28int COI_CALLCONV
Pin_ReadMatrix(
double LOWER[],
double CURR[],
double UPPER[],
int VSTA[],
int TYPE[],
29 double RHS[],
int ESTA[],
int COLSTA[],
int ROWNO[],
double VALUE[],
30 int NLFLAG[],
int NUMVAR,
int NUMCON,
int NUMNZ,
void* USRMEM )
32 int it, is, i, icol, iz, iold;
48 for ( it=1; it<=
T; it++ ) {
59 CURR[is+3] = CURR[is] - CURR[is+2];
61 CURR[is+4] = CURR[is+4-
Vpp] - CURR[is+3];
63 CURR[is+4] = 500 - CURR[is+3];
73 for ( i = 0; i < iold; i++ )
75 for ( i = 0; i <
Vpp; i++ )
76 CURR[iold+i] = CURR[iold+i-
Vpp] + (CURR[iold+i-
Vpp]-CURR[iold+i-2*
Vpp]);
82 for ( i = 0; i < iold; i++ )
84 for ( i = 0; i <
Vpp; i++ )
87 for ( i = 0; i < iold; i++ )
89 for ( i = 0; i <
Epp; i++ )
105 for ( i = 1; i < NUMCON; i++ )
113 for ( it = 1; it<=
T; it++ ) {
115 RHS[is] = 1.0+2.3*pow(1.015,(it-1.));
120 RHS[1] = RHS[1]+ 0.87*18.;
163 for ( it = 1; it <=
T; it++ )
199 ROWNO[iz] = is+2+
Epp;
221 ROWNO[iz] = is+1+
Epp;
253 ROWNO[iz] = is+4+
Epp;
277 VALUE[iz] = pow(1.05,(1.0-it));
298int COI_CALLCONV
Pin_FDEval(
const double X[],
double* G,
double JAC[],
int ROWNO,
const int JACNUM[],
int MODE,
299 int IGNERR,
int* ERRCNT,
int NUMVAR,
int NUMJAC,
int THREAD,
void* USRMEM )
309 if ( 1+(it-1)*
Epp+1 == ROWNO ) {
313 h1 = (1.1+0.1*X[is+5]);
314 h2 = pow(1.02,-X[is+1]/7.0);
315 if ( 1 == MODE || 3 == MODE )
317 if ( 2 == MODE || 3 == MODE ) {
318 JAC[is+1] = h1*h2*log(1.02)/7.0;
322 else if ( 1+(it-1)*
Epp+5 == ROWNO ) {
326 if ( 1 == MODE || 3 == MODE )
327 *G = -X[is+3]*(X[is+5]-250./X[is+4]);
328 if ( 2 == MODE || 3 == MODE ) {
329 JAC[is+3] = -(X[is+5]-250./X[is+4]);
330 JAC[is+4] = -X[is+3]*250./pow(X[is+4],2);
331 JAC[is+5] = -X[is+3];
338 printf(
"\nError. Pin_FDEval called with ROWNO = %d. MODE = %d\n\n", ROWNO, MODE);
344int COI_CALLCONV
Pin_Solution(
const double XVAL[],
const double XMAR[],
const int XBAS[],
const int XSTA[],
345 const double YVAL[],
const double YMAR[],
const int YBAS[],
const int YSTA[],
346 int NUMVAR,
int NUMCON,
void* USRMEM )
350 char *status[4] = {
"Lower",
"Upper",
"Basic",
"Super"};
352 printf(
"Saving primal solution and status information for T = %d\n",
T);
353 for ( i = 0; i < NUMVAR; i++ ) {
357 for ( i = 0; i < NUMCON; i++ )
361 fprintf(
fd,
"\n Variable Solution value Reduced cost Status\n\n");
362 for ( i=0; i<NUMVAR; i++ )
363 fprintf(
fd,
"%6d%18f%18f%10s\n", i, XVAL[i], XMAR[i], status[XBAS[i]] );
364 fprintf(
fd,
"\n Constrnt Activity level Marginal cost Status\n\n");
365 for ( i=0; i<NUMCON; i++ )
366 fprintf(
fd,
"%6d%18f%18f%10s\n", i, YVAL[i], YMAR[i], status[YBAS[i]] );
422#if defined(LICENSE_INT_1) && defined(LICENSE_INT_2) && defined(LICENSE_INT_3) && defined(LICENSE_TEXT)
427 printf(
"Skipping COI_Solve due to setup errors. COI_Error = %d\n",
COI_Error);
431 printf(
"After solving. COI_Error =%d\n",
COI_Error);
436 c_log(
"Incorrect Model or Solver Status during first solve", -1);
453 printf(
"\n**** Fatal Error while revising CONOPT Sizes.\n");
454 c_log(
"Errors encountered while revising model sizes",
COI_Error);
458 printf(
"\n**** Fatal Error while Solving for T=%d\n",
T);
462 printf(
"\n**** Incorrect Model or Solver Status returned for T=%d\n",
T);
463 c_log(
"Incorrect Model or Solver Status during later solve", -1);
466 printf(
"\nEnd of Pinadd Model. Return code=%d\n",
COI_Error);
467 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_IniStat(coiHandle_t cntvect, int inistat)
handling of the initial status values.
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_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 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)