CONOPT
Loading...
Searching...
No Matches
leastsq9.f90
Go to the documentation of this file.
1!> @file leastsq9.f90
2!! @ingroup FORT1THREAD_EXAMPLES
3!!
4!!
5!! The model is similar to leastsq7, but we test an alternative optimal
6!! solution that was found at some stage with bounded residuals.
7!! The new solution is then used as a starting point for a run without
8!! bounded residuals and the solution should still be optimal.
9!!
10!! For efficiency, the model is smaller.
11!!
12!! We solve the following nonlinear least squares model:
13!!
14!! \f[
15!! \min \sum_i res_{i}^2 \\
16!!
17!! \sum_j ( a_{ij}x_j + b_{ij}x_j^2 ) + res_i = obs_i
18!! \f]
19!!
20!! where \f$a\f$, \f$b\f$, and \f$obs\f$ are known data, and \f$res\f$ and \f$x\f$ are the
21!! variables of the model.
22!!
23!!
24!! For more information about the individual callbacks, please have a look at the source code.
25
26#if defined(_WIN32) && !defined(_WIN64)
27#define dec_directives_win32
28#endif
29
30module lsq9
31 Integer, parameter :: Nobs = 14
32 Integer, parameter :: DimX = 10
33 real*8, dimension(Nobs,DimX) :: a, b
34 real*8, dimension(Nobs) :: obs
35 Integer :: run ! Run = 1 standard,
36 ! Run = 2 with wide bounds on Res
37 ! Run = 3 standard model with obs(1) changed by +1.e-3
38end module lsq9
39
40
41REAL FUNCTION rndx( )
42!
43! Defines a pseudo random number between 0 and 1
44!
45 IMPLICIT NONE
46
47 Integer, save :: seed = 12359
48
49 seed = mod(seed*1027+25,1048576)
50 rndx = float(seed)/float(1048576)
51
52END FUNCTION rndx
53
54subroutine defdata
55!
56! Define values for A, B, and Obs
57!
58 Use lsq9
59 IMPLICIT NONE
60
61 Integer :: i, j
62 real*8, Parameter :: xtarg = -1.0
63 real*8, Parameter :: noise = 1.0
64 Real, External :: Rndx
65 real*8 :: o
66
67 do i = 1, nobs
68 o = 0.d0
69 do j = 1, dimx
70 a(i,j) = rndx()
71 b(i,j) = rndx()
72 o = o + a(i,j) * xtarg + b(i,j) * xtarg**2
73 enddo
74 obs(i) = o + noise * rndx()
75 enddo
76
77end subroutine defdata
78!
79! Main program.
80!
81!> Main program. A simple setup and call of CONOPT
82!!
83Program leastsquare
84
86 Use conopt
87 Use lsq9
88 IMPLICIT NONE
89!
90! Declare the user callback routines as Integer, External:
91!
92 Integer, External :: lsq_readmatrix ! Mandatory Matrix definition routine defined below
93 Integer, External :: lsq_fdeval ! Function and Derivative evaluation routine
94 ! needed a nonlinear model.
95 Integer, External :: std_status ! Standard callback for displaying solution status
96 Integer, External :: std_solution ! Standard callback for displaying solution values
97 Integer, External :: std_message ! Standard callback for managing messages
98 Integer, External :: std_errmsg ! Standard callback for managing error messages
99 Integer, External :: lsq_2dlagrstr ! Callback for second derivatives structure
100 Integer, External :: lsq_2dlagrval ! Callback for second derivatives values
101 Integer, External :: lsq_option ! Option defining callback routine
102#ifdef dec_directives_win32
103!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: Lsq_ReadMatrix
104!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: Lsq_FDEval
105!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: Std_Status
106!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: Std_Solution
107!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: Std_Message
108!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: Std_ErrMsg
109!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: Lsq_2DLagrStr
110!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: Lsq_2DLagrVal
111!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: Lsq_Option
112#endif
113!
114! Control vector
115!
116 INTEGER, Dimension(:), Pointer :: cntvect
117 INTEGER :: coi_error
118!
119 Integer :: i
120 Character(Len=132) :: text
121 real*8 :: obj_run1, obj_run2
122
123 call startup
124!
125! Define data
126!
127 Call defdata
128!
129! Create and initialize a Control Vector
130!
131 coi_error = coi_create( cntvect )
132!
133! Tell CONOPT about the size of the model by populating the Control Vector:
134!
135 coi_error = max( coi_error, coidef_numvar( cntvect, nobs + dimx ) )
136 coi_error = max( coi_error, coidef_numcon( cntvect, nobs + 1 ) )
137 coi_error = max( coi_error, coidef_numnz( cntvect, nobs * (dimx+2) ) )
138 coi_error = max( coi_error, coidef_numnlnz( cntvect, nobs * (dimx+1) ) )
139 coi_error = max( coi_error, coidef_numhess( cntvect, nobs + dimx ) )
140 coi_error = max( coi_error, coidef_optdir( cntvect, -1 ) ) ! Minimize
141 coi_error = max( coi_error, coidef_objcon( cntvect, nobs + 1 ) ) ! Objective is last constraint
142 coi_error = max( coi_error, coidef_optfile( cntvect, 'leastsq9.opt' ) )
143!
144! Tell CONOPT about the callback routines:
145!
146 coi_error = max( coi_error, coidef_readmatrix( cntvect, lsq_readmatrix ) )
147 coi_error = max( coi_error, coidef_fdeval( cntvect, lsq_fdeval ) )
148 coi_error = max( coi_error, coidef_status( cntvect, std_status ) )
149 coi_error = max( coi_error, coidef_solution( cntvect, std_solution ) )
150 coi_error = max( coi_error, coidef_message( cntvect, std_message ) )
151 coi_error = max( coi_error, coidef_errmsg( cntvect, std_errmsg ) )
152 coi_error = max( coi_error, coidef_2dlagrstr( cntvect, lsq_2dlagrstr ) )
153 coi_error = max( coi_error, coidef_2dlagrval( cntvect, lsq_2dlagrval ) )
154 coi_error = max( coi_error, coidef_option( cntvect, lsq_option ) )
155
156#if defined(CONOPT_LICENSE_INT_1) && defined(CONOPT_LICENSE_INT_2) && defined(CONOPT_LICENSE_INT_3) && defined(CONOPT_LICENSE_TEXT)
157 coi_error = max( coi_error, coidef_license( cntvect, conopt_license_int_1, conopt_license_int_2, conopt_license_int_3, conopt_license_text) )
158#endif
159
160 If ( coi_error .ne. 0 ) THEN
161 write(*,*)
162 write(*,*) '**** Fatal Error while loading CONOPT Callback routines.'
163 write(*,*)
164 call flog( "Skipping Solve due to setup errors", 1 )
165 ENDIF
166!
167! Save the solution so we can check the duals:
168!
169 do_allocate = .true.
170!
171! Start CONOPT:
172!
173 run = 1
174 coi_error = coi_solve( cntvect )
175
176 If ( coi_error /= 0 ) then
177 call flog( "Run 1: Errors encountered during solution", 1 )
178 elseif ( stacalls == 0 .or. solcalls == 0 ) then
179 call flog( "Run 1: Status or Solution routine was not called", 1 )
180 elseif ( .not. ( sstat == 1 .and. mstat == 2 ) ) then
181 call flog( "Run 1: Solver or Model status was not as expected (1,2)", 1 )
182! elseif ( abs( OBJ - 19.44434311d0 ) > 1.d-7 ) then
183! call flog( "Run 1: Incorrect objective returned", 1 )
184 Else
185 do i = 1, nobs
186 if ( abs( udual(i) - 2*xprim(dimx+i) ) > 2.d-7 ) then
187 write(text,*) 'Run 1: Dual and Primal did not match in constraint',i,' P=',xprim(dimx+i),' D=',udual(i)
188 call flog( text, 1 )
189 endif
190 enddo
191 Call checkdual( 'Run 1: Leastsq9', minimize )
192 endif
193 obj_run1 = obj
194!
195! Repeat but with bounds on the residuals. They cannot be moved into
196! the post-triangle any more. Also use initial values close to a known
197! alternate solution.
198!
199 run = 2
200 coi_error = coi_solve( cntvect )
201
202 If ( coi_error /= 0 ) then
203 call flog( "Run 2: Errors encountered during solution", 1 )
204 elseif ( stacalls == 0 .or. solcalls == 0 ) then
205 call flog( "Run 2: Status or Solution routine was not called", 1 )
206 elseif ( .not. ( sstat == 1 .and. mstat == 2 ) ) then
207 call flog( "Run 2: Solver or Model status was not as expected (1,2)", 1 )
208! elseif ( abs( OBJ - OBJ_Run1 ) > 1.d-7 ) then
209! call flog( "Run 2: Incorrect objective returned", 1 )
210 Else
211 do i = 1, nobs
212 if ( abs( udual(i) - 2*xprim(dimx+i) ) > 2.d-7 ) then
213 write(text,*) 'Run 2: Dual and Primal did not match in constraint',i,' P=',xprim(dimx+i),' D=',udual(i)
214 call flog( text, 1 )
215 endif
216 enddo
217 Call checkdual( 'Run 2: Leastsq9', minimize )
218 endif
219 obj_run2 = obj
220!
221! Repeat but with the solution from run2 used as an initial solution.
222!
223 run = 3
224 coi_error = coi_solve( cntvect )
225
226 If ( coi_error /= 0 ) then
227 call flog( "Run 3: Errors encountered during solution", 1 )
228 elseif ( stacalls == 0 .or. solcalls == 0 ) then
229 call flog( "Run 3: Status or Solution routine was not called", 1 )
230 elseif ( .not. ( sstat == 1 .and. mstat == 2 ) ) then
231 call flog( "Run 3: Solver or Model status was not as expected (1,2)", 1 )
232 elseif ( abs( obj - obj_run2 ) > 1.d-6 ) then !
233 call flog( "Run 3: Incorrect objective returned in run3 ", 1 )
234 else
235 Call checkdual( 'Run 3: Leastsq9', minimize )
236 endif
237
238 write(*,*)
239 write(*,*) 'End of Least Square example 7. Return code=',coi_error
240
241 if ( coi_free(cntvect) /= 0 ) call flog( "Error while freeing control vector",1)
243 call flog( "Successful Solve", 0 )
244
245End Program leastsquare
246!
247! ============================================================================
248! Define information about the model:
249!
250
251!> Define information about the model
252!!
253!! @include{doc} readMatrix_params.dox
254Integer Function lsq_readmatrix( lower, curr, upper, vsta, type, rhs, esta, &
255 colsta, rowno, value, nlflag, n, m, nz, &
256 usrmem )
257#ifdef dec_directives_win32
258!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: Lsq_ReadMatrix
259#endif
260 Use proginfo
261 Use lsq9
262 IMPLICIT NONE
263 integer, intent (in) :: n ! number of variables
264 integer, intent (in) :: m ! number of constraints
265 integer, intent (in) :: nz ! number of nonzeros
266 real*8, intent (in out), dimension(n) :: lower ! vector of lower bounds
267 real*8, intent (in out), dimension(n) :: curr ! vector of initial values
268 real*8, intent (in out), dimension(n) :: upper ! vector of upper bounds
269 integer, intent (in out), dimension(n) :: vsta ! vector of initial variable status
270 ! (not defined here)
271 integer, intent (out), dimension(m) :: type ! vector of equation types
272 integer, intent (in out), dimension(m) :: esta ! vector of initial equation status
273 ! (not defined here)
274 real*8, intent (in out), dimension(m) :: rhs ! vector of right hand sides
275 integer, intent (in out), dimension(n+1) :: colsta ! vector with start of column indices
276 integer, intent (out), dimension(nz) :: rowno ! vector of row numbers
277 integer, intent (in out), dimension(nz) :: nlflag ! vector of nonlinearity flags
278 real*8, intent (in out), dimension(nz) :: value ! vector of matrix values
279 real*8 usrmem(*) ! optional user memory
280
281 Integer :: i, j, k
282!
283! Information about Variables:
284! Default: Lower = -Inf, Curr = 0, and Upper = +inf.
285! Default: the status information in Vsta is not used.
286!
287 do i = 1, dimx
288 curr(i) = -0.8d0
289 enddo
290 if ( run == 2 ) Then ! Add large bound on Res that will prevent the
291 do i = 1, nobs ! post triangle from being identified.
292 lower(dimx+i) = -2.0d0
293 upper(dimx+i) = +2.0d0
294 enddo
295 curr = &
296 (/ -1.280997e+00, -3.966357e-01, -1.418473e+00, -7.497624e-01, -1.034839e+00, &
297 -1.006460e+00, -1.090813e+00, -1.181425e+00, 2.505639e-01, -1.139540e+00, &
298 1.275053e-02, -3.982541e-02, 1.602648e-01, -8.255030e-02, -9.448025e-02, &
299 -9.631539e-03, 1.857009e-01, -2.428132e-01, 2.244003e-01, -6.741576e-02, &
300 -1.749643e-01, -7.359635e-02, 1.151421e-03, 6.899964e-02 /)
301 endif
302 if ( run == 3 ) Then ! In run 3 use the previous solution as the
303 curr = xprim
304 endif
305!
306! Information about Constraints:
307! Default: Rhs = 0
308! Default: the status information in Esta and the function
309! value in FV are not used.
310! Default: Type: There is no default.
311! 0 = Equality,
312! 1 = Greater than or equal,
313! 2 = Less than or equal,
314! 3 = Non binding.
315!
316! Constraints 1 to Nobs:
317! Rhs = Obs(i) and type Equality
318!
319 do i = 1, nobs
320 rhs(i) = obs(i)
321 type(i) = 0
322 enddo
323!
324! Constraint Nobs + 1 (Objective)
325! Rhs = 0 and type Non binding
326!
327 type(nobs+1) = 3
328!
329! Information about the Jacobian. CONOPT expects a columnwise
330! representation in Rowno, Value, Nlflag and Colsta.
331!
332! Colsta = Start of column indices (No Defaults):
333! Rowno = Row indices
334! Value = Value of derivative (by default only linear
335! derivatives are used)
336! Nlflag = 0 for linear and 1 for nonlinear derivative
337! (not needed for completely linear models)
338!
339!
340! Indices
341! x(i) res(j)
342! j: NL L=1
343! obj: NL
344!
345 k = 1
346 do j = 1, dimx
347 colsta(j) = k
348 do i = 1, nobs
349 rowno(k) = i
350 nlflag(k) = 1
351 k = k + 1
352 enddo
353 enddo
354 do i = 1, nobs
355 colsta(dimx+i) = k
356 rowno(k) = i
357 nlflag(k) = 0
358 value(k) = 1.d0
359 k = k + 1
360 rowno(k) = nobs+1
361 nlflag(k) = 1
362 k = k + 1
363 enddo
364 colsta(dimx+nobs+1) = k
365
366 lsq_readmatrix = 0 ! Return value means OK
367
368end Function lsq_readmatrix
369!
370!==========================================================================
371! Compute nonlinear terms and non-constant Jacobian elements
372!
373
374!> Compute nonlinear terms and non-constant Jacobian elements
375!!
376!! @include{doc} fdeval_params.dox
377Integer Function lsq_fdeval( x, g, jac, rowno, jcnm, mode, ignerr, errcnt, &
378 n, nz, thread, usrmem )
379#ifdef dec_directives_win32
380!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: Lsq_FDEval
381#endif
382 use lsq9
383 IMPLICIT NONE
384 integer, intent (in) :: n ! number of variables
385 integer, intent (in) :: rowno ! number of the row to be evaluated
386 integer, intent (in) :: nz ! number of nonzeros in this row
387 real*8, intent (in), dimension(n) :: x ! vector of current solution values
388 real*8, intent (in out) :: g ! constraint value
389 real*8, intent (in out), dimension(n) :: jac ! vector of derivatives for current constraint
390 integer, intent (in), dimension(nz) :: jcnm ! list of variables that appear nonlinearly
391 ! in this row. Ffor information only.
392 integer, intent (in) :: mode ! evaluation mode: 1 = function value
393 ! 2 = derivatives, 3 = both
394 integer, intent (in) :: ignerr ! if 1 then errors can be ignored as long
395 ! as errcnt is incremented
396 integer, intent (in out) :: errcnt ! error counter to be incremented in case
397 ! of function evaluation errors.
398 integer, intent (in) :: thread
399 real*8 usrmem(*) ! optional user memory
400
401 integer :: i,j
402 real*8 :: s
403!
404! Row Nobs+1: the objective function is nonlinear
405!
406 if ( rowno .eq. nobs+1 ) then
407!
408! Mode = 1 or 3. Function value: G = sum(i, res(i)**2)
409!
410 if ( mode .eq. 1 .or. mode .eq. 3 ) then
411 s = 0.d0
412 do i = 1, nobs
413 s = s + x(dimx+i)**2
414 enddo
415 g = s
416 endif
417!
418! Mode = 2 or 3: Derivative values:
419!
420 if ( mode .eq. 2 .or. mode .eq. 3 ) then
421 do i = 1, nobs
422 jac(dimx+i) = 2*x(dimx+i)
423 enddo
424 endif
425!
426! Row 1 to Nobs: The observation definitions:
427!
428 else
429!
430! Mode = 1 or 3: Function value - x-part only
431!
432 if ( mode .eq. 1 .or. mode .eq. 3 ) then
433 s = 0.d0
434 do j = 1, dimx
435 s = s + a(rowno,j)*x(j) + b(rowno,j)*x(j)**2
436 enddo
437 g = s
438 endif
439!
440! Mode = 2 or 3: Derivatives
441!
442 if ( mode .eq. 2 .or. mode .eq. 3 ) then
443 do j = 1, dimx
444 jac(j) = a(rowno,j) + 2.d0*b(rowno,j)*x(j)
445 enddo
446 endif
447 endif
448 lsq_fdeval = 0
449
450end Function lsq_fdeval
451
452
453!> Specify the structure of the Lagrangian of the Hessian
454!!
455!! @include{doc} 2DLagrStr_params.dox
456Integer Function lsq_2dlagrstr( HSRW, HSCL, NODRV, N, M, NHESS, UsrMem )
457#ifdef dec_directives_win32
458!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: Lsq_2DLagrStr
459#endif
460 use lsq9
461 Implicit None
462
463 Integer, Intent (IN) :: n, m, nhess
464 Integer, Intent (IN OUT) :: nodrv
465 Integer, Dimension(Nhess), Intent (Out) :: hsrw, hscl
466 real*8, Intent(IN OUT) :: usrmem(*)
467
468 integer :: i
469!
470! We assume that this is a Large Residual model, where the most
471! important 2nd derivatives are those that appear directly in the
472! objective.
473! We will therefore only define the 2nd derivatives corresponding to
474! the objective constraint where the 2nd derivatives is 2*I.
475! CONOPT will by default complain that some nonlinear variables do
476! not appear in the Hessian. We will therefore define one dummy element
477! on the diagonal of the Hessian for each of the nonlinear X-variables
478! and give it the numerical value 0.
479!
480!
481! Define structure of Hessian
482!
483 do i = 1, dimx+nobs
484 hsrw(i) = i
485 hscl(i) = i
486 enddo
487
488 lsq_2dlagrstr = 0
489
490End Function lsq_2dlagrstr
491
492
493!> Compute the Lagrangian of the Hessian
494!!
495!! @include{doc} 2DLagrVal_params.dox
496Integer Function lsq_2dlagrval( X, U, HSRW, HSCL, HSVL, NODRV, N, M, NHESS, UsrMem )
497#ifdef dec_directives_win32
498!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: Lsq_2DLagrVal
499#endif
500 use lsq9
501 Implicit None
502
503 Integer, Intent (IN) :: n, m, nhess
504 Integer, Intent (IN OUT) :: nodrv
505 real*8, Dimension(N), Intent (IN) :: x
506 real*8, Dimension(M), Intent (IN) :: u
507 Integer, Dimension(Nhess), Intent (In) :: hsrw, hscl
508 real*8, Dimension(NHess), Intent (Out) :: hsvl
509 real*8, Intent(IN OUT) :: usrmem(*)
510
511 integer :: i
512!
513! We assume that this is a Large Residual model, where the most
514! important 2nd derivatives are those that appear directly in the
515! objective.
516! We will therefore only define the 2nd derivatives corresponding to
517! the objective constraint where the 2nd derivatives is 2*I.
518! CONOPT will by default complain that some nonlinear variables do
519! not appear in the Hessian. We will therefore define one dummy element
520! on the diagonal of the Hessian for each of the nonlinear X-variables
521! and give it the numerical value 0.
522!
523! Normal Evaluation mode
524!
525 do i = 1, dimx
526 hsvl(i) = 0.d0
527 enddo
528 do i = 1, nobs
529 hsvl(dimx+i) = 2.d0*u(nobs+1)
530 enddo
531
532 lsq_2dlagrval = 0
533
534End Function lsq_2dlagrval
535
536
537!> Sets runtime options
538!!
539!! @include{doc} option_params.dox
540Integer Function lsq_option( ncall, rval, ival, lval, usrmem, name )
541#ifdef dec_directives_win32
542!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: Lsq_Option
543#endif
544 integer ncall, ival, lval
545 character(Len=*) :: name
546 real*8 rval
547 real*8 usrmem(*) ! optional user memory
548
549 Select case (ncall)
550 case (1)
551 name = 'lkdeb2' ! Turn the debugger off
552 ival = 0
553 case default
554 name = ' '
555 end Select
556 lsq_option = 0
557
558end Function lsq_option
integer function std_solution(xval, xmar, xbas, xsta, yval, ymar, ybas, ysta, n, m, usrmem)
Definition comdecl.f90:132
integer function std_status(modsta, solsta, iter, objval, usrmem)
Definition comdecl.f90:88
subroutine checkdual(case, minmax)
Definition comdecl.f90:394
integer function std_message(smsg, dmsg, nmsg, llen, usrmem, msgv)
Definition comdecl.f90:205
integer function std_errmsg(rowno, colno, posno, msglen, usrmem, msg)
Definition comdecl.f90:248
integer(c_int) function coidef_message(cntvect, coi_message)
define callback routine for handling messages returned during the solution process.
Definition conopt.f90:1265
integer(c_int) function coidef_solution(cntvect, coi_solution)
define callback routine for returning the final solution values.
Definition conopt.f90:1238
integer(c_int) function coidef_status(cntvect, coi_status)
define callback routine for returning the completion status.
Definition conopt.f90:1212
integer(c_int) function coidef_readmatrix(cntvect, coi_readmatrix)
define callback routine for providing the matrix data to CONOPT.
Definition conopt.f90:1111
integer(c_int) function coidef_errmsg(cntvect, coi_errmsg)
define callback routine for returning error messages for row, column or Jacobian elements.
Definition conopt.f90:1291
integer(c_int) function coidef_fdeval(cntvect, coi_fdeval)
define callback routine for performing function and derivative evaluations.
Definition conopt.f90:1135
integer(c_int) function coidef_2dlagrstr(cntvect, coi_2dlagrstr)
define callback routine for providing the structure of the second derivatives of the Lagrangian.
Definition conopt.f90:1547
integer(c_int) function coidef_optfile(cntvect, optfile)
define callback routine for defining an options file.
Definition conopt.f90:928
integer(c_int) function coidef_option(cntvect, coi_option)
define callback routine for defining runtime options.
Definition conopt.f90:1346
integer(c_int) function coidef_2dlagrval(cntvect, coi_2dlagrval)
define callback routine for computing the values of the second derivatives of the Lagrangian.
Definition conopt.f90:1573
integer(c_int) function coidef_license(cntvect, licint1, licint2, licint3, licstring)
define the License Information.
Definition conopt.f90:293
integer(c_int) function coidef_numvar(cntvect, numvar)
defines the number of variables in the model.
Definition conopt.f90:97
integer(c_int) function coidef_numcon(cntvect, numcon)
defines the number of constraints in the model.
Definition conopt.f90:121
integer(c_int) function coidef_numnlnz(cntvect, numnlnz)
defines the Number of Nonlinear Nonzeros.
Definition conopt.f90:167
integer(c_int) function coidef_optdir(cntvect, optdir)
defines the Optimization Direction.
Definition conopt.f90:213
integer(c_int) function coidef_numnz(cntvect, numnz)
defines the number of nonzero elements in the Jacobian.
Definition conopt.f90:144
integer(c_int) function coidef_numhess(cntvect, numhess)
defines the Number of Hessian Nonzeros.
Definition conopt.f90:188
integer(c_int) function coidef_objcon(cntvect, objcon)
defines the Objective Constraint.
Definition conopt.f90:239
integer(c_int) function coi_create(cntvect)
initializes CONOPT and creates the control vector.
Definition conopt.f90:1726
integer(c_int) function coi_free(cntvect)
frees the control vector.
Definition conopt.f90:1749
integer(c_int) function coi_solve(cntvect)
method for starting the solving process of CONOPT.
Definition conopt.f90:1625
integer function lsq_readmatrix(lower, curr, upper, vsta, type, rhs, esta, colsta, rowno, value, nlflag, n, m, nz, usrmem)
Define information about the model.
Definition leastl1.f90:166
integer function lsq_fdeval(x, g, jac, rowno, jcnm, mode, ignerr, errcnt, n, nz, thread, usrmem)
Compute nonlinear terms and non-constant Jacobian elements.
Definition leastl1.f90:287
integer function lsq_2dlagrstr(hsrw, hscl, nodrv, n, m, nhess, usrmem)
Specify the structure of the Lagrangian of the Hessian.
Definition leastsq2.f90:359
integer function lsq_2dlagrval(x, u, hsrw, hscl, hsvl, nodrv, n, m, nhess, usrmem)
Compute the Lagrangian of the Hessian.
Definition leastsq2.f90:396
integer function lsq_option(ncall, rval, ival, lval, usrmem, name)
Sets runtime options.
Definition leastsq2.f90:437
#define dimx
Definition leastsq.c:16
#define nobs
Definition leastsq.c:15
void defdata()
Defines the data for the problem.
Definition leastsq.c:35
float rndx()
Defines a pseudo random number between 0 and 1.
Definition leastsq.c:22
program leastsquare
Main program. A simple setup and call of CONOPT.
Definition leastsq.f90:68
real *8, dimension(nobs, dimx) a
Definition leastsq9.f90:35
real *8, dimension(nobs) obs
Definition leastsq9.f90:36
integer run
Definition leastsq9.f90:37
real *8, dimension(nobs, dimx) b
Definition leastsq9.f90:35
real *8 obj
Definition comdecl.f90:16
integer solcalls
Definition comdecl.f90:15
integer sstat
Definition comdecl.f90:18
real *8, dimension(:), pointer udual
Definition comdecl.f90:24
integer, parameter minimize
Definition comdecl.f90:31
integer stacalls
Definition comdecl.f90:14
subroutine flog(msg, code)
Definition comdecl.f90:62
logical do_allocate
Definition comdecl.f90:27
real *8, dimension(:), pointer xprim
Definition comdecl.f90:23
integer mstat
Definition comdecl.f90:17
subroutine startup
Definition comdecl.f90:41