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