CONOPT
Loading...
Searching...
No Matches
pinadd2ddir.c
Go to the documentation of this file.
1
14
15#include <stdlib.h>
16#include <stdio.h>
17#include <math.h>
18#include <string.h>
19#include "coiheader.h"
20
21#include "comdecl.h"
22int T = 16; /* Number of time periods */
23#define Tmin 16
24#define Tmax 20
25#define Vpp 7 /* Variables per period */
26#define Epp 6 /* Equations per period */
27#define Hpp 5 /* Hessian elements per period -- se below */
28double Xkeep[Tmax*Vpp]; /* Space for storing solutions */
29int Xstat[Tmax*Vpp]; /* Space for storing status info */
30int Estat[Tmax*Epp]; /* Space for storing status info */
31
32
37int COI_CALLCONV Pin_ReadMatrix( double LOWER[], double CURR[], double UPPER[], int VSTA[], int TYPE[],
38 double RHS[], int ESTA[], int COLSTA[], int ROWNO[], double VALUE[],
39 int NLFLAG[], int NUMVAR, int NUMCON, int NUMNZ, void* USRMEM )
40{
41 int it, is, i, icol, iz, iold;
42/*
43 Define the information for the columns.
44
45 We should not supply status information, VSTA.
46
47 We order the variables as follows:
48 0: td, 1: cs, 2: s, 3: d, 4: r, 5: p, and 6: rev. All variables for
49 period 1 appears first followed by all variables for period 2 etc.
50
51 td, cs, s, and d have lower bounds of 0, r and p have lower
52 bounds of 1, and rev has no lower bound.
53 All have infinite upper bounds (default).
54 The initial value of td is 18, s is 7, cs is 7*t, d is td-s,
55 p is 14, and r is r(t-1)-d. No initial value for rev. */
56
57 for ( it=1; it<=T; it++ ) {
58 is = Vpp*(it-1);
59 LOWER[is ] = 0;
60 LOWER[is+1] = 0;
61 LOWER[is+2] = 0;
62 LOWER[is+3] = 0;
63 LOWER[is+4] = 1;
64 LOWER[is+5] = 1;
65 CURR[is ] = 18;
66 CURR[is+1] = 7*it;
67 CURR[is+2] = 7;
68 CURR[is+3] = CURR[is] - CURR[is+2];
69 if ( it > 1 )
70 CURR[is+4] = CURR[is+4-Vpp] - CURR[is+3];
71 else
72 CURR[is+4] = 500 - CURR[is+3];
73 CURR[is+5] = 14;
74 }
75 if ( T > Tmin ) {
76
77/* This is a restart: Use the initial values from last solve for
78 the variables in the first periods and extrapolate the last
79 period using a linear extrapolation between the last two */
80
81 iold = Vpp*(T-1);
82 for ( i = 0; i < iold; i++ )
83 CURR[i] = Xkeep[i];
84 for ( i = 0; i < Vpp; i++ )
85 CURR[iold+i] = CURR[iold+i-Vpp] + (CURR[iold+i-Vpp]-CURR[iold+i-2*Vpp]);
86
87/* The variables from the last solve are given the old status and
88 the variables in the new period are given those in the last
89 pariod. Similarly with the Equation status: */
90
91 for ( i = 0; i < iold; i++ )
92 VSTA[i] = Xstat[i];
93 for ( i = 0; i < Vpp; i++ )
94 VSTA[iold+i] = Xstat[iold+i-Vpp];
95 iold = Epp*(T-1)+1;
96 for ( i = 0; i < iold; i++ )
97 ESTA[i] = Estat[i];
98 for ( i = 0; i < Epp; i++ )
99 ESTA[iold+i] = Estat[iold+i-Epp];
100 }
101/*
102 Define the information for the rows
103
104 We order the constraints as follows: The objective is first,
105 followed by tddef, sdef, csdef, ddef, rdef, and revdef for
106 the first period, the same for the second period, etc.
107
108 The objective is a nonbinding constraint: */
109
110 TYPE[0] = 3;
111
112/* All others are equalities: */
113
114 for ( i = 1; i < NUMCON; i++ )
115 TYPE[i] = 0;
116/*
117 Right hand sides: In all periods except the first, only tddef
118 has a nonzero right hand side of 1+2.3*1.015**(t-1).
119 In the initial period there are contributions from lagged
120 variables in the constraints that have lagged variables. */
121
122 for ( it = 1; it<=T; it++ ) {
123 is = 1 + 6*(it-1);
124 RHS[is] = 1.0+2.3*pow(1.015,(it-1.));
125 }
126
127/* tddef: + 0.87*td(0) */
128
129 RHS[1] = RHS[1]+ 0.87*18.;
130
131/* sdef: +0.75*s(0) */
132
133 RHS[2] = 0.75*6.5;
134
135/* csdef: +1*cs(0) */
136
137 RHS[3] = 0;
138
139/* rdef: +1*r(0) */
140
141 RHS[5] = 500;
142
143/*
144 Define the structure and content of the Jacobian:
145 To help define the Jacobian pattern and values it can be useful to
146 make a picture of the Jacobian. We describe the variables for one
147 period and the constraints they are part of:
148
149 td cs s d r p rev
150 0 1 2 3 4 5 6
151 0: Obj (1+r)**(1-t)
152 Period t:
153 0: tddef 1.0 0.13
154 1: sdef NL 1.0 NL
155 2: csdef 1.0 -1.0
156 3: ddef -1.0 1.0 1.0
157 4: rdef 1.0 1.0
158 5: revdef NL NL NL 1.0
159 Period t+1:
160 0: tddef -0.87
161 1: sdef -0.75
162 2: csdef -1.0
163 3: ddef
164 4: rdef -1.0
165 5: revdef
166
167 The Jacobian has to be sorted column-wise so we will just define
168 the elements column by column according to the table above: */
169
170 iz = 0; /* Running index for Jacobian in C convention 0 to nz-1 */
171 icol = 0; /* Running column index in C convention 0 to N-1 */
172 for ( it = 1; it <= T; it++ )
173 {
174
175/* is points to the position before the first equation for the period */
176
177 is = 1 + 6*(it-1); /* 1 correspond to the objective in row 0 */
178
179/* Column td: */
180 COLSTA[icol] = iz;
181 icol = icol + 1;
182 ROWNO[iz] = is;
183 VALUE[iz] = +1.0;
184 NLFLAG[iz] = 0;
185 iz = iz + 1;
186 ROWNO[iz] = is+3;
187 VALUE[iz] = -1.0;
188 NLFLAG[iz] = 0;
189 iz = iz + 1;
190 if ( it < T ) {
191 ROWNO[iz] = is+Epp;
192 VALUE[iz] = -0.87;
193 NLFLAG[iz] = 0;
194 iz = iz + 1;
195 }
196
197/* Column cs */
198 COLSTA[icol] = iz;
199 icol = icol + 1;
200 ROWNO[iz] = is+1;
201 NLFLAG[iz] = 1;
202 iz = iz + 1;
203 ROWNO[iz] = is+2;
204 VALUE[iz] = +1.0;
205 NLFLAG[iz] = 0;
206 iz = iz + 1;
207 if ( it < T ) {
208 ROWNO[iz] = is+2+Epp;
209 VALUE[iz] = -1.0;
210 NLFLAG[iz] = 0;
211 iz = iz + 1;
212 }
213
214/* Column s */
215 COLSTA[icol] = iz;
216 icol = icol + 1;
217 ROWNO[iz] = is+1;
218 VALUE[iz] = +1.0;
219 NLFLAG[iz] = 0;
220 iz = iz + 1;
221 ROWNO[iz] = is+2;
222 VALUE[iz] = -1.0;
223 NLFLAG[iz] = 0;
224 iz = iz + 1;
225 ROWNO[iz] = is+3;
226 VALUE[iz] = +1.0;
227 NLFLAG[iz] = 0;
228 iz = iz + 1;
229 if ( it < T ) {
230 ROWNO[iz] = is+1+Epp;
231 VALUE[iz] = -0.75;
232 NLFLAG[iz] = 0;
233 iz = iz + 1;
234 }
235
236/* Column d: */
237 COLSTA[icol] = iz;
238 icol = icol + 1;
239 ROWNO[iz] = is+3;
240 VALUE[iz] = +1.0;
241 NLFLAG[iz] = 0;
242 iz = iz + 1;
243 ROWNO[iz] = is+4;
244 VALUE[iz] = +1.0;
245 NLFLAG[iz] = 0;
246 iz = iz + 1;
247 ROWNO[iz] = is+5;
248 NLFLAG[iz] = 1;
249 iz = iz + 1;
250
251/* Column r: */
252 COLSTA[icol] = iz;
253 icol = icol + 1;
254 ROWNO[iz] = is+4;
255 VALUE[iz] = +1.0;
256 NLFLAG[iz] = 0;
257 iz = iz + 1;
258 ROWNO[iz] = is+5;
259 NLFLAG[iz] = 1;
260 iz = iz + 1;
261 if ( it < T ) {
262 ROWNO[iz] = is+4+Epp;
263 VALUE[iz] = -1.0;
264 NLFLAG[iz] = 0;
265 iz = iz + 1;
266 }
267
268/* Column p: */
269 COLSTA[icol] = iz;
270 icol = icol + 1;
271 ROWNO[iz] = is;
272 VALUE[iz] = +0.13;
273 NLFLAG[iz] = 0;
274 iz = iz + 1;
275 ROWNO[iz] = is+1;
276 NLFLAG[iz] = 1;
277 iz = iz + 1;
278 ROWNO[iz] = is+5;
279 NLFLAG[iz] = 1;
280 iz = iz + 1;
281
282/* Column rev: */
283 COLSTA[icol] = iz;
284 icol = icol + 1;
285 ROWNO[iz] = +0; /* Objective -- no is term */
286 VALUE[iz] = pow(1.05,(1.0-it));
287 NLFLAG[iz] = 0;
288 iz = iz + 1;
289 ROWNO[iz] = is+5;
290 VALUE[iz] = 1.0;
291 NLFLAG[iz] = 0;
292 iz = iz + 1;
293 }
294 COLSTA[icol] = iz; /* First elements past last column */
295
296 return 0;
297}
298/*
299 =====================================================================
300 Compute nonlinear terms and non-constant Jacobian elements */
301
302
307int COI_CALLCONV Pin_FDEval( const double X[], double* G, double JAC[], int ROWNO, const int JACNUM[], int MODE,
308 int IGNERR, int* ERRCNT, int NUMVAR, int NUMJAC, int THREAD, void* USRMEM )
309{
310
311 int it, is;
312 double h1, h2;
313
314/* Compute the number of the period, it */
315
316 it = (ROWNO+Epp-1) / Epp;
317 is = Vpp*(it-1);
318 if ( 1+(it-1)*Epp+1 == ROWNO ) {
319
320/* sdef equation. Nonlinear term = -(1.1+0.1*p)*1.02**(-cs/7) */
321
322 h1 = (1.1+0.1*X[is+5]);
323 h2 = pow(1.02,-X[is+1]/7.0);
324 if ( 1 == MODE || 3 == MODE )
325 *G = -h1*h2;
326 if ( 2 == MODE || 3 == MODE ) {
327 JAC[is+1] = h1*h2*log(1.02)/7.0;
328 JAC[is+5] = -h2*0.1;
329 }
330 }
331 else if ( 1+(it-1)*Epp+5 == ROWNO ) {
332
333/* revdef equation. Nonlinear term = -d*(p-250/r) */
334
335 if ( 1 == MODE || 3 == MODE )
336 *G = -X[is+3]*(X[is+5]-250./X[is+4]);
337 if ( 2 == MODE || 3 == MODE ) {
338 JAC[is+3] = -(X[is+5]-250./X[is+4]);
339 JAC[is+4] = -X[is+3]*250./pow(X[is+4],2);
340 JAC[is+5] = -X[is+3];
341 }
342 }
343 else {
344
345/* Error - this equation is not nonlinear */
346
347 printf("\nError. Pin_FDEval called with ROWNO = %d. MODE = %d\n\n", ROWNO, MODE);
348 return 1;
349 };
350 return 0;
351}
352
353
358int COI_CALLCONV Pin_2DDir( const double X[], const double DX[], double D2G[], int ROWNO, const int JACNUM[],
359 int* NODRV, int NUMVAR, int NUMJAC, int THREAD, void* USRMEM )
360{
361 int it, ic;
362 double cs, p, d, r;
363 double h1, h2, h11, h15, h34, h35, h44;
364
365/* Compute the number of the period, it */
366
367 it = (ROWNO+Epp-1) / Epp;
368 if ( 1+(it-1)*Epp+1 == ROWNO )
369 {
370/* sdef equation. Nonlinear term = -(1.1+0.1*p)*1.02**(-cs/7) */
371/* Hessian (diagonal and lower triangle): A total of 2 nonzero elements per period
372 1 5
373 cs p
374 1 : cs -(1.1+0.1p)*1.02**(-cs/7)*(log(1.02)/7)**2
375 5 : p 0.1*1.02**(-cs/7)*(log(1.02)72) */
376
377 ic = Vpp*(it-1);
378 cs = X[ic+1];
379 p = X[ic+5];
380 h1 = 1.1+0.1*p;
381 h2 = pow(1.02,-cs/7.0);
382 h11 = -h1*h2*pow(log(1.02)/7.0,2);
383 h15 = 0.1*h2*(log(1.02)/7.);
384 D2G[ic+1] = h11*DX[ic+1] + h15*DX[ic+5];
385 D2G[ic+5] = h15*DX[ic+1];
386 }
387 else if ( 1+(it-1)*Epp+5 == ROWNO )
388 {
389/* revdef equation. Nonlinear term = -d*(p-250/r) */
390/* Hessian (diagonal and lower triangle): A total of 3 nonzero elements per period
391 3 4 5
392 d r p
393 3 : d
394 4 : r -250/r**2 500*d/r**3
395 5 : p -1 */
396 ic = Vpp*(it-1);
397 d = X[ic+3];
398 r = X[ic+4];
399 p = X[ic+5];
400 h34 = -250.0/pow(r,2);
401 h35 = -1.0;
402 h44 = 500.0*d/pow(r,3);
403 D2G[ic+3] = h34*DX[ic+4] + h35*DX[ic+5];
404 D2G[ic+4] = h34*DX[ic+3] + h44*DX[ic+4];
405 D2G[ic+5] = h35*DX[ic+3];
406 }
407 else
408 {
409
410/* Error - this equation is not nonlinear */
411
412 printf("\nError. Pin_2DDir called with ROWNO = %d.\n\n", ROWNO);
413 return 1;
414 };
415 return 0;
416}
417
418int COI_CALLCONV Pin_Solution( const double XVAL[], const double XMAR[], const int XBAS[], const int XSTA[],
419 const double YVAL[], const double YMAR[], const int YBAS[], const int YSTA[],
420 int NUMVAR, int NUMCON, void* USRMEM )
421{
422/* Specialized Solution routine */
423 int i;
424 char *status[4] = {"Lower","Upper","Basic","Super"};
425 if ( T < Tmax ) {
426 printf("Saving primal solution and status information for T = %d\n",T);
427 for ( i = 0; i < NUMVAR; i++ ) {
428 Xkeep[i] = XVAL[i];
429 Xstat[i] = XBAS[i];
430 }
431 for ( i = 0; i < NUMCON; i++ )
432 Estat[i] = YBAS[i];
433 return 0;
434 }
435 fprintf(fd,"\n Variable Solution value Reduced cost Status\n\n");
436 for ( i=0; i<NUMVAR; i++ )
437 fprintf(fd,"%6d%18f%18f%10s\n", i, XVAL[i], XMAR[i], status[XBAS[i]] );
438 fprintf(fd,"\n Constrnt Activity level Marginal cost Status\n\n");
439 for ( i=0; i<NUMCON; i++ )
440 fprintf(fd,"%6d%18f%18f%10s\n", i, YVAL[i], YMAR[i], status[YBAS[i]] );
441
442 return 0;
443}
444
445
450int COI_CALLCONV Pin_2DLagrStr( int HSRW[], int HSCL[], int* NODRV,
451 int NUMVAR, int NUMCON, int NHESS, void* USRMEM )
452{
453 int it, is, ic;
454/*
455 There are two nonlinear constraints, Sdef and RevDef and they have
456 the following Hessians (for each time period):
457
458 Revdef equation. Nonlinear term = -d*(p-250/r)
459 Hessian (diagonal and lower triangle): A total of 3 nonzero elements per period
460 3 4 5
461 d r p
462 3 : d
463 4 : r -250/r**2 500*d/r**3
464 5 : p -1
465
466 Sdef: Nonlinear term = -(1.1+0.1p)*1.02**(-cs/7)
467 Hessian (diagonal and lower triangle): A total of 2 nonzero elements per period
468 1 5
469 cs p
470 1 : cs -(1.1+0.1p)*1.02**(-cs/7)*(log(1.02)/7)**2
471 5 : p 0.1*1.02**(-cs/7)*(log(1.02)72)
472
473 The two Hessian matrices do not overlap so the total number of nonzeros is
474 5 per period. The structure using numerical indices for rows and columns and
475 running indices for the Hessian element is:
476
477 1 3 4 5
478 1 0
479 3
480 4 2 4
481 5 1 3
482
483 and the same with names of variables and contributing equations
484 cs d r p
485 cs sdef
486 d
487 r revdef revdef
488 p sdef revdef
489*/
490/* Define structure of Hessian */
491
492 for ( it = 1; it <= T; it++ ) {
493 is = Hpp*(it-1);
494 ic = Vpp*(it-1);
495 HSCL[is ] = ic+1; HSRW[is ] = ic+1;
496 HSCL[is+1] = ic+1; HSRW[is+1] = ic+5;
497 HSCL[is+2] = ic+3; HSRW[is+2] = ic+4;
498 HSCL[is+3] = ic+3; HSRW[is+3] = ic+5;
499 HSCL[is+4] = ic+4; HSRW[is+4] = ic+4;
500 };
501 return 0;
502}
503
504
509int COI_CALLCONV Pin_2DLagrVal( const double X[], const double U[], const int HSRW[], const int HSCL[],
510 double HSVL[], int* NODRV, int NUMVAR, int NUMCON, int NHESS, void* USRMEM )
511{
512 int it, is, ic, ie;
513 double cs, d, r, p;
514 double h1, h2;
515
516/* For comments see above */
517
518/* Normal Evaluation mode */
519
520 for ( it = 1; it <= T; it++ ) {
521 is = Hpp*(it-1);
522 ic = Vpp*(it-1);
523 ie = Epp*(it-1) + 1;
524 cs = X[ic+1];
525 d = X[ic+3];
526 r = X[ic+4];
527 p = X[ic+5];
528 h1 = 1.1+0.1*p;
529 h2 = pow(1.02,-cs/7.0);
530 HSVL[is ] = -h1*h2*pow(log(1.02)/7.0,2) * U[ie+1]; /* Sdef = equation 1 */
531 HSVL[is+1] = 0.1*h2*(log(1.02)/7.) * U[ie+1];
532 HSVL[is+2] = -250.0/pow(r,2) * U[ie+5]; /* Revdef = equation 5 */
533 HSVL[is+3] = -1.0 * U[ie+5];
534 HSVL[is+4] = 500.0*d/pow(r,3) * U[ie+5];
535 };
536 return 0;
537}
538
539#include "std.c"
540
543int main(int argc, char** argv)
544{
545 c_log( "Starting to execute", START );
546
547 T = Tmin;
548
549/* Tell CONOPT about the sizes in the model */
550/* Number of variables (excl. slacks): 7 per period */
551
553
554/* Number of equations: 1 objective + 6 per period */
555
556 COI_Error += COIDEF_NumCon ( CntVect, 1+6*T );
557
558/* Number of nonzeros in the Jacobian. See the counting in */
559/* ReadMatrix above. For each period there is 1 in the objective, 16 */
560/* for unlagged variables and 4 for lagged variables. */
561
562 COI_Error += COIDEF_NumNz ( CntVect, 17*T+4*(T-1) );
563
564/* Number of nonlinear nonzeros. 5 unlagged for each period. */
565
567
568/* Number of Hessian elements. 5 = Hpp for each period. */
569
571
572/* Objective: Maximize Constraint no 0 */
573
576
577/* Turn debugging of FDEval on or off */
578
580
581/* Turn debugging of 2nd derivatives in 2DLagr and/or 2DDir on or off */
582/* -1 means first call only */
583
585/* Register the options file */
586 COI_Error += COIDEF_Optfile ( CntVect, "pindyck.opt");
587 /*
588 Register the necessary callback routines with CONOPT
589 */
590 COI_Error += COIDEF_Message ( CntVect, &Std_Message ); /* Register the callback Message */
591 COI_Error += COIDEF_ErrMsg ( CntVect, &Std_ErrMsg ); /* Register the callback ErrMsg */
592 COI_Error += COIDEF_Status ( CntVect, &Std_Status ); /* Register the callback Status */
593 COI_Error += COIDEF_Solution ( CntVect, &Pin_Solution ); /* Register the callback Solution */
594 COI_Error += COIDEF_ReadMatrix( CntVect, &Pin_ReadMatrix); /* Register the callback ReadMatrix */
595 COI_Error += COIDEF_FDEval ( CntVect, &Pin_FDEval); /* Register the callback FDEval */
596/* COI_Error += COIDEF_2DLagrStr ( CntVect, &Pin_2DLagrStr);*//* Register the callback 2DLagrStr */
597/* COI_Error += COIDEF_2DLagrVal ( CntVect, &Pin_2DLagrVal);*//* Register the callback 2DLagrVal */
598 COI_Error += COIDEF_2DDir ( CntVect, &Pin_2DDir); /* Register the callback 2DDir */
599
600#if defined(LICENSE_INT_1) && defined(LICENSE_INT_2) && defined(LICENSE_INT_3) && defined(LICENSE_TEXT)
601 COI_Error += COIDEF_License ( CntVect, LICENSE_INT_1, LICENSE_INT_2, LICENSE_INT_3, LICENSE_TEXT);
602#endif
603
604 if ( COI_Error ) {
605 printf("Skipping COI_Solve due to setup errors. COI_Error = %d\n",COI_Error);
606 c_log( "Skipping Solve due to setup errors", COI_Error);
607 }
608 COI_Error = COI_Solve ( CntVect ); /* Optimize */
609 printf("After solving. COI_Error =%d\n",COI_Error);
610 if ( COI_Error ) {
611 c_log( "Errors encountered during first solve", COI_Error);
612 }
613 else if ( mstat != 2 || sstat != 1 ) {
614 c_log( "Incorrect Model or Solver Status during first solve", -1);
615 }
616
617/* Now increase the time horizon gradually up to 20.
618 All sizes that depend on T must be registered again. */
619
620 for ( T = Tmin+1; T <= Tmax; T++ ) {
622 COI_Error += COIDEF_NumCon ( CntVect, 1+6*T );
623 COI_Error += COIDEF_NumNz ( CntVect, 17*T+4*(T-1) );
626
627/* This time we have status information copied from a previous solve,
628 i.e. IniStat = 2 */
630
631/* Turn debugging of 2nd derivative off again */
633 if ( COI_Error ) {
634 printf("\n**** Fatal Error while revising CONOPT Sizes.\n");
635 c_log( "Errors encountered while revising model sizes", COI_Error);
636 }
638 if ( COI_Error ) {
639 printf("\n**** Fatal Error while Solving for T=%d\n",T);
640 c_log( "Errors encountered during later solve", COI_Error);
641 }
642 else if ( mstat != 2 || sstat != 1 ) {
643 printf("\n**** Incorrect Model or Solver Status after Solving for T=%d\n",T);
644 c_log( "Incorrect Model or Solver Status during later solve", -1);
645 }
646 }
647 printf("\nEnd of Pinadd2ddir Model. Return code=%d\n",COI_Error);
648 c_log( "Successful Solve", OK );
649}
C language header file for direct linking against the COI library generated by apiwrapper for GAMS Ve...
coiHandle_t CntVect
Definition comdecl.h:14
#define START
Definition comdecl.h:13
FILE * fd
Definition comdecl.h:3
int mstat
Definition comdecl.h:7
#define OK
Definition comdecl.h:12
int sstat
Definition comdecl.h:8
int COI_Error
Definition comdecl.h:15
int COI_CALLCONV COIDEF_ReadMatrix(coiHandle_t cntvect, COI_READMATRIX_t coi_readmatrix)
define callback routine for providing the matrix data to CONOPT.
int COI_CALLCONV COIDEF_Message(coiHandle_t cntvect, COI_MESSAGE_t coi_message)
define callback routine for handling messages returned during the solution process.
int COI_CALLCONV COIDEF_Solution(coiHandle_t cntvect, COI_SOLUTION_t coi_solution)
define callback routine for returning the final solution values.
int COI_CALLCONV COIDEF_Status(coiHandle_t cntvect, COI_STATUS_t coi_status)
define callback routine for returning the completion status.
int COI_CALLCONV COIDEF_ErrMsg(coiHandle_t cntvect, COI_ERRMSG_t coi_errmsg)
define callback routine for returning error messages for row, column or Jacobian elements.
int COI_CALLCONV COIDEF_FDEval(coiHandle_t cntvect, COI_FDEVAL_t coi_fdeval)
define callback routine for performing function and derivative evaluations.
int COI_CALLCONV COIDEF_2DDir(coiHandle_t cntvect, COI_2DDIR_t coi_2ddir)
define callback routine for computing the second derivative for a constraint in a direction.
int COI_CALLCONV COIDEF_Optfile(coiHandle_t cntvect, const char *optfile)
define callback routine for defining an options file.
int COI_CALLCONV COIDEF_DebugFV(coiHandle_t cntvect, int debugfv)
turn Debugging of FDEval on and off.
int COI_CALLCONV COIDEF_License(coiHandle_t cntvect, int licint1, int licint2, int licint3, const char *licstring)
define the License Information.
int COI_CALLCONV COIDEF_Debug2D(coiHandle_t cntvect, int debug2d)
turn debugging of 2nd derivatives on and off.
int COI_CALLCONV COIDEF_IniStat(coiHandle_t cntvect, int inistat)
handling of the initial status values.
int COI_CALLCONV COIDEF_NumHess(coiHandle_t cntvect, int numhess)
defines the Number of Hessian Nonzeros.
int COI_CALLCONV COIDEF_ObjCon(coiHandle_t cntvect, int objcon)
defines the Objective Constraint.
int COI_CALLCONV COIDEF_NumVar(coiHandle_t cntvect, int numvar)
defines the number of variables in the model.
int COI_CALLCONV COIDEF_NumNz(coiHandle_t cntvect, int numnz)
defines the number of nonzero elements in the Jacobian.
int COI_CALLCONV COIDEF_NumCon(coiHandle_t cntvect, int numcon)
defines the number of constraints in the model.
int COI_CALLCONV COIDEF_OptDir(coiHandle_t cntvect, int optdir)
defines the Optimization Direction.
int COI_CALLCONV COIDEF_NumNlNz(coiHandle_t cntvect, int numnlnz)
defines the Number of Nonlinear Nonzeros.
int COI_CALLCONV COI_Solve(coiHandle_t cntvect)
method for starting the solving process of CONOPT.
#define Hpp
Definition pinadd2.c:19
int COI_CALLCONV Pin_2DLagrVal(const double X[], const double U[], const int HSRW[], const int HSCL[], double HSVL[], int *NODRV, int NUMVAR, int NUMCON, int NHESS, void *USRMEM)
Compute the Lagrangian of the Hessian.
int COI_CALLCONV Pin_ReadMatrix(double LOWER[], double CURR[], double UPPER[], int VSTA[], int TYPE[], double RHS[], int ESTA[], int COLSTA[], int ROWNO[], double VALUE[], int NLFLAG[], int NUMVAR, int NUMCON, int NUMNZ, void *USRMEM)
Define information about the model.
Definition pinadd2ddir.c:37
int main(int argc, char **argv)
Main program. A simple setup and call of CONOPT.
int COI_CALLCONV Pin_2DDir(const double X[], const double DX[], double D2G[], int ROWNO, const int JACNUM[], int *NODRV, int NUMVAR, int NUMJAC, int THREAD, void *USRMEM)
Computes the second derivative of a constraint in a direction.
int COI_CALLCONV Pin_Solution(const double XVAL[], const double XMAR[], const int XBAS[], const int XSTA[], const double YVAL[], const double YMAR[], const int YBAS[], const int YSTA[], int NUMVAR, int NUMCON, void *USRMEM)
int COI_CALLCONV Pin_FDEval(const double X[], double *G, double JAC[], int ROWNO, const int JACNUM[], int MODE, int IGNERR, int *ERRCNT, int NUMVAR, int NUMJAC, int THREAD, void *USRMEM)
Compute nonlinear terms and non-constant Jacobian elements.
int COI_CALLCONV Pin_2DLagrStr(int HSRW[], int HSCL[], int *NODRV, int NUMVAR, int NUMCON, int NHESS, void *USRMEM)
Specify the structure of the Lagrangian of the Hessian.
int COI_CALLCONV Pin_ReadMatrix(double LOWER[], double CURR[], double UPPER[], int VSTA[], int TYPE[], double RHS[], int ESTA[], int COLSTA[], int ROWNO[], double VALUE[], int NLFLAG[], int NUMVAR, int NUMCON, int NUMNZ, void *USRMEM)
Define information about the model.
Definition pinadd.c:28
int Xstat[Tmax *Vpp]
Definition pinadd.c:20
int COI_CALLCONV Pin_Solution(const double XVAL[], const double XMAR[], const int XBAS[], const int XSTA[], const double YVAL[], const double YMAR[], const int YBAS[], const int YSTA[], int NUMVAR, int NUMCON, void *USRMEM)
Definition pinadd.c:344
double Xkeep[Tmax *Vpp]
Definition pinadd.c:19
int COI_CALLCONV Pin_FDEval(const double X[], double *G, double JAC[], int ROWNO, const int JACNUM[], int MODE, int IGNERR, int *ERRCNT, int NUMVAR, int NUMJAC, int THREAD, void *USRMEM)
Compute nonlinear terms and non-constant Jacobian elements.
Definition pinadd.c:298
int T
Definition pinadd.c:14
#define Tmin
Definition pinadd.c:15
int Estat[Tmax *Epp]
Definition pinadd.c:21
#define Epp
Definition pinadd.c:18
#define Tmax
Definition pinadd.c:16
#define Vpp
Definition pinadd.c:17
int COI_CALLCONV Std_Status(int MODSTA, int SOLSTA, int ITER, double OBJVAL, void *USRMEM)
Definition std.c:45
int COI_CALLCONV Std_Message(int SMSG, int DMSG, int NMSG, char *MSGV[], void *USRMEM)
Definition std.c:8
void c_log(char *msgt, int code)
Definition std.c:202
int COI_CALLCONV Std_ErrMsg(int ROWNO, int COLNO, int POSNO, const char *MSG, void *USRMEM)
Definition std.c:26