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 )
33 int it, is, i, icol, iz, iold;
49 for ( it=1; it<=
T; it++ ) {
60 CURR[is+3] = CURR[is] - CURR[is+2];
62 CURR[is+4] = CURR[is+4-
Vpp] - CURR[is+3];
64 CURR[is+4] = 500 - CURR[is+3];
74 for ( i = 0; i < iold; 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]);
83 for ( i = 0; i < iold; i++ )
85 for ( i = 0; i <
Vpp; i++ )
88 for ( i = 0; i < iold; i++ )
90 for ( i = 0; i <
Epp; i++ )
106 for ( i = 1; i < NUMCON; i++ )
114 for ( it = 1; it<=
T; it++ ) {
116 RHS[is] = 1.0+2.3*pow(1.015,(it-1.));
121 RHS[1] = RHS[1]+ 0.87*18.;
164 for ( it = 1; it <=
T; it++ )
200 ROWNO[iz] = is+2+
Epp;
222 ROWNO[iz] = is+1+
Epp;
254 ROWNO[iz] = is+4+
Epp;
278 VALUE[iz] = pow(1.05,(1.0-it));
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 )
310 if ( 1+(it-1)*
Epp+1 == ROWNO ) {
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 )
318 if ( 2 == MODE || 3 == MODE ) {
319 JAC[is+1] = h1*h2*log(1.02)/7.0;
323 else if ( 1+(it-1)*
Epp+5 == ROWNO ) {
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];
339 printf(
"\nError. Pin_FDEval called with ROWNO = %d. MODE = %d\n\n", ROWNO, MODE);
345int COI_CALLCONV
Pin_Solution(
const double XVAL[],
const double XMAR[],
const int XBAS[],
const int XSTA[],
346 const double YVAL[],
const double YMAR[],
const int YBAS[],
const int YSTA[],
347 int NUMVAR,
int NUMCON,
void* USRMEM )
351 char *status[4] = {
"Lower",
"Upper",
"Basic",
"Super"};
353 printf(
"Saving primal solution and status information for T = %d\n",
T);
354 for ( i = 0; i < NUMVAR; i++ ) {
358 for ( i = 0; i < NUMCON; i++ )
362 fprintf(
fd,
"\n Variable Solution value Reduced cost Status\n\n");
363 for ( i=0; i<NUMVAR; i++ )
364 fprintf(
fd,
"%6d%18f%18f%10s\n", i, XVAL[i], XMAR[i], status[XBAS[i]] );
365 fprintf(
fd,
"\n Constrnt Activity level Marginal cost Status\n\n");
366 for ( i=0; i<NUMCON; i++ )
367 fprintf(
fd,
"%6d%18f%18f%10s\n", i, YVAL[i], YMAR[i], status[YBAS[i]] );
378 int NUMVAR,
int NUMCON,
int NHESS,
void* USRMEM )
419 for ( it = 1; it <=
T; it++ ) {
422 HSCL[is ] = ic+1; HSRW[is ] = ic+1;
423 HSCL[is+1] = ic+1; HSRW[is+1] = ic+5;
424 HSCL[is+2] = ic+3; HSRW[is+2] = ic+4;
425 HSCL[is+3] = ic+3; HSRW[is+3] = ic+5;
426 HSCL[is+4] = ic+4; HSRW[is+4] = ic+4;
436int COI_CALLCONV
Pin_2DLagrVal(
const double X[],
const double U[],
const int HSRW[],
const int HSCL[],
437 double HSVL[],
int* NODRV,
int NUMVAR,
int NUMCON,
int NHESS,
void* USRMEM )
447 for ( it = 1; it <=
T; it++ ) {
456 h2 = pow(1.02,-cs/7.0);
457 HSVL[is ] = -h1*h2*pow(log(1.02)/7.0,2) * U[ie+1];
458 HSVL[is+1] = 0.1*h2*(log(1.02)/7.) * U[ie+1];
459 HSVL[is+2] = -250.0/pow(r,2) * U[ie+5];
460 HSVL[is+3] = -1.0 * U[ie+5];
461 HSVL[is+4] = 500.0*d/pow(r,3) * U[ie+5];
524#if defined(LICENSE_INT_1) && defined(LICENSE_INT_2) && defined(LICENSE_INT_3) && defined(LICENSE_TEXT)
529 printf(
"Skipping COI_Solve due to setup errors. COI_Error = %d\n",
COI_Error);
533 printf(
"After solving. COI_Error =%d\n",
COI_Error);
538 c_log(
"Incorrect Model or Solver Status during first solve", -1);
558 printf(
"\n**** Fatal Error while revising CONOPT Sizes.\n");
559 c_log(
"Errors encountered while revising model sizes",
COI_Error);
563 printf(
"\n**** Fatal Error while Solving for T=%d\n",
T);
567 printf(
"\n**** Incorrect Model or Solver Status during later solve for T=%d\n",
T);
568 c_log(
"Incorrect Model or Solver Status during later solve", -1);
571 printf(
"\nEnd of Pinadd2 Model. Return code=%d\n",
COI_Error);
572 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_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.
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_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)