35int COI_CALLCONV
Pin_ReadMatrix(
double LOWER[],
double CURR[],
double UPPER[],
int VSTA[],
int TYPE[],
36 double RHS[],
int ESTA[],
int COLSTA[],
int ROWNO[],
double VALUE[],
37 int NLFLAG[],
int NUMVAR,
int NUMCON,
int NZ,
void* USRMEM )
39 int it, is, i, icol, iz;
55 for ( it=1; it<=
T; it++ ) {
66 CURR[is+3] = CURR[is] - CURR[is+2];
68 CURR[is+4] = CURR[is+4-
Vpp] - CURR[is+3];
70 CURR[is+4] = 500 - CURR[is+3];
73 LOWER[is+5] = CURR[is+5];
74 UPPER[is+5] = CURR[is+5];
93 for ( i = 1; i < NUMCON; i++ )
101 for ( it = 1; it<=
T; it++ ) {
103 RHS[is] = 1.0+2.3*pow(1.015,(it-1.));
108 RHS[1] = RHS[1]+ 0.87*18.;
151 for ( it = 1; it <=
T; it++ )
187 ROWNO[iz] = is+2+
Epp;
209 ROWNO[iz] = is+1+
Epp;
241 ROWNO[iz] = is+4+
Epp;
265 VALUE[iz] = pow(1.05,(1.0-it));
286int COI_CALLCONV
Pin_FDEval(
const double X[],
double* G,
double JAC[],
int ROWNO,
const int JACNUM[],
int MODE,
287 int IGNERR,
int* ERRCNT,
int NUMROW,
int NUMNZ,
int THREAD,
void* USRMEM )
297 if ( 1+(it-1)*
Epp+1 == ROWNO ) {
301 h1 = (1.1+0.1*X[is+5]);
302 h2 = pow(1.02,-X[is+1]/7.0);
303 if ( 1 == MODE || 3 == MODE )
305 if ( 2 == MODE || 3 == MODE ) {
306 JAC[is+1] = h1*h2*log(1.02)/7.0;
310 else if ( 1+(it-1)*
Epp+5 == ROWNO ) {
314 if ( 1 == MODE || 3 == MODE )
315 *G = -X[is+3]*(X[is+5]-250./X[is+4]);
316 if ( 2 == MODE || 3 == MODE ) {
317 JAC[is+3] = -(X[is+5]-250./X[is+4]);
318 JAC[is+4] = -X[is+3]*250./pow(X[is+4],2);
319 JAC[is+5] = -X[is+3];
326 printf(
"\nError. Pin_FDEval called with ROWNO = %d. MODE = %d\n\n", ROWNO, MODE);
332int COI_CALLCONV
Pin_TriOrd(
int MODE,
int TYPE,
int STATUS,
int ROWNO,
int COLNO,
333 int INF,
double VALUE,
double RESID,
void* USRMEM )
336 fprintf(
fd,
"\nThe recursive order of the equations is described below:\n\n");
337 else if ( -2 == MODE )
338 fprintf(
fd,
"\nThe recursive order of the critical equations is:\n\n");
340 if ( COLNO >= 0 && COLNO < 7 *
T ) {
342 fprintf(
fd,
"Equation %7d has been solved with respect to variable %7d\nValue = %15f and Residual= %15f\n",
343 ROWNO, COLNO, VALUE, RESID );
345 fprintf(
fd,
"Equation %7d has been solved with respect to variable %7d\nValue = +Infinity and Residual= %15f\n",
346 ROWNO, COLNO, RESID );
348 fprintf(
fd,
"Equation %7d has been solved with respect to variable %7d\nValue = -Infinity and Residual= %15f\n",
349 ROWNO, COLNO, RESID );
352 fprintf(
fd,
"Equation %7d has been solved with respect to the slack\nResidual= %15f\n",
364 int major, minor, patch;
371 printf(
"\nSolving Pindyck Model using CONOPT version %d.%d.%d:\n", major, minor, patch );
419#if defined(LICENSE_INT_1) && defined(LICENSE_INT_2) && defined(LICENSE_INT_3) && defined(LICENSE_TEXT)
424 printf(
"Skipping COI_Solve due to setup errors. COI_Error = %d\n",
COI_Error);
428 printf(
"After solving. COI_Error =%d\n",
COI_Error);
432 c_log(
"Status or Solution routine was not called", -1); }
434 c_log(
"The model or solver status was not (16,1) as expected", -1); }
436 c_log(
"Successful Solve",
OK );
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_TriOrd(coiHandle_t cntvect, COI_TRIORD_t coi_triord)
define callback routine for providing the triangular order information.
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_Square(coiHandle_t cntvect, int square)
square models.
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.
void COI_CALLCONV COIGET_Version(int *major, int *minor, int *patch)
returns the version number. It can be used to ensure that the modeler is linked to the correct versio...
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.
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_FDEval(const double X[], double *G, double JAC[], int ROWNO, const int JACNUM[], int MODE, int IGNERR, int *ERRCNT, int NUMROW, int NUMNZ, int THREAD, void *USRMEM)
Compute nonlinear terms and non-constant Jacobian elements.
int main(int argc, char **argv)
Main program. A simple setup and call of CONOPT.
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 NZ, void *USRMEM)
Define information about the model.
int COI_CALLCONV Pin_TriOrd(int MODE, int TYPE, int STATUS, int ROWNO, int COLNO, int INF, double VALUE, double RESID, void *USRMEM)
int COI_CALLCONV Std_Status(int MODSTA, int SOLSTA, int ITER, double OBJVAL, void *USRMEM)
int COI_CALLCONV Std_Message(int SMSG, int DMSG, int NMSG, char *MSGV[], void *USRMEM)
int COI_CALLCONV Std_TriOrd(int mode, int type, int status, int irow, int icol, int inf, double value, double resid, void *USRMEM)
void c_log(char *msgt, int code)
int COI_CALLCONV Std_ErrMsg(int ROWNO, int COLNO, int POSNO, const char *MSG, void *USRMEM)
int COI_CALLCONV Std_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)