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 )
41 int it, is, i, icol, iz, iold;
57 for ( it=1; it<=
T; it++ ) {
68 CURR[is+3] = CURR[is] - CURR[is+2];
70 CURR[is+4] = CURR[is+4-
Vpp] - CURR[is+3];
72 CURR[is+4] = 500 - CURR[is+3];
82 for ( i = 0; i < iold; 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]);
91 for ( i = 0; i < iold; i++ )
93 for ( i = 0; i <
Vpp; i++ )
96 for ( i = 0; i < iold; i++ )
98 for ( i = 0; i <
Epp; i++ )
114 for ( i = 1; i < NUMCON; i++ )
122 for ( it = 1; it<=
T; it++ ) {
124 RHS[is] = 1.0+2.3*pow(1.015,(it-1.));
129 RHS[1] = RHS[1]+ 0.87*18.;
172 for ( it = 1; it <=
T; it++ )
208 ROWNO[iz] = is+2+
Epp;
230 ROWNO[iz] = is+1+
Epp;
262 ROWNO[iz] = is+4+
Epp;
286 VALUE[iz] = pow(1.05,(1.0-it));
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 )
318 if ( 1+(it-1)*
Epp+1 == ROWNO ) {
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 )
326 if ( 2 == MODE || 3 == MODE ) {
327 JAC[is+1] = h1*h2*log(1.02)/7.0;
331 else if ( 1+(it-1)*
Epp+5 == ROWNO ) {
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];
347 printf(
"\nError. Pin_FDEval called with ROWNO = %d. MODE = %d\n\n", ROWNO, MODE);
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 )
363 double h1, h2, h11, h15, h34, h35, h44;
368 if ( 1+(it-1)*
Epp+1 == ROWNO )
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];
387 else if ( 1+(it-1)*
Epp+5 == ROWNO )
400 h34 = -250.0/pow(r,2);
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];
412 printf(
"\nError. Pin_2DDir called with ROWNO = %d.\n\n", ROWNO);
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 )
424 char *status[4] = {
"Lower",
"Upper",
"Basic",
"Super"};
426 printf(
"Saving primal solution and status information for T = %d\n",
T);
427 for ( i = 0; i < NUMVAR; i++ ) {
431 for ( i = 0; i < NUMCON; i++ )
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]] );
451 int NUMVAR,
int NUMCON,
int NHESS,
void* USRMEM )
492 for ( it = 1; it <=
T; it++ ) {
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;
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 )
520 for ( it = 1; it <=
T; it++ ) {
529 h2 = pow(1.02,-cs/7.0);
530 HSVL[is ] = -h1*h2*pow(log(1.02)/7.0,2) * U[ie+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];
533 HSVL[is+3] = -1.0 * U[ie+5];
534 HSVL[is+4] = 500.0*d/pow(r,3) * U[ie+5];
600#if defined(LICENSE_INT_1) && defined(LICENSE_INT_2) && defined(LICENSE_INT_3) && defined(LICENSE_TEXT)
605 printf(
"Skipping COI_Solve due to setup errors. COI_Error = %d\n",
COI_Error);
609 printf(
"After solving. COI_Error =%d\n",
COI_Error);
614 c_log(
"Incorrect Model or Solver Status during first solve", -1);
634 printf(
"\n**** Fatal Error while revising CONOPT Sizes.\n");
635 c_log(
"Errors encountered while revising model sizes",
COI_Error);
639 printf(
"\n**** Fatal Error while Solving for T=%d\n",
T);
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);
647 printf(
"\nEnd of Pinadd2ddir Model. Return code=%d\n",
COI_Error);
648 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_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.
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.
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.
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 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)