CONOPT
Loading...
Searching...
No Matches
mp_polygon2.f90
Go to the documentation of this file.
1!> @file mp_polygon2.f90
2!! @ingroup FORTOPENMP_EXAMPLES
3!!
4!!
5!! Polygon model from COPS test set.
6!! The model is run sequentially and with various number of threads but with ThreadC defined.
7!! The models with various number of threads should produce identical solutions and we test
8!! this.
9!!
10!!
11!! For more information about the individual callbacks, please have a look at the source code.
12
13#if defined(_WIN32) && !defined(_WIN64)
14#define dec_directives_win32
15#endif
16
17Module pdata2
18 Integer, Parameter :: NP = 50 ! Number of polygon points
19 Integer, Parameter :: NV = 2*np ! Number of variables
20 Integer, Parameter :: no = np-1 ! Number of Ordered constraints
21 Integer, Parameter :: nd = np*(np-1)/2 ! Number of distance constraints
22 Integer, dimension(ND) :: rowmapi, rowmapj ! Map from distance index to i and j
23 Integer, dimension(NP,NP) :: rowmapk
24 real*8, dimension(NV) :: xprim, xprim1, xprim2, xprim4
25end module pdata2
27!> Main program. A simple setup and call of CONOPT
28!!
29Program polygon
30
32 Use conopt
33 Use pdata2
34 Use omp_lib
35 implicit None
36!
37! Declare the user callback routines as Integer, External:
38!
39 Integer, External :: poly_readmatrix ! Mandatory Matrix definition routine defined below
40 Integer, External :: poly_fdeval ! Function and Derivative evaluation routine
41 ! needed a nonlinear model.
42 Integer, External :: std_status ! Standard callback for displaying solution status
43 Integer, External :: poly_solution ! Special callback for displaying and testing solution values
44 Integer, External :: std_message ! Standard callback for managing messages
45 Integer, External :: std_errmsg ! Standard callback for managing error messages
46#ifdef dec_directives_win32
47!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: Poly_ReadMatrix
48!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: Poly_FDEval
49!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: Std_Status
50!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: Poly_Solution
51!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: Std_Message
52!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: Std_ErrMsg
53#endif
54!
55! Control vector
56!
57 INTEGER, Dimension(:), Pointer :: cntvect
58 INTEGER :: coi_error
59
60 real*8 time0, time1, time2, time4
61 Integer :: iter1, iter2, iter4
62 Integer :: i
63 Logical :: same12, same14, same24
64!
65! The model shown here in GAMS format
66!
67! set i sides / i1*i%nv% /;
68!
69! alias (i,j);
70!
71! scalar pi a famous constant;
72!
73!
74! positive variables
75! r(i) polar radius (distance to fixed vertex)
76! theta(i) polar angle (measured from fixed direction)
77! variable polygon_area
78!
79! equations
80! obj
81! distance(i,j)
82! ordered(i) ;
83!
84! obj.. polygon_area =e= 0.5*sum(j(i+1), r(i+1)*r(i)*sin(theta(i+1)-theta(i)));
85!
86! ordered(i+1).. theta(i) =l= theta(i+1);
87!
88! distance(i,j)$(ord(j) > ord(i))..
89! sqr(r(i)) + sqr(r(j)) - 2*r(i)*r(j)*cos(theta(j)-theta(i)) =l= 1;
90!
91!
92! pi = 2*arctan(inf);
93!
94! r.up(i) = 1;
95! theta.up(i) = pi;
96!
97! r.fx('i%nv%') = 0;
98! theta.fx('i%nv%') = pi;
99!
100! r.l(i) = 4*ord(i)*(card(i)+ 1- ord(i))/sqr(card(i)+1);
101! theta.l(i) = pi*ord(i)/card(i);
102!
103! model polygon /all/;
104!
105! $if set workspace polygon.workspace = %workspace%;
106!
107! solve polygon using nlp maximizing polygon_area;
108!
109! Create and initialize a Control Vector
110!
111 call startup
112
113 coi_error = coi_create( cntvect )
114!
115! Tell CONOPT about the size of the model by populating the Control Vector:
116!
117 coi_error = max( coi_error, coidef_numvar( cntvect, nv ) ) ! # variables
118 coi_error = max( coi_error, coidef_numcon( cntvect, no + nd + 1 ) ) ! # constraints
119 coi_error = max( coi_error, coidef_numnz( cntvect, 2*no+4*nd+nv ) ) ! # nonzeros in the Jacobian
120 coi_error = max( coi_error, coidef_numnlnz( cntvect, 4*nd+nv ) ) ! # of which are nonlinear
121 coi_error = max( coi_error, coidef_optdir( cntvect, +1 ) ) ! Maximize
122 coi_error = max( coi_error, coidef_objcon( cntvect, no + nd + 1 ) ) ! Objective is last constraint
123 coi_error = max( coi_error, coidef_optfile( cntvect, 'mp_polygon2.opt' ) )
124!
125! Tell CONOPT about the callback routines:
126!
127 coi_error = max( coi_error, coidef_readmatrix( cntvect, poly_readmatrix ) )
128 coi_error = max( coi_error, coidef_fdeval( cntvect, poly_fdeval ) )
129 coi_error = max( coi_error, coidef_status( cntvect, std_status ) )
130 coi_error = max( coi_error, coidef_solution( cntvect, poly_solution ) )
131 coi_error = max( coi_error, coidef_message( cntvect, std_message ) )
132 coi_error = max( coi_error, coidef_errmsg( cntvect, std_errmsg ) )
133
134#if defined(CONOPT_LICENSE_INT_1) && defined(CONOPT_LICENSE_INT_2) && defined(CONOPT_LICENSE_INT_3) && defined(CONOPT_LICENSE_TEXT)
135 coi_error = max( coi_error, coidef_license( cntvect, conopt_license_int_1, conopt_license_int_2, conopt_license_int_3, conopt_license_text) )
136#endif
137
138 If ( coi_error .ne. 0 ) THEN
139 write(*,*)
140 write(*,*) '**** Fatal Error while loading CONOPT Callback routines.'
141 write(*,*)
142 call flog( "Skipping Solve due to setup errors", 1 )
143 ENDIF
144!
145! Start CONOPT -- First time use ThreadC < ThreadS. We should get error 115.
146!
147 coi_error = max( coi_error, coidef_threads( cntvect, 2 ) ) !
148 coi_error = max( coi_error, coidef_threadc( cntvect, 1 ) ) !
149 coi_error = coi_solve( cntvect )
150
151 write(*,*)
152 write(*,*) 'End of Polygon example with one thread. Return code=',coi_error
153
154 If ( coi_error /= 115 ) then
155 call flog( "ThreadC = 1 and ThreadS = 2 did not give error return 115.", 1 )
156 endif
157 coi_error = max( coi_error, coidef_threadc( cntvect, 8 ) ) ! Cut work in 8 when testing threads
158!
159! Start CONOPT again -- this time exactly 1 thread
160!
161 coi_error = max( coi_error, coidef_threads( cntvect, 1 ) ) ! Use 1 thread
162 time0 = omp_get_wtime()
163 coi_error = coi_solve( cntvect )
164 time1 = omp_get_wtime() - time0
165
166 write(*,*)
167 write(*,*) 'End of Polygon example with 1 threads. Return code=',coi_error
168
169 If ( coi_error /= 0 ) then
170 call flog( "Single thread: Errors encountered during solution", 1 )
171 elseif ( stacalls == 0 .or. solcalls == 0 ) then
172 call flog( "Single thread: Status or Solution routine was not called", 1 )
173 elseif ( sstat /= 1 .or. mstat /= 2 ) then
174 call flog( "Single thread: Solver and Model Status was not as expected (1,2)", 1 )
175 endif
176 iter1 = miter
177 xprim1 = xprim
178!
179! Start CONOPT again -- this time exactly 2 threads -- we keep ThreadC = 8
180!
181 coi_error = max( coi_error, coidef_threads( cntvect, 2 ) ) ! Use 2 thread
182 time0 = omp_get_wtime()
183 coi_error = coi_solve( cntvect )
184 time2 = omp_get_wtime() - time0
185
186 write(*,*)
187 write(*,*) 'End of Polygon example with 2 threads. Return code=',coi_error
188
189 If ( coi_error /= 0 ) then
190 call flog( "Double threads: Errors encountered during solution", 1 )
191 elseif ( stacalls == 0 .or. solcalls == 0 ) then
192 call flog( "Double threads: Status or Solution routine was not called", 1 )
193 elseif ( sstat /= 1 .or. mstat /= 2 ) then
194 call flog( "Double threads: Solver and Model Status was not as expected (1,2)", 1 )
195 endif
196 iter2 = miter
197 xprim2 = xprim
198!
199! Start CONOPT again -- this time exactly 4 threads -- we keep ThreadC = 16
200!
201 coi_error = max( coi_error, coidef_threads( cntvect, 4 ) ) ! Use 4 thread
202 time0 = omp_get_wtime()
203 coi_error = coi_solve( cntvect )
204 time4 = omp_get_wtime() - time0
205
206 write(*,*)
207 write(*,*) 'End of Polygon example with 4 threads. Return code=',coi_error
208
209 If ( coi_error /= 0 ) then
210 call flog( "Quad threads: Errors encountered during solution", 1 )
211 elseif ( stacalls == 0 .or. solcalls == 0 ) then
212 call flog( "Quad threads: Status or Solution routine was not called", 1 )
213 elseif ( sstat /= 1 .or. mstat /= 2 ) then
214 call flog( "Quad threads: Solver and Model Status was not as expected (1,2)", 1 )
215 endif
216 iter4 = miter
217 xprim4 = xprim
218
219 same12 = .true.
220 same14 = .true.
221 same24 = .true.
222 Do i = 1, nv
223 If ( xprim2(i) /= xprim1(i) ) then
224 if ( same12 ) then
225 write(*,*) 'Solution 2 is different from Solution 1. First diff for index',i
226 endif
227 same12 = .false.
228 endif
229 If ( xprim4(i) /= xprim1(i) ) then
230 if ( same14 ) then
231 write(*,*) 'Solution 4 is different from Solution 1. First diff for index',i
232 endif
233 same14 = .false.
234 endif
235 If ( xprim4(i) /= xprim2(i) ) then
236 if ( same24 ) then
237 write(*,*) 'Solution 4 is different from Solution 2. First diff for index',i
238 endif
239 same24 = .false.
240 endif
241 Enddo
242
243 write(*,*)
244 write(*,"('Time for single thread',f10.3)") time1
245 write(*,"('Time for double thread',f10.3)") time2
246 write(*,"('Time for quad thread',f10.3)") time4
247 write(*,"('Speedup double ',f10.3)") time1/time2
248 write(*,"('Speedup quad ',f10.3)") time1/time4
249 if ( same12 .and. same14 .and. same24 ) then
250 write(*,*) 'All solutions are the same'
251 else
252 write(*,*) 'The solutions are NOT the same'
253! call flog( "Solutions are not the same", 1 )
254 Endif
255
256 if ( coi_free( cntvect ) /= 0 ) call flog( "Error while freeing control vector", 1 )
257
258 call flog( "Successful Solve", 0 )
259
260End Program polygon
261!
262! ============================================================================
263! Define information about the model:
264!
265
266!> Define information about the model
267!!
268!! @include{doc} readMatrix_params.dox
269Integer Function poly_readmatrix( lower, curr, upper, vsta, type, rhs, esta, &
270 colsta, rowno, value, nlflag, n, m, nz, &
271 usrmem )
272#ifdef dec_directives_win32
273!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: Poly_ReadMatrix
274#endif
275 Use pdata2
276 implicit none
277 integer, intent (in) :: n ! number of variables
278 integer, intent (in) :: m ! number of constraints
279 integer, intent (in) :: nz ! number of nonzeros
280 real*8, intent (in out), dimension(n) :: lower ! vector of lower bounds
281 real*8, intent (in out), dimension(n) :: curr ! vector of initial values
282 real*8, intent (in out), dimension(n) :: upper ! vector of upper bounds
283 integer, intent (in out), dimension(n) :: vsta ! vector of initial variable status
284 ! (not defined here)
285 integer, intent (out), dimension(m) :: type ! vector of equation types
286 integer, intent (in out), dimension(m) :: esta ! vector of initial equation status
287 ! (not defined here)
288 real*8, intent (in out), dimension(m) :: rhs ! vector of right hand sides
289 integer, intent (in out), dimension(n+1) :: colsta ! vector with start of column indices
290 integer, intent (out), dimension(nz) :: rowno ! vector of row numbers
291 integer, intent (in out), dimension(nz) :: nlflag ! vector of nonlinearity flags
292 real*8, intent (in out), dimension(nz) :: value ! vector of matrix values
293 real*8 usrmem(*) ! optional user memory
294
295 Integer :: i, j, k
296 real*8, parameter :: pi = 3.141592
297
298!
299! Information about Variables:
300! Default: Lower = -Inf, Curr = 0, and Upper = +inf.
301! Default: the status information in Vsta is not used.
302!
303! r.up(i) = 1;
304! theta.up(i) = pi;
305!
306! r.fx('i%nv%') = 0;
307! theta.fx('i%nv%') = pi;
308!
309! r.l(i) = 4*ord(i)*(card(i)+ 1- ord(i))/sqr(card(i)+1);
310! theta.l(i) = pi*ord(i)/card(i);
311 DO i = 1, np-1
312 lower(i) = 0.d0
313 lower(i+np) = 0.d0
314 upper(i) = 1.d0
315 upper(i+np) = pi
316 curr(i) = 4.d0*i*(np+1-i)/(1+np)**2
317 curr(i+np) = pi*i/np
318 enddo
319 lower(np) = 0.d0
320 upper(np) = 0.d0
321 curr(np) = 0.d0
322 lower(2*np) = pi
323 upper(2*np) = pi
324 curr(2*np) = pi
325!
326! Information about Constraints:
327! Default: Rhs = 0
328! Default: the status information in Esta and the function
329! value in FV are not used.
330! Default: Type: There is no default.
331! 0 = Equality,
332! 1 = Greater than or equal,
333! 2 = Less than or equal,
334! 3 = Non binding.
335!
336! ordered(i+1).. theta(i) =l= theta(i+1);
337!
338! distance(i,j)$(ord(j) > ord(i))..
339! sqr(r(i)) + sqr(r(j)) - 2*r(i)*r(j)*cos(theta(j)-theta(i)) =l= 1;
340!
341! obj.. polygon_area =e= 0.5*sum(j(i+1), r(i+1)*r(i)*sin(theta(i+1)-theta(i)));
342!
343 k = 0
344 DO i = 1, no
345 k = k + 1
346 Type(k) = 2 ! Ordered constraint Less than and RHS = 0
347 Enddo
348 rowmapk = 0 ! Initialize so we can recognize (i,j) combinations that are not equations
349 DO i = 1, np-1
350 DO j = i+1, np
351 k = k + 1
352 Type(k) = 2 ! Dist(i,j) Less than
353 rhs(k) = 1.d0
354 rowmapi(k-no) = i ! To be used for easier lookup
355 rowmapj(k-no) = j
356 rowmapk(i,j) = k
357 Enddo
358 Enddo
359 k = k + 1
360 type(k) = 3 ! Objective of type Non binding
361!
362! Information about the Jacobian. We have to define Rowno, Value,
363! Nlflag and Colsta.
364!
365! Colsta = Start of column indices (No Defaults):
366! Rowno = Row indices
367! Value = Value of derivative (by default only linear
368! derivatives are used)
369! Nlflag = 0 for linear and 1 for nonlinear derivative
370! (not needed for completely linear models)
371!
372! Indices
373!
374! r(1) r(2) r(3) r(4) .. Th(1) th(2) th(3) th(4)
375! 1: 1 -1
376! 2: 1 -1
377! 3: 1 -1
378! ..
379! NP: NL NL NL NL
380! NP+1: NL NL NL NL
381! NP+2 NL NL NL NL
382! ..
383! NL NL NL NL
384! NL NL NL NL
385! ..
386! Obj: NL NL NL NL NL NL
387!
388! Nonlinearity Structure: L = 0 are linear and NL = 1 are nonlinear
389! All nonzeros are nonlinear
390!
391 k = 0
392 DO i = 1, np ! r variables
393 colsta(i) = k+1
394 DO j = i+1, np
395 k = k + 1
396 rowno(k) = rowmapk(i,j) ! Distance - i index
397 nlflag(k) = 1
398 enddo
399 DO j = 1,np
400 IF ( rowmapk(j,i) > 0 ) Then
401 k = k + 1
402 rowno(k) = rowmapk(j,i) ! Distance - j index
403 nlflag(k) = 1
404 endif
405 enddo
406 k = k + 1
407 rowno(k) = no+nd+1 ! Objective constraint
408 nlflag(k) = 1
409 enddo
410 DO i = 1, np ! theta variables
411 colsta(np+i) = k+1
412 if ( i < np ) then
413 k = k + 1
414 rowno(k) = i ! ordered constraint index i
415 nlflag(k) = 0
416 value(k) = 1.d0
417 endif
418 if ( i > 1 ) then
419 k = k + 1
420 rowno(k) = i-1 ! ordered constraint index i+1
421 nlflag(k) = 0
422 value(k) = -1.d0
423 endif
424 DO j = i+1, np
425 k = k + 1
426 rowno(k) = rowmapk(i,j) ! Distance - i index
427 nlflag(k) = 1
428 enddo
429 DO j = 1,np
430 IF ( rowmapk(j,i) > 0 ) Then
431 k = k + 1
432 rowno(k) = rowmapk(j,i) ! Distance - j index
433 nlflag(k) = 1
434 endif
435 enddo
436 k = k + 1
437 rowno(k) = no+nd+1 ! Objective constraint
438 nlflag(k) = 1
439 enddo
440 colsta(nv+1) = k+1
442 poly_readmatrix = 0 ! Return value means OK
443
444end Function poly_readmatrix
445!
446!==========================================================================
447! Compute nonlinear terms and non-constant Jacobian elements
448!
449
450!> Compute nonlinear terms and non-constant Jacobian elements
451!!
452!! @include{doc} fdeval_params.dox
453Integer Function poly_fdeval( x, g, jac, rowno, jcnm, mode, ignerr, errcnt, &
454 n, nz, thread, usrmem )
455#ifdef dec_directives_win32
456!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: Poly_FDEval
457#endif
458 Use pdata2
459 implicit none
460 integer, intent (in) :: n ! number of variables
461 integer, intent (in) :: rowno ! number of the row to be evaluated
462 integer, intent (in) :: nz ! number of nonzeros in this row
463 real*8, intent (in), dimension(n) :: x ! vector of current solution values
464 real*8, intent (in out) :: g ! constraint value
465 real*8, intent (in out), dimension(n) :: jac ! vector of derivatives for current constraint
466 integer, intent (in), dimension(nz) :: jcnm ! list of variables that appear nonlinearly
467 ! in this row. Ffor information only.
468 integer, intent (in) :: mode ! evaluation mode: 1 = function value
469 ! 2 = derivatives, 3 = both
470 integer, intent (in) :: ignerr ! if 1 then errors can be ignored as long
471 ! as errcnt is incremented
472 integer, intent (in out) :: errcnt ! error counter to be incremented in case
473 ! of function evaluation errors.
474 integer, intent (in) :: thread
475 real*8 usrmem(*) ! optional user memory
476
477 Integer :: ne
478 Integer :: i, j
479 real*8 :: s, c
480
481 ne = n / 3
482!
483! Row NO+ND+1: the objective function is nonlinear
484!
485 if ( rowno == no+nd+1 ) then
486!
487! Mode = 1 or 3. Function value:
488! obj.. polygon_area =e= 0.5*sum(j(i+1), r(i+1)*r(i)*sin(theta(i+1)-theta(i)));
489!
490 if ( mode .eq. 1 .or. mode .eq. 3 ) then
491 g = 0.d0
492 do i = 1, np-1
493 g = g + x(i+1)*x(i)*sin(x(np+i+1)-x(np+i))
494 enddo
495 g = g * 0.5d0
496 endif
497!
498! Mode = 2 or 3: Derivative values: w.r.t. x: 2*(x(i)-x(j))*(-1/2)*dist(-3/2)
499!
500 if ( mode .eq. 2 .or. mode .eq. 3 ) then
501 do i = 1, nv
502 jac(i) = 0.d0
503 enddo
504 do i = 1, np-1
505! g = g + 0.5* x(i+1)*x(i)*Sin(x(NP+i+1)-x(NP+i))
506 s = 0.5d0*sin(x(np+i+1)-x(np+i))
507 jac(i+1) = jac(i+1) + x(i)*s
508 jac(i) = jac(i) + x(i+1)*s
509 c = 0.5d0*x(i+1)*x(i)*cos(x(np+i+1)-x(np+i))
510 jac(np+i+1) = jac(np+i+1) + c
511 jac(np+i) = jac(np+i) - c
512 enddo
513 endif
514!
515 Else if ( rowno > no ) then ! this is a distance constraint
516!
517! Mode = 1 or 3. Function value:
518! sqr(r(i)) + sqr(r(j)) - 2*r(i)*r(j)*cos(theta(j)-theta(i)) =l= 1;
519!
520 i = rowmapi(rowno-no)
521 j = rowmapj(rowno-no)
522 if ( mode .eq. 1 .or. mode .eq. 3 ) then
523 g = x(i)**2 + x(j)**2 -2.d0*x(i)*x(j)*cos(x(j+np)-x(i+np))
524 endif
525!
526! Mode = 2 or 3: Derivative values:
527!
528 if ( mode .eq. 2 .or. mode .eq. 3 ) then
529 c = cos(x(j+np)-x(i+np))
530 jac(i) = 2.d0*(x(i)-x(j)*c)
531 jac(j) = 2.d0*(x(j)-x(i)*c)
532 s = 2.d0*sin(x(j+np)-x(i+np))*x(i)*x(j)
533 jac(i+np) = -s
534 jac(j+np) = s
535 endif
536 Else
537 write(*,*) 'Fdeval called with rowno=',rowno
538 poly_fdeval = 1; return ! error in row number
539 endif
540 poly_fdeval = 0
541
542end Function poly_fdeval
543
544Integer Function poly_solution( XVAL, XMAR, XBAS, XSTA, YVAL, YMAR, YBAS, YSTA, N, M, USRMEM )
545#ifdef dec_directives_win32
546!DEC$ ATTRIBUTES STDCALL, REFERENCE, NOMIXED_STR_LEN_ARG :: Poly_Solution
547#endif
548!
549! Simple implementation in which we write the solution values to
550! the 'Documentation file' on unit 10.
551!
552 Use proginfop
553 Use pdata2
554 IMPLICIT NONE
555 INTEGER, Intent(IN) :: n, m
556 INTEGER, Intent(IN), Dimension(N) :: xbas, xsta
557 INTEGER, Intent(IN), Dimension(M) :: ybas, ysta
558 real*8, Intent(IN), Dimension(N) :: xval, xmar
559 real*8, Intent(IN), Dimension(M) :: yval, ymar
560 real*8, Intent(IN OUT) :: usrmem(*)
561
562 INTEGER i
563 CHARACTER*5, Parameter, Dimension(4) :: stat = (/ 'Lower','Upper','Basic','Super' /)
564
565 WRITE(10,"(/' Variable Solution value Reduced cost B-stat')")
566 DO i = 1, n
567 WRITE(10,"(1P,I7,E20.6,E16.6,4X,A5 )") i, xval(i), xmar(i), stat(1+xbas(i))
568 ENDDO
569
570 WRITE(10,"(/' Constrnt Activity level Marginal cost B-stat')")
571 DO i = 1, m
572 WRITE(10,"(1P,I7,E20.6,E16.6,4X,A5 )") i, yval(i), ymar(i), stat(1+ybas(i))
573 ENDDO
574 xprim(1:n) = xval(1:n)
575 Call flush(10)
576
577 solcalls = solcalls + 1
578 poly_solution = 0
579
580END Function poly_solution
integer function std_status(modsta, solsta, iter, objval, usrmem)
Definition comdecl.f90:88
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_optfile(cntvect, optfile)
define callback routine for defining an options file.
Definition conopt.f90:928
integer(c_int) function coidef_license(cntvect, licint1, licint2, licint3, licstring)
define the License Information.
Definition conopt.f90:293
integer(c_int) function coidef_threadc(cntvect, threadc)
check for thread compatibility.
Definition conopt.f90:727
integer(c_int) function coidef_threads(cntvect, threads)
number of threads allowed internally in CONOPT.
Definition conopt.f90:627
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_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 poly_solution(xval, xmar, xbas, xsta, yval, ymar, ybas, ysta, n, m, usrmem)
program polygon
Main program. A simple setup and call of CONOPT.
integer, dimension(np, np) rowmapk
integer, parameter nd
integer, dimension(nd) rowmapi
real *8, dimension(nv) xprim
integer, dimension(nd) rowmapj
real *8, dimension(nv) xprim2
real *8, dimension(nv) xprim1
integer, parameter nv
integer, parameter no
real *8, dimension(nv) xprim4
integer, parameter np
subroutine flog(msg, code)
Definition comdeclp.f90:48
integer miter
Definition comdeclp.f90:22
subroutine startup
Definition comdeclp.f90:31
integer function poly_readmatrix(lower, curr, upper, vsta, type, rhs, esta, colsta, rowno, value, nlflag, n, m, nz, usrmem)
Define information about the model.
Definition polygon.f90:158
integer recursive function poly_fdeval(x, g, jac, rowno, jcnm, mode, ignerr, errcnt, n, nz, thread, usrmem)
Compute nonlinear terms and non-constant Jacobian elements.
Definition polygon.f90:338