24int COI_CALLCONV
Pin_ReadMatrix(
double LOWER[],
double CURR[],
double UPPER[],
int VSTA[],
int TYPE[],
25 double RHS[],
int ESTA[],
int COLSTA[],
int ROWNO[],
double VALUE[],
26 int NLFLAG[],
int NUMVAR,
int NUMCON,
int NUMNZ,
void* USRMEM )
28 int it, is, i, icol, iz;
44 for ( it=1; it<=
T; it++ ) {
55 CURR[is+3] = CURR[is] - CURR[is+2];
57 CURR[is+4] = CURR[is+4-
Vpp] - CURR[is+3];
59 CURR[is+4] = 500 - CURR[is+3];
75 for ( i = 1; i < NUMCON; i++ )
83 for ( it = 1; it<=
T; it++ ) {
85 RHS[is] = 1.0+2.3*pow(1.015,(it-1.));
90 RHS[1] = RHS[1]+ 0.87*18.;
133 for ( it = 1; it <=
T; it++ )
169 ROWNO[iz] = is+2+
Epp;
191 ROWNO[iz] = is+1+
Epp;
223 ROWNO[iz] = is+4+
Epp;
247 VALUE[iz] = pow(1.05,(1.0-it));
268int COI_CALLCONV
Pin_FDEval(
const double X[],
double* G,
double JAC[],
int ROWNO,
const int JACNUM[],
int MODE,
269 int IGNERR,
int* ERRCNT,
int NUMVAR,
int NUMNZ,
int THREAD,
void* USRMEM )
279 if ( 1+(it-1)*
Epp+1 == ROWNO ) {
283 h1 = (1.1+0.1*X[is+5]);
284 h2 = pow(1.02,-X[is+1]/7.0);
285 if ( 1 == MODE || 3 == MODE )
287 if ( 2 == MODE || 3 == MODE ) {
288 JAC[is+1] = h1*h2*log(1.02)/7.0;
292 else if ( 1+(it-1)*
Epp+5 == ROWNO ) {
296 if ( 1 == MODE || 3 == MODE )
297 *G = -X[is+3]*(X[is+5]-250./X[is+4]);
298 if ( 2 == MODE || 3 == MODE ) {
299 JAC[is+3] = -(X[is+5]-250./X[is+4]);
300 JAC[is+4] = -X[is+3]*250./pow(X[is+4],2);
301 JAC[is+5] = -X[is+3];
308 printf(
"\nError. Pin_FDEval called with ROWNO = %d. MODE = %d\n\n", ROWNO, MODE);
320 int major, minor, patch;
327 printf(
"\nSolving Pindyck Model using CONOPT version %d.%d.%d:\n", major, minor, patch );
368#if defined(LICENSE_INT_1) && defined(LICENSE_INT_2) && defined(LICENSE_INT_3) && defined(LICENSE_TEXT)
373 printf(
"Skipping COI_Solve due to setup errors. COI_Error = %d\n",
COI_Error);
377 printf(
"After solving. COI_Error =%d\n",
COI_Error);
381 c_log(
"Status or Solution routine was not called", -1); }
383 c_log(
"Incorrect Model or Solver Status", -1); }
384 else if ( fabs(
OBJ-1170.486 ) > 0.001 ) {
385 c_log(
"Incorrect objective returned", -1); }
387 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_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_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_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 main(int argc, char **argv)
Main program. A simple setup and call of CONOPT.
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 NUMNZ, int THREAD, void *USRMEM)
Compute nonlinear terms and non-constant Jacobian elements.
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)
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)