Scippy

    SCIP

    Solving Constraint Integer Programs

    nlpi_conopt.c
    Go to the documentation of this file.
    1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
    2/* */
    3/* This file is part of the program and library */
    4/* SCIP --- Solving Constraint Integer Programs */
    5/* */
    6/* Copyright (c) 2002-2026 Zuse Institute Berlin (ZIB) */
    7/* */
    8/* Licensed under the Apache License, Version 2.0 (the "License"); */
    9/* you may not use this file except in compliance with the License. */
    10/* You may obtain a copy of the License at */
    11/* */
    12/* http://www.apache.org/licenses/LICENSE-2.0 */
    13/* */
    14/* Unless required by applicable law or agreed to in writing, software */
    15/* distributed under the License is distributed on an "AS IS" BASIS, */
    16/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
    17/* See the License for the specific language governing permissions and */
    18/* limitations under the License. */
    19/* */
    20/* You should have received a copy of the Apache-2.0 license */
    21/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */
    22/* */
    23/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
    24
    25/**@file nlpi_conopt.c
    26 * @ingroup DEFPLUGINS_NLPI
    27 * @brief CONOPT NLP interface
    28 * @author Ksenia Bestuzheva
    29 *
    30 * NLP interface for the CONOPT solver.
    31 *
    32 * This file can only be compiled if CONOPT is available.
    33 * Otherwise, to resolve public functions, use nlpi_conopt_dummy.c.
    34 */
    35
    36/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
    37
    38#include "scip/nlpi_conopt.h"
    39#include "scip/nlpioracle.h"
    40#include "scip/scip_mem.h"
    41#include "scip/scip_numerics.h"
    42#include "scip/scip_nlp.h"
    43#include "scip/scip_nlpi.h"
    45#include "scip/pub_misc.h"
    46#include "scip/pub_message.h"
    47#include "scip/type_clock.h"
    48#include "scip/scip_general.h"
    49
    50#include "scip/scip_message.h"
    51#include "scip/scip_timing.h"
    52
    53#include "conopt.h"
    54
    55#define NLPI_NAME "conopt" /**< short concise name of solver */
    56#define NLPI_DESC "CONOPT interface" /**< description of solver */
    57#define NLPI_PRIORITY 2000 /**< priority of NLP solver */
    58
    59#define DEFAULT_RANDSEED 107 /**< initial random seed */
    60#define MAXPERTURB 0.01 /**< maximal perturbation of bounds in starting point heuristic */
    61
    62/*
    63 * Data structures
    64 */
    65
    66struct SCIP_NlpiData
    67{
    68 SCIP_CLOCK* solvetime; /**< clock for measuring solving time */
    69 int license_int_1; /**< integer 1 of CONOPT license */
    70 int license_int_2; /**< integer 2 of CONOPT license */
    71 int license_int_3; /**< integer 3 of CONOPT license */
    72 char license_text[81]; /**< text of CONOPT license */
    73};
    74
    76{
    77 SCIP* scip; /**< SCIP data structure */
    78 SCIP_NLPIORACLE* oracle; /**< Oracle-helper to store and evaluate NLP */
    79 SCIP_RANDNUMGEN* randnumgen; /**< random number generator */
    80
    81 SCIP_Bool firstrun; /**< whether the next NLP solve will be the first one (with the current problem structure) */
    82 SCIP_Real* initguess; /**< initial values for primal variables, or NULL if not known */
    83
    84 SCIP_NLPSOLSTAT solstat; /**< solution status from last NLP solve */
    85 SCIP_NLPTERMSTAT termstat; /**< termination status from last NLP solve */
    86 SCIP_Real solvetime; /**< time spend for last NLP solve */
    87 int niterations; /**< number of iterations for last NLP solve */
    88 SCIP_Real objval; /**< objective value from last run */
    89
    90 SCIP_Real* lastprimal; /**< primal solution from last run, if available */
    91 SCIP_Real* lastdualcons; /**< dual solution from last run, if available */
    92 SCIP_Real* lastduallb; /**< dual solution for lower bounds from last run, if available */
    93 SCIP_Real* lastdualub; /**< dual solution for upper bounds from last run, if available */
    94 int varsolsize; /**< size of solution values arrays corresponding to variables */
    95 int conssolsize; /**< size of solution values array corresponding to constraints */
    96
    97 coiHandle_t CntVect; /**< pointer to CONOPT Control Vector */
    98
    99 /* options that will be passed to CONOPT via callbacks */
    100 int verblevel; /**< verbosity level, same as in SCIP_NlpParam: 0 off, 1 normal, 2 debug, > 2 more debug */
    101 SCIP_Real opttol; /**< optimality tolerance */
    102
    103 /* statistics */
    104 int ncalls; /**< overall number of solver calls */
    105 int nsuccess; /**< number of successes (optimal or feasible solution found or proven unbounded) */
    106 int nlocinfeas; /**< number of calls resulting in local infeasibility */
    107 int nother; /**< number of other calls */
    108 int nlimit; /**< number of calls where the solver terminated due to a time or iteration limit */
    109};
    110
    111/*
    112 * Local methods
    113 */
    114
    115/** Implementations of CONOPT callbacks */
    116
    117/** CONOPT callback to pass solution back to SCIP
    118 *
    119 * The dual values are multiplied by -1, since CONOPT's definition of marginal values is 'by
    120 * how much the objective increases if we increase the constraint side by +eps', which, for
    121 * minimisation problems (which is always the case here), is the negative of what SCIP expects.
    122 */
    123static int COI_CALLCONV Solution(
    124 const double XVAL[], /**< solution values of the variables (provided by CONOPT) */
    125 const double XMAR[], /**< marginal values (provided by CONOPT) */
    126 const int XBAS[], /**< basis indicators for the variables (provided by CONOPT) */
    127 const int XSTA[], /**< status values for the variables (provided by CONOPT) */
    128 const double YVAL[], /**< values of the left hand sides of all rows in the optimal solution (provided by CONOPT) */
    129 const double YMAR[], /**< marginal values corresponding to rows (provided by CONOPT) */
    130 const int YBAS[], /**< basis indicators for the rows or constraints (provided by CONOPT) */
    131 const int YSTA[], /**< status values for the rows or constraints (provided by CONOPT) */
    132 int NUMVAR, /**< number of variables (provided by CONOPT) */
    133 int NUMCON, /**< number of constraints (provided by CONOPT) */
    134 void* USRMEM /**< user memory pointer (i.e. pointer to SCIP_NLPIPROBLEM) */
    135 )
    136{
    137 SCIP_NLPIPROBLEM* problem = (SCIP_NLPIPROBLEM*)USRMEM;
    138 int noraclevars;
    139 int noracleconss;
    140
    141 assert(problem != NULL);
    142 assert(problem->oracle != NULL);
    143
    144 noraclevars = SCIPnlpiOracleGetNVars(problem->oracle);
    145 noracleconss = SCIPnlpiOracleGetNConstraints(problem->oracle);
    146
    147 /* number of SCIP variables always less or equal, since CONOPT variables can also contain slack variables */
    148 assert(NUMVAR >= noraclevars);
    149
    150 /* CONOPT has one more constraint than oracle (the objective) */
    151 assert(NUMCON == noracleconss + 1);
    152
    153 /* copy values from CONOPT into SCIP arrays. Note that in CONOPT, there is one
    154 * extra constraint (the objective) and slack variables that are not explicitly
    155 * present in SCIP, which the code below does not copy */
    156 if( problem->lastprimal == NULL )
    157 {
    158 if( NUMVAR > 0 )
    159 {
    160 if( SCIPduplicateBlockMemoryArray(problem->scip, &problem->lastprimal, XVAL, noraclevars) != SCIP_OKAY ||
    161 SCIPallocClearBlockMemoryArray(problem->scip, &problem->lastduallb, noraclevars) != SCIP_OKAY ||
    162 SCIPallocClearBlockMemoryArray(problem->scip, &problem->lastdualub, noraclevars) != SCIP_OKAY )
    163 {
    164 SCIPerrorMessage("Failed to allocate memory for a solution from CONOPT\n");
    165 return 1;
    166 }
    167 problem->varsolsize = noraclevars;
    168 }
    169 if( NUMCON > 0 )
    170 {
    171 if( SCIPduplicateBlockMemoryArray(problem->scip, &problem->lastdualcons, YMAR, noracleconss) != SCIP_OKAY )
    172 {
    173 SCIPerrorMessage("Failed to allocate memory for a solution from CONOPT\n");
    174 return 1;
    175 }
    176 problem->conssolsize = noracleconss;
    177 }
    178 }
    179 else
    180 {
    181 assert(noraclevars <= problem->varsolsize);
    182 assert(noracleconss <= problem->conssolsize);
    183 BMScopyMemoryArray(problem->lastprimal, XVAL, noraclevars);
    184 BMSclearMemoryArray(problem->lastduallb, noraclevars);
    185 BMSclearMemoryArray(problem->lastdualub, noraclevars);
    186 BMScopyMemoryArray(problem->lastdualcons, YMAR, noracleconss);
    187 }
    188
    189 /* replace initial guess with the obtained solution */
    190 if( problem->lastprimal != NULL )
    191 {
    192 if( problem->initguess == NULL )
    193 {
    194 if( SCIPduplicateMemoryArray(problem->scip, &problem->initguess, problem->lastprimal, noraclevars) != SCIP_OKAY )
    195 {
    196 SCIPerrorMessage("Failed to allocate memory for an initial guess from\n");
    197 return 1;
    198 }
    199 }
    200 else
    201 BMScopyMemoryArray(problem->initguess, problem->lastprimal, noraclevars);
    202 }
    203
    204 /* get dual multipliers for variable bounds */
    205 for( int i = 0; i < noraclevars; i++ )
    206 {
    207 if( XBAS[i] == 0 ) /* Xi is at lower bound */
    208 problem->lastduallb[i] = -XMAR[i];
    209 else if( XBAS[i] == 1 ) /* Xi is at upper bound */
    210 problem->lastdualub[i] = -XMAR[i];
    211 }
    212
    213 for( int i = 0; i < NUMCON-1; i++ )
    214 (problem->lastdualcons[i]) *= -1;
    215
    216 return 0;
    217} /*lint !e715*/
    218
    219/** CONOPT callback to pass variable bounds, constraint types and sides
    220 * and Jacobian structure and constant values to CONOPT
    221 */
    222static int COI_CALLCONV ReadMatrix(
    223 double LOWER[], /**< lower bounds on the variables (set to CONOPT's minus infinity before callback is issued */
    224 double CURR[], /**< initial values of the variables (set to zero before callback is issued */
    225 double UPPER[], /**< upper bounds on the variables (set to CONOPT's plus infinity before callback is issued */
    226 int VSTA[], /**< initial status values for the variable (used if coidef_inistat() was called with IniStat = 1 or 2) */
    227 int TYPE[], /**< constraint types (equation, inequality, free) */
    228 double RHS[], /**< right hand sides values of constraints (default is zero) */
    229 int ESTA[], /**< initial status values for constraint slacks (used if coidef_inistat() was called with IniStat = 1 or 2) */
    230 int COLSTA[], /**< starting indices of Jacobian columns in ROWNO */
    231 int ROWNO[], /**< row numbers of Jacobian nonzeros */
    232 double VALUE[], /**< values of the Jacobian elements (defined for all constant Jacobian elements) */
    233 int NLFLAG[], /**< flags marking nonlinear Jacobian elements (following the same sparse representation as ROWNO) */
    234 int NUMVAR, /**< number of variables as defined in COIDEF_NumVar() */
    235 int NUMCON, /**< number of constraints as defined in COIDEF_NumCon() */
    236 int NUMNZ, /**< number of Jacobian elements as defined in COIDEF_NumNz() */
    237 void* USRMEM /**< user memory pointer (i.e. pointer to SCIP_NLPIPROBLEM) */
    238 )
    239{
    240 SCIP_NLPIPROBLEM* problem = (SCIP_NLPIPROBLEM*)USRMEM;
    241 SCIP* scip;
    242 SCIP_NLPIORACLE* oracle;
    243 const SCIP_Real* lbs;
    244 const SCIP_Real* ubs;
    245 int norigvars;
    246 int nslackvars = 0;
    247 int njacnlnnz;
    248 int* rangeconsidxs = NULL;
    249 const SCIP_Bool* jacrownlflags;
    250 const int* jaccoloffsets;
    251 const int* jacrows;
    252 int nobjnz;
    253 const int* objnz;
    254 const SCIP_Bool* objnlflags;
    255 int nobjnlnz;
    256 int objnzcnt = 0;
    257 int* nrownz;
    258 SCIP_RETCODE retcode;
    259
    260 assert(problem != NULL);
    261
    262 oracle = problem->oracle;
    263 assert(oracle != NULL);
    264
    265 scip = problem->scip;
    266 assert(scip != NULL);
    267
    268 SCIPdebugMsg(scip, "NLP sizes passed to CONOPT: NUMVAR = %d, NUMCON = %d, NUMNZ = %d\n", NUMVAR, NUMCON, NUMNZ);
    269
    270 norigvars = SCIPnlpiOracleGetNVars(oracle);
    271 lbs = SCIPnlpiOracleGetVarLbs(oracle);
    272 ubs = SCIPnlpiOracleGetVarUbs(oracle);
    273
    274 /* save indices of range constraints if there are any */
    275 if( NUMVAR - norigvars > 0 )
    276 {
    277 retcode = SCIPallocBufferArray(scip, &rangeconsidxs, NUMVAR - norigvars);
    278 if( retcode != SCIP_OKAY )
    279 {
    280 SCIPerrorMessage("No memory in a callback of CONOPT\n");
    281 return 1;
    282 }
    283 }
    284
    285 /* add all 'normal' (i.e. non-slack) variables here */
    286 for( int i = 0; i < norigvars; i++ )
    287 {
    288 if( !SCIPisInfinity(scip, -lbs[i]) )
    289 LOWER[i] = lbs[i];
    290 if( !SCIPisInfinity(scip, ubs[i]) )
    291 UPPER[i] = ubs[i];
    292 }
    293
    294 /* specify initial values of original variables,
    295 * (if there is a previous solution, it is stored in initguess) */
    296 if( problem->initguess != NULL )
    297 {
    298 BMScopyMemoryArray(CURR, problem->initguess, norigvars);
    299
    300 /* some values may have been set outside the bounds - project them */
    301 for( int i = 0; i < norigvars; ++i )
    302 {
    303 if( lbs[i] > CURR[i] )
    304 CURR[i] = SCIPrandomGetReal(problem->randnumgen, lbs[i], lbs[i] + MAXPERTURB*MIN(1.0, ubs[i]-lbs[i]));
    305 else if( ubs[i] < CURR[i] )
    306 CURR[i] = SCIPrandomGetReal(problem->randnumgen, ubs[i] - MAXPERTURB*MIN(1.0, ubs[i]-lbs[i]), ubs[i]);
    307 }
    308 }
    309 else
    310 {
    311 /* if no initial guess given, project 0 onto variable bounds */
    312 assert(problem->randnumgen != NULL);
    313
    314 SCIPdebugMsg(scip, "CONOPT started without initial primal values; make up starting guess by projecting 0 onto variable bounds\n");
    315
    316 for( int i = 0; i < norigvars; ++i )
    317 {
    318 if( lbs[i] > 0.0 )
    319 CURR[i] = SCIPrandomGetReal(problem->randnumgen, lbs[i], lbs[i] + MAXPERTURB*MIN(1.0, ubs[i]-lbs[i]));
    320 else if( ubs[i] < 0.0 )
    321 CURR[i] = SCIPrandomGetReal(problem->randnumgen, ubs[i] - MAXPERTURB*MIN(1.0, ubs[i]-lbs[i]), ubs[i]);
    322 else
    323 CURR[i] = SCIPrandomGetReal(problem->randnumgen,
    324 MAX(lbs[i], -MAXPERTURB*MIN(1.0, ubs[i]-lbs[i])), MIN(ubs[i], MAXPERTURB*MIN(1.0, ubs[i]-lbs[i])));
    325 }
    326 }
    327
    328 for( int i = 0; i < NUMCON-1; i++ )
    329 {
    332
    333 assert(lhs <= rhs);
    334
    335 if( !SCIPisInfinity(scip, -lhs) && !SCIPisInfinity(scip, rhs) )
    336 {
    337 TYPE[i] = 0; /* an equality or a ranged row modelled as equality */
    338
    339 if( !SCIPisEQ(scip, lhs, rhs) )
    340 {
    341 assert(rangeconsidxs != NULL);
    342
    343 /* range constraint lhs <= g(x) <= rhs: reformulate as g(x) - s = 0 and lhs <= s <= rhs */
    344 RHS[i] = 0.0;
    345 LOWER[norigvars + nslackvars] = lhs;
    346 UPPER[norigvars + nslackvars] = rhs;
    347
    348 /* set initial value of slack variable */
    349 if( lhs > 0.0 )
    350 CURR[norigvars + nslackvars] = SCIPrandomGetReal(problem->randnumgen, lhs, lhs + MAXPERTURB*MIN(1.0, rhs-lhs));
    351 else if( rhs < 0.0 )
    352 CURR[norigvars + nslackvars] = SCIPrandomGetReal(problem->randnumgen, rhs - MAXPERTURB*MIN(1.0, rhs-lhs), rhs);
    353 else
    354 CURR[norigvars + nslackvars] = SCIPrandomGetReal(problem->randnumgen,
    355 MAX(lhs, -MAXPERTURB*MIN(1.0, rhs-lhs)), MIN(rhs, MAXPERTURB*MIN(1.0, rhs-lhs)));
    356
    357 rangeconsidxs[nslackvars] = i;
    358 nslackvars++;
    359 }
    360 else
    361 RHS[i] = lhs;
    362 }
    363 else if( !SCIPisInfinity(scip, -lhs) )
    364 {
    365 TYPE[i] = 1;
    366 RHS[i] = lhs;
    367 }
    368 else if( !SCIPisInfinity(scip, rhs) )
    369 {
    370 TYPE[i] = 2;
    371 RHS[i] = rhs;
    372 }
    373 else
    374 TYPE[i] = 3;
    375 }
    376 assert(norigvars + nslackvars == NUMVAR);
    377
    378 /* the last constraint is the objective */
    379 TYPE[NUMCON-1] = 3; /* objective must be a free row */
    380 RHS[NUMCON-1] = 0.0;
    381
    382 /* Jacobian information */
    383
    384 retcode = SCIPnlpiOracleGetJacobianColSparsity(scip, oracle, &jaccoloffsets, &jacrows, &jacrownlflags, &njacnlnnz);
    385 if( retcode != SCIP_OKAY )
    386 {
    387 SCIPerrorMessage("Error in Jacobian sparsity computation\n");
    388 return 2;
    389 }
    390 assert(jaccoloffsets == NULL || jaccoloffsets[norigvars] <= NUMNZ);
    391
    392 /* move structure info into COLSTA and ROWNO; while doing so, also add nonzeroes for the objective
    393 * (which CONOPT sees as the last constraint, i.e. constraint with index NUMCON-1) */
    394 retcode = SCIPallocCleanBufferArray(scip, &nrownz, NUMCON);
    395 if( retcode != SCIP_OKAY )
    396 {
    397 SCIPerrorMessage("No memory in a callback of CONOPT\n");
    398 return 1;
    399 }
    400
    401 retcode = SCIPnlpiOracleGetObjGradientNnz(scip, oracle, &objnz, &objnlflags, &nobjnz, &nobjnlnz);
    402 assert(nobjnz > 0 || objnz == NULL);
    403 if( retcode != SCIP_OKAY )
    404 {
    405 SCIPerrorMessage("Error in the ReadMatrix callback of CONOPT\n");
    406 return 2;
    407 }
    408
    409 for( int i = 0; i < norigvars; i++ )
    410 {
    411 /* starts of columns get shifted by how many objective nonzeros were added */
    412 COLSTA[i] = jaccoloffsets != NULL ? jaccoloffsets[i] + objnzcnt : objnzcnt;
    413
    414 if( jaccoloffsets != NULL )
    415 {
    416 /* nonzeroes of constraints */
    417 for( int j = jaccoloffsets[i]; j < jaccoloffsets[i+1]; j++ )
    418 {
    419 ROWNO[j+objnzcnt] = jacrows[j];
    420 NLFLAG[j+objnzcnt] = jacrownlflags[j] ? 1 : 0;
    421 if( NLFLAG[j+objnzcnt] == 0 )
    422 {
    423 /* for linear terms, compute the (constant) Jacobian values */
    424 VALUE[j+objnzcnt] = SCIPnlpiOracleGetConstraintLinearCoef(oracle, jacrows[j], nrownz[jacrows[j]]);
    425 ++(nrownz[jacrows[j]]);
    426 }
    427 }
    428 }
    429
    430 /* nonzeroes of objective */
    431 if( objnz != NULL && objnzcnt < nobjnz && i == objnz[objnzcnt] )
    432 {
    433 int idx = jaccoloffsets != NULL ? jaccoloffsets[i+1] + objnzcnt : objnzcnt;
    434
    435 ROWNO[idx] = NUMCON - 1;
    436 NLFLAG[idx] = objnlflags[objnzcnt] ? 1 : 0;
    437 if( NLFLAG[idx] == 0 )
    438 {
    439 /* in the oracle, index -1 is used for the objective */
    440 VALUE[idx] = SCIPnlpiOracleGetConstraintLinearCoef(oracle, -1, nrownz[NUMCON-1]);
    441 ++(nrownz[NUMCON-1]);
    442 }
    443 ++objnzcnt;
    444 }
    445 }
    446 assert(COLSTA[0] == 0);
    447 COLSTA[norigvars] = jaccoloffsets != NULL ? jaccoloffsets[norigvars] + objnzcnt : objnzcnt;
    448 BMSclearMemoryArray(nrownz, NUMCON);
    450
    451 if( nslackvars > 0 )
    452 {
    453 /* add a nonzero for each slack variable */
    454 for( int i = 0; i < nslackvars; i++ )
    455 {
    456 COLSTA[norigvars+i] = COLSTA[norigvars] + i; /* for each slack var, only one nonzero is added */
    457 ROWNO[COLSTA[norigvars+i]] = rangeconsidxs[i];
    458 NLFLAG[COLSTA[norigvars+i]] = 0;
    459 VALUE[COLSTA[norigvars+i]] = -1.0;
    460 }
    461 SCIPfreeBufferArray(scip, &rangeconsidxs);
    462 COLSTA[NUMVAR] = NUMNZ;
    463 }
    464
    465#ifndef NDEBUG
    466 for( int i = 0; i < NUMNZ; ++i )
    467 assert(ROWNO[i] >= 0 && ROWNO[i] < NUMCON);
    468#endif
    469
    470#ifdef STRUCTURE_DEBUG
    471 SCIPdebugMsg(scip, "Jacobian structure information:\n");
    472 SCIPdebugMsg(scip, "COLSTA = ");
    473 for( int i = 0; i <= NUMVAR; i++ )
    474 SCIPdebugMsgPrint(scip, "%d, ", i, COLSTA[i]);
    475 SCIPdebugMsgPrint(scip, "\n");
    476
    477 SCIPdebugMsg(scip, "ROWNO = ");
    478 for( int i = 0; i < NUMNZ; i++ )
    479 SCIPdebugMsgPrint(scip, "%d, ", i, ROWNO[i]);
    480 SCIPdebugMsgPrint(scip, "\n");
    481
    482 SCIPdebugMsg(scip, "NLFLAG = ");
    483 for( int i = 0; i < NUMNZ; i++ )
    484 SCIPdebugMsgPrint(scip, "%d, ", NLFLAG[i]);
    485 SCIPdebugMsgPrint(scip, "\n");
    486
    487 SCIPdebugMsg(scip, "VALUE = ");
    488 for( int i = 0; i < NUMNZ; i++ )
    489 if( VALUE[i] == 1.234e34 ) /*lint !e777*/ /* CONOPT's special value for "undefined" */
    490 SCIPdebugMsgPrint(scip, "undef, ");
    491 else
    492 SCIPdebugMsgPrint(scip, "%g, ", VALUE[i]);
    493 SCIPdebugMsgPrint(scip, "\n");
    494 /*
    495 for( int i = 0; i < NUMVAR; i++ )
    496 {
    497 SCIPdebugMsg(scip, "var %d:", i);
    498 for( int j = COLSTA[i]; j < COLSTA[i+1]; ++j )
    499 SCIPdebugMsgPrint(scip, " %d", ROWNO[j]);
    500 SCIPdebugMsgPrint(scip, "\n");
    501 }
    502 */
    503 fflush(stdout);
    504#endif
    505
    506 return 0;
    507} /*lint !e715*/
    508
    509/** callback for CONOPT's standard output */
    510static int COI_CALLCONV Message(
    511 int SMSG, /**< number of lines in the message that should go to the Screen file, between 0 and 30 */
    512 int DMSG, /**< number of lines in the message that should go to the Status file, between 0 and 30 */
    513 int NMSG, /**< number of lines in the message that should go to the Documentation file, between 0 and 30 */
    514 char* MSGV[], /**< array with the lengths of the individual message lines, the lengths are between 1 and 132 */
    515 void* USRMEM /**< user memory pointer (i.e. pointer to SCIP_NLPIPROBLEM) */
    516 )
    517{
    518 SCIP_NLPIPROBLEM* problem = (SCIP_NLPIPROBLEM*)USRMEM;
    519
    520 assert(problem != NULL);
    521 assert(problem->scip != NULL);
    522 assert(NMSG <= DMSG); /* conopt docu says that NMSG is always <= DMSG */
    523
    524 switch( problem->verblevel )
    525 {
    526 case 0:
    527 break;
    528 case 1:
    529 for( int i = 0; i < SMSG; i++ )
    530 SCIPinfoMessage(problem->scip, NULL, "%s\n", MSGV[i]);
    531 break;
    532 default:
    533 for( int i = 0; i < SMSG || i < DMSG; i++ )
    534 SCIPinfoMessage(problem->scip, NULL, "%s\n", MSGV[i]);
    535 break;
    536 }
    537
    538 return 0;
    539} /*lint !e715*/
    540
    541/** callback for CONOPT's standard error output */
    542static int COI_CALLCONV ErrMsg(
    543 int ROWNO, /**< number of row */
    544 int COLNO, /**< number of column */
    545 int POSNO, /**< number of a Jacobian element */
    546 const char* MSG, /**< the message */
    547 void* USRMEM /**< user memory pointer (i.e. pointer to SCIP_NLPIPROBLEM) */
    548 )
    549{
    550 SCIP_NLPIPROBLEM* problem = (SCIP_NLPIPROBLEM*)USRMEM;
    551
    552 if( problem->verblevel > 0 )
    553 {
    554 if( ROWNO == -1 && COLNO == -1 )
    555 SCIPinfoMessage(problem->scip, NULL, "\nCONOPT error/warning: Jacobian element %d: ", POSNO);
    556 else if( ROWNO == -1 )
    557 SCIPinfoMessage(problem->scip, NULL, "\nCONOPT error/warning: variable %d: ", COLNO);
    558 else if( COLNO == -1 )
    559 SCIPinfoMessage(problem->scip, NULL, "\nCONOPT error/warning: constraint %d: ", ROWNO);
    560 else
    561 SCIPinfoMessage(problem->scip, NULL, "\nCONOPT error/warning: variable %d appearing in constraint %d: ", COLNO, ROWNO);
    562 SCIPinfoMessage(problem->scip, NULL, "%s\n", MSG);
    563 }
    564
    565 return 0;
    566}
    567
    568/** callback for CONOPT to report the solving statuses */
    569static int COI_CALLCONV Status(
    570 int MODSTA, /**< model status (corresponds to SCIP's solstat) */
    571 int SOLSTA, /**< solver status (corresponds to SCIP's termstat) */
    572 int ITER, /**< number of iterations */
    573 double OBJVAL, /**< objective value */
    574 void* USRMEM /**< user memory pointer (i.e. pointer to SCIP_NLPIPROBLEM) */
    575 )
    576{
    577 SCIP* scip;
    578 SCIP_NLPIPROBLEM* problem = (SCIP_NLPIPROBLEM*)USRMEM;
    579 SCIP_Bool other = FALSE;
    580 SCIP_Bool limit = FALSE;
    581
    582 assert(problem != NULL);
    583
    584 scip = problem->scip;
    585 assert(scip != NULL);
    586
    587 SCIPdebugMsg(scip, "CONOPT has finished optimizing\n");
    588 SCIPdebugMsg(scip, "Iteration count = %8d\n", ITER);
    589 SCIPdebugMsg(scip, "Objective value = %10f\n", OBJVAL);
    590
    591 problem->niterations = ITER;
    592 problem->objval = OBJVAL;
    593 ++(problem->ncalls);
    594
    595 switch( MODSTA )
    596 {
    597 case 1:
    598 SCIPdebugMsg(scip, "NLP problem solved to global optimality\n");
    600 ++(problem->nsuccess);
    601 break;
    602 case 2:
    603 SCIPdebugMsg(scip, "NLP problem solved to local optimality\n");
    605 ++(problem->nsuccess);
    606 break;
    607 case 3:
    608 SCIPdebugMsg(scip, "NLP problem unbounded\n");
    610 ++(problem->nsuccess);
    611 break;
    612 case 4:
    613 SCIPdebugMsg(scip, "NLP problem infeasible\n");
    615 ++(problem->nsuccess);
    616 break;
    617 case 5:
    618 SCIPdebugMsg(scip, "NLP problem locally infeasible\n");
    620 ++(problem->nlocinfeas);
    621 break;
    622 case 7: /* intermediate non-optimal */
    624 break;
    625 case 6: /* intermediate infeasible */
    626 case 12: /* unknown error */
    627 case 13:
    628 SCIPdebugMsg(scip, "NLP problem status unknown (CONOPT status %d)\n", MODSTA);
    630 other = TRUE;
    631 break;
    632 default:
    633 SCIPerrorMessage("CONOPT returned an unexpected solution status %d\n", MODSTA);
    635 other = TRUE;
    636 }
    637
    638 switch( SOLSTA )
    639 {
    640 case 1:
    642 SCIPdebugMsg(scip, "CONOPT terminated with normal status.\n");
    643 break;
    644 case 2:
    646 SCIPdebugMsg(scip, "CONOPT terminated due to an iteration limit.\n");
    647 limit = TRUE;
    648 break;
    649 case 3:
    651 SCIPdebugMsg(scip, "CONOPT terminated due to a time limit.\n");
    652 limit = TRUE;
    653 break;
    654 case 4: /* terminated by solver */
    656 SCIPdebugMsg(scip, "CONOPT terminated due to numerical trouble.\n");
    657 break;
    658 case 5:
    660 SCIPdebugMsg(scip, "CONOPT terminated due to evaluation errors.\n");
    661 break;
    662 case 8:
    664 SCIPdebugMsg(scip, "CONOPT interrupted by user.\n");
    665 break;
    666 case 6: /* unknown */
    667 case 9: /* error: setup failure */
    668 case 10: /* error: solver failure */
    669 case 11: /* error: internal solver error */
    670 SCIPdebugMsg(scip, "CONOPT terminated with status %d\n", SOLSTA);
    672 break;
    673 default:
    674 SCIPerrorMessage("CONOPT returned an unexpected termination status %d\n", SOLSTA);
    676 }
    677
    678 if( other )
    679 {
    680 if( limit )
    681 ++(problem->nlimit);
    682 else
    683 ++(problem->nother);
    684 }
    685
    686 return 0;
    687}
    688
    689/** CONOPT callback for function and Jacobian evaluation
    690 *
    691 * The callback has three modes, indicated by MODE:
    692 *
    693 * 1: Only evaluate the sum of the nonlinear and linear terms in row ROWNO and return the value in G.
    694 * 2: Only evaluate the nonlinear Jacobian elements in row ROWNO and return them in JAC.
    695 * 3: Perform both option 1 and 2.
    696 */
    697static int COI_CALLCONV FDEval(
    698 const double X[], /**< point of evaluation (provided by CONOPT) */
    699 double* G, /**< value of the function */
    700 double JAC[], /**< vector of Jacobian values */
    701 int ROWNO, /**< number of the row for which nonlinearities are to be evaluated (provided by CONOPT) */
    702 const int JACNUM[], /**< list of column numbers for the nonlinear nonzero Jacobian elements in
    703 * the current row (provided by CONOPT when MODE = 2 or 3) */
    704 int MODE, /**< indicator for mode of evaluation (provided by CONOPT) */
    705 int IGNERR, /**< indicator whether CONOPT assumes the point to be safe (0) or potentially unsafe (1) */
    706 int* ERRCNT, /**< scalar function evaluation error indicator (set to 1 if a function value cannot be computed */
    707 int NUMVAR, /**< number of variables (provided by CONOPT) */
    708 int NUMJAC, /**< number of nonlinear nonzero Jacobian elements in the current row */
    709 int THREAD, /**< only relevant in multi-threading environments */
    710 void* USRMEM /**< user memory pointer (i.e. pointer to SCIP_NLPIPROBLEM) */
    711 )
    712{
    713 SCIP_RETCODE retcode;
    714 SCIP_NLPIPROBLEM* problem = (SCIP_NLPIPROBLEM*)USRMEM;
    715
    716 assert(problem != NULL);
    717 assert(ROWNO <= SCIPnlpiOracleGetNConstraints(problem->oracle));
    718
    719 if( MODE == 1 )
    720 {
    721 /* the last 'constraint' is the objective */
    722 retcode = ROWNO < SCIPnlpiOracleGetNConstraints(problem->oracle) ?
    723 SCIPnlpiOracleEvalConstraintValue(problem->scip, problem->oracle, ROWNO, X, G) :
    724 SCIPnlpiOracleEvalObjectiveValue(problem->scip, problem->oracle, X, G);
    725 if( retcode != SCIP_OKAY || *G == SCIP_INVALID ) /*lint !e777*/
    726 *ERRCNT = 1;
    727 }
    728
    729 if( MODE == 2 || MODE == 3 )
    730 {
    731 /* the last 'constraint' is the objective */
    732 retcode = ROWNO < SCIPnlpiOracleGetNConstraints(problem->oracle) ?
    733 SCIPnlpiOracleEvalConstraintGradient(problem->scip, problem->oracle, ROWNO, X, TRUE, G, JAC) :
    734 SCIPnlpiOracleEvalObjectiveGradient(problem->scip, problem->oracle, X, TRUE, G, JAC);
    735 if( retcode != SCIP_OKAY )
    736 *ERRCNT = 1;
    737 }
    738
    739 return 0;
    740} /*lint !e715*/
    741
    742/** CONOPT callback to pass some of the options (not supported via COIDEF_* functions) to CONOPT */
    743static int COI_CALLCONV Option(
    744 int NCALL, /**< number of callback call (provided by CONOPT) */
    745 double* RVAL, /**< pointer to set the value of a real option */
    746 int* IVAL, /**< pointer to set the value of an integer option */
    747 int* LVAL, /**< pointer to set the value of a binary option */
    748 char* NAME, /**< pointer to set the name of the option */
    749 void* USRMEM /**< user memory pointer (i.e. pointer to SCIP_NLPIPROBLEM) */
    750 )
    751{
    752 SCIP_NLPIPROBLEM* problem = (SCIP_NLPIPROBLEM*)USRMEM;
    753
    754 assert(problem != NULL);
    755
    756 switch( NCALL )
    757 {
    758 case 0: /* information about stopping criteria */
    759 strcpy(NAME, "LOCNPT");
    760 if( problem->verblevel >= 2 )
    761 *IVAL = 1;
    762 else
    763 *IVAL = 0;
    764 break;
    765 case 1: /* optimality tolerance */
    766 strcpy(NAME, "RTREDG");
    767 *RVAL = problem->opttol;
    768 break;
    769 case 2: /* turn definitional constraints off for now (conopt#103) */
    770 strcpy(NAME, "Flg_NoDefc");
    771 *LVAL = 1;
    772 break;
    773 default:
    774 *NAME = '\0';
    775 }
    776
    777 return 0;
    778} /*lint !e715*/
    779
    780/** CONOPT callback to define structure of the Hessian of the Lagrangian */
    781static int COI_CALLCONV LagrStr(
    782 int HSRW[], /**< row numbers of the lower triangular part of the Hessian */
    783 int HSCL[], /**< column numbers of the lower triangular part of the Hessian; elements must be
    784 * sorted column-wise, and within each column, row-wise */
    785 int* NODRV, /**< can be set to 1 if the derivatives could not be computed */
    786 int NUMVAR, /**< number of variables as defined in coidef_numvar() (provided by CONOPT) */
    787 int NUMCON, /**< number of constraints as defined in coidef_numcon() (provided by CONOPT) */
    788 int NHESS, /**< number of nonzero elements in the Hessian (provided by CONOPT) */
    789 void* USRMEM /**< user memory pointer (i.e. pointer to SCIP_NLPIPROBLEM) */
    790 )
    791{
    792 SCIP_NLPIPROBLEM* problem = (SCIP_NLPIPROBLEM*)USRMEM;
    793 const int* hessoffsets;
    794 const int* rows;
    795 int col = 0;
    796
    797 assert(problem != NULL);
    798
    799 if( SCIPnlpiOracleGetHessianLagSparsity(problem->scip, problem->oracle, &hessoffsets, &rows, TRUE) != SCIP_OKAY )
    800 {
    801 *NODRV = 1;
    802 return 0;
    803 }
    804
    805 for( int i = 0; i < NHESS; i++ )
    806 {
    807 /* check if it's time to switch to the next row (this will also skip empty rows) */
    808 while( i == hessoffsets[col+1] )
    809 col++;
    810
    811 HSRW[i] = rows[i];
    812 HSCL[i] = col;
    813 }
    814
    815 return 0;
    816} /*lint !e715*/
    817
    818/** CONOPT callback to compute the Hessian of the Lagrangian
    819 *
    820 * the Lagrangian is written as L = sum_{r in rows}U[r] * function(r)
    821 */
    822static int COI_CALLCONV LagrVal(
    823 const double X[], /**< point in which the Hessian should be computed (provided by CONOPT) */
    824 const double U[], /**< vector of weights on the individual constraints (provided by CONOPT) */
    825 const int HSRW[], /**< row numbers of the lower triangular part of the Hessian (provided by CONOPT) */
    826 const int HSCL[], /**< column numbers of the lower triangular part of the Hessian; elements must be
    827 * sorted column-wise, and within each column, row-wise (provided by CONOPT) */
    828 double HSVL[], /**< values of Hessian entries */
    829 int* NODRV, /**< can be set to 1 if the derivatives could not be computed */
    830 int NUMVAR, /**< number of variables as defined in coidef_numvar() (provided by CONOPT) */
    831 int NUMCON, /**< number of constraints as defined in coidef_numcon() (provided by CONOPT) */
    832 int NHESS, /**< number of nonzero elements in the Hessian (provided by CONOPT) */
    833 void* USRMEM /**< user memory pointer (i.e. pointer to SCIP_NLPIPROBLEM) */
    834 )
    835{
    836 SCIP_NLPIPROBLEM* problem = (SCIP_NLPIPROBLEM*)USRMEM;
    837
    838 assert(problem != NULL);
    839
    840 /* TODO better handling for isnew? */
    841 if( SCIPnlpiOracleEvalHessianLag(problem->scip, problem->oracle, X, TRUE, TRUE, U[NUMCON-1], U, HSVL, TRUE)
    842 != SCIP_OKAY )
    843 *NODRV = 1;
    844
    845 return 0;
    846} /*lint !e715*/
    847
    848/* NLPI local methods */
    849
    850/** frees solution arrays and sets the solstat and termstat to unknown and other, resp. */
    851static
    853 SCIP_NLPIPROBLEM* problem /**< data structure of problem */
    854 )
    855{
    856 assert(problem != NULL);
    857
    858 SCIPfreeBlockMemoryArrayNull(problem->scip, &(problem->lastprimal), problem->varsolsize);
    859 SCIPfreeBlockMemoryArrayNull(problem->scip, &(problem->lastdualcons), problem->conssolsize);
    860 SCIPfreeBlockMemoryArrayNull(problem->scip, &(problem->lastduallb), problem->varsolsize);
    861 SCIPfreeBlockMemoryArrayNull(problem->scip, &(problem->lastdualub), problem->varsolsize);
    862 problem->varsolsize = 0;
    863 problem->conssolsize = 0;
    864
    867}
    868
    870 SCIP* scip, /**< SCIP data structure */
    871 SCIP_NLPIDATA* data, /**< pointer to NLPIDATA structure */
    872 SCIP_NLPIPROBLEM* problem /**< pointer to NLPI problem structure */
    873 )
    874{
    875 int COI_Error = 0; /* CONOPT error counter */
    876 int nrangeconss = 0;
    877 int nconss;
    878 int nvars;
    879 const int* jacoffsets;
    880 const int* hessoffsets;
    881 int nnlnz;
    882 const int* objgradnz;
    883 const SCIP_Bool* objnl;
    884 int nobjgradnz;
    885 int nobjgradnls;
    886
    887 assert(data != NULL);
    888 assert(problem != NULL);
    889 assert(problem->oracle != NULL);
    890
    891 if( data->solvetime == NULL )
    892 if( data->solvetime == NULL )
    893 {
    894 SCIP_CALL( SCIPcreateClock(scip, &(data->solvetime)) );
    895 }
    896
    897 nconss = SCIPnlpiOracleGetNConstraints(problem->oracle);
    898 nvars = SCIPnlpiOracleGetNVars(problem->oracle);
    899
    900 /* count range constraints: because CONOPT doesn't support them directly, will need to add a slack variable for each ranged constraint */
    901 for( int i = 0; i < nconss; i++ )
    902 {
    905
    906 if( !SCIPisInfinity(problem->scip, -lhs) && !SCIPisInfinity(problem->scip, rhs) && !SCIPisEQ(scip, lhs, rhs) )
    907 nrangeconss++;
    908 }
    909
    910 /* tell CONOPT that we may have empty columns */
    911 COI_Error += COIDEF_EmptyCol(problem->CntVect, 1);
    912
    913 /* inform CONOPT about problem sizes */
    914 COI_Error += COIDEF_NumVar(problem->CntVect, nvars + nrangeconss);
    915 COI_Error += COIDEF_NumCon(problem->CntVect, nconss + 1); /* objective counts as another constraint here */
    916
    917 /* jacobian information */
    918 SCIP_CALL( SCIPnlpiOracleGetJacobianColSparsity(scip, problem->oracle, &jacoffsets, NULL, NULL, &nnlnz) );
    919 SCIP_CALL( SCIPnlpiOracleGetObjGradientNnz(scip, problem->oracle, &objgradnz, &objnl, &nobjgradnz, &nobjgradnls) );
    920
    921 /* each slack var adds a Jacobian nnz; objective also counts as constraint */
    922 COI_Error += COIDEF_NumNz(problem->CntVect, jacoffsets != NULL ? jacoffsets[nvars] + nrangeconss + nobjgradnz :
    923 nrangeconss + nobjgradnz);
    924
    925 /* Jacobian nonzeroes include those of constraints and objective */
    926 COI_Error += COIDEF_NumNlNz(problem->CntVect, nnlnz + nobjgradnls);
    927
    928 /* hessian sparsity information */
    930 COI_Error += COIDEF_NumHess(problem->CntVect, hessoffsets[nvars]);
    931
    932 /* tell CONOPT to minimise the objective (the oracle always gives a minimisation problem) */
    933 COI_Error += COIDEF_OptDir(problem->CntVect, -1);
    934
    935 /* oracle gives objective as a constraint, hence use ObjCon (not ObjVar) here;
    936 * we treat objective as the last constraint, hence index nconss */
    937 COI_Error += COIDEF_ObjCon(problem->CntVect, nconss);
    938
    939 /* register callback routines */
    940 COI_Error += COIDEF_Message(problem->CntVect, Message);
    941 COI_Error += COIDEF_ErrMsg(problem->CntVect, ErrMsg);
    942 COI_Error += COIDEF_Status(problem->CntVect, Status);
    943 COI_Error += COIDEF_Solution(problem->CntVect, Solution);
    944 COI_Error += COIDEF_ReadMatrix(problem->CntVect, ReadMatrix);
    945 COI_Error += COIDEF_FDEval(problem->CntVect, FDEval);
    946 COI_Error += COIDEF_Option(problem->CntVect, Option);
    947 COI_Error += COIDEF_2DLagrStr(problem->CntVect, LagrStr);
    948 COI_Error += COIDEF_2DLagrVal(problem->CntVect, LagrVal);
    949
    950 /* tell CONOPT that our function evaluations include the linear terms */
    951 COI_Error += COIDEF_FVincLin(problem->CntVect, 1);
    952
    953 /* pass the problem pointer to CONOPT, so that it may be used in CONOPT callbacks */
    954 COI_Error += COIDEF_UsrMem(problem->CntVect, (void*)problem);
    955
    956 /* register license, if available */
    957 if( data->license_text[0] != '\0' )
    958 COI_Error += COIDEF_License(problem->CntVect, data->license_int_1, data->license_int_2, data->license_int_3, data->license_text);
    959
    960 if( COI_Error )
    961 SCIPinfoMessage(scip, NULL, "Error %d encountered during initialising CONOPT\n", COI_Error);
    962
    963 return SCIP_OKAY;
    964}
    965
    967 SCIP_NLPIPROBLEM* problem, /**< pointer to problem data structure */
    968 const SCIP_NLPPARAM param /**< NLP solve parameters */
    969 )
    970{
    971 int COI_Error = 0; /* CONOPT error counter */
    972
    973 assert(problem != NULL);
    974
    975 if( param.warmstart )
    976 {
    977 SCIPdebugMsg(problem->scip, "warmstart parameter not supported by CONOPT interface yet. Ignored.\n");
    978 }
    979 if( param.lobjlimit > -SCIP_REAL_MAX )
    980 {
    981 SCIPwarningMessage(problem->scip, "lobjlimit parameter not supported by CONOPT interface yet. Ignored.\n");
    982 }
    983 if( param.fastfail )
    984 {
    985 SCIPdebugMsg(problem->scip, "fastfail parameter not supported by CONOPT interface yet. Ignored.\n");
    986 }
    987
    988 /* options that we can set directly */
    989 COI_Error += COIDEF_ItLim(problem->CntVect, param.iterlimit);
    990 COI_Error += COIDEF_ResLim(problem->CntVect, param.timelimit);
    991
    992 /* options that need to be handled in callbacks */
    993 problem->verblevel = param.verblevel;
    994 problem->opttol = param.opttol;
    995
    996 if( COI_Error )
    997 SCIPinfoMessage(problem->scip, NULL, "Errors encountered during setting parameters, %d\n", COI_Error);
    998}
    999
    1000
    1001/*
    1002 * Callback methods of NLP solver interface
    1003 */
    1004
    1005/** copy method of NLP interface (called when SCIP copies plugins) */
    1006static
    1007SCIP_DECL_NLPICOPY(nlpiCopyConopt)
    1008{
    1009 SCIP_NLPI* targetnlpi;
    1010 SCIP_NLPIDATA* sourcenlpidata;
    1011
    1013
    1014 /* if license is set in source NLPI, maybe set via SCIPsetLicenseConopt(),
    1015 * then pass it on to the copy
    1016 */
    1017 sourcenlpidata = SCIPnlpiGetData(sourcenlpi);
    1018 assert(sourcenlpidata != NULL);
    1019 if( sourcenlpidata->license_text[0] != '\0' )
    1020 {
    1021 targetnlpi = SCIPfindNlpi(scip, NLPI_NAME);
    1022 assert(targetnlpi != NULL);
    1023
    1024 SCIPsetLicenseConopt(targetnlpi, sourcenlpidata->license_int_1,
    1025 sourcenlpidata->license_int_2, sourcenlpidata->license_int_3, sourcenlpidata->license_text);
    1026 }
    1027
    1028 return SCIP_OKAY; /*lint !e527*/
    1029} /*lint !e715*/
    1030
    1031/** destructor of NLP interface to free nlpi data */
    1032static
    1033SCIP_DECL_NLPIFREE(nlpiFreeConopt)
    1034{
    1035 assert(nlpi != NULL);
    1036 assert(nlpidata != NULL);
    1037 assert(*nlpidata != NULL);
    1038
    1039 if( (*nlpidata)->solvetime != NULL )
    1040 if( (*nlpidata)->solvetime != NULL )
    1041 {
    1042 SCIP_CALL( SCIPfreeClock(scip, &((*nlpidata)->solvetime)) );
    1043 }
    1044
    1045 SCIPfreeBlockMemory(scip, nlpidata);
    1046 assert(*nlpidata == NULL);
    1047
    1048 return SCIP_OKAY;
    1049} /*lint !e715*/
    1050
    1051#ifdef SCIP_DISABLED_CODE
    1052/** gets pointer for NLP solver */
    1053static
    1054SCIP_DECL_NLPIGETSOLVERPOINTER(nlpiGetSolverPointerXyz)
    1055{
    1056 SCIPerrorMessage("method of xyz nonlinear solver is not implemented\n");
    1057 SCIPABORT();
    1058
    1059 return NULL; /*lint !e527*/
    1060} /*lint !e715*/
    1061#else
    1062#define nlpiGetSolverPointerConopt NULL
    1063#endif
    1064
    1065/** create a problem instance */
    1066static
    1067SCIP_DECL_NLPICREATEPROBLEM(nlpiCreateProblemConopt)
    1068{
    1069 assert(nlpi != NULL);
    1070 assert(problem != NULL);
    1071
    1073 assert(*problem != NULL);
    1074
    1075 (*problem)->firstrun = TRUE;
    1076 (*problem)->scip = scip;
    1077
    1078 /* initialize oracle */
    1079 SCIP_CALL( SCIPnlpiOracleCreate(scip, &(*problem)->oracle) );
    1080 SCIP_CALL( SCIPnlpiOracleSetProblemName(scip, (*problem)->oracle, name) );
    1081
    1082 if( COI_Create(&((*problem)->CntVect)) || (*problem)->CntVect == NULL )
    1083 {
    1084 SCIPerrorMessage("Could not create CONOPT control vector\n");
    1085 return SCIP_ERROR;
    1086 }
    1087
    1088 /* create random number generator */
    1089 SCIP_CALL( SCIPcreateRandom(scip, &(*problem)->randnumgen, DEFAULT_RANDSEED, TRUE) );
    1090
    1091 return SCIP_OKAY; /*lint !e527*/
    1092} /*lint !e715*/
    1093
    1094/** free a problem instance */
    1095static
    1096SCIP_DECL_NLPIFREEPROBLEM(nlpiFreeProblemConopt)
    1097{
    1098 assert(nlpi != NULL);
    1099 assert(problem != NULL);
    1100 assert(*problem != NULL);
    1101
    1102 invalidateSolution(*problem);
    1103
    1104 if( (*problem)->oracle != NULL )
    1105 {
    1106 SCIP_CALL( SCIPnlpiOracleFree(scip, &(*problem)->oracle) );
    1107 }
    1108
    1109 SCIPfreeRandom(scip, &(*problem)->randnumgen);
    1110 SCIPfreeMemoryArrayNull(scip, &(*problem)->initguess);
    1111
    1112 if( COI_Free(&((*problem)->CntVect)) )
    1113 {
    1114 SCIPerrorMessage("Error when freeing CONOPT control vector\n");
    1115 return SCIP_ERROR;
    1116 }
    1117
    1118 SCIPfreeBlockMemory(scip, problem);
    1119 *problem = NULL;
    1120
    1121#ifdef PRINT_NLPSTATS
    1122 SCIPinfoMessage(scip, NULL, "\nNLP solver CONOPT stats: ncalls = %d, nsuccess = %d, nlimit = %d, nlocinfeas = %d, nother = %d\n",
    1123 (*problem)->ncalls, (*problem)->nsuccess, (*problem)->nlimit, (*problem)->nlocinfeas, (*problem)->nother);
    1124#endif
    1125
    1126 return SCIP_OKAY;
    1127} /*lint !e715*/
    1128
    1129#ifdef SCIP_DISABLED_CODE
    1130/** gets pointer to solver-internal problem instance */
    1131static
    1132SCIP_DECL_NLPIGETPROBLEMPOINTER(nlpiGetProblemPointerXyz)
    1133{
    1134 SCIPerrorMessage("method of xyz nonlinear solver is not implemented\n");
    1135 SCIPABORT();
    1136
    1137 return NULL; /*lint !e527*/
    1138} /*lint !e715*/
    1139#else
    1140#define nlpiGetProblemPointerConopt NULL
    1141#endif
    1142
    1143/** add variables */
    1144static
    1145SCIP_DECL_NLPIADDVARS(nlpiAddVarsConopt)
    1146{
    1147 assert(nlpi != NULL);
    1148 assert(problem != NULL);
    1149 assert(problem->oracle != NULL);
    1150
    1151 SCIP_CALL( SCIPnlpiOracleAddVars(scip, problem->oracle, nvars, lbs, ubs, varnames) );
    1152
    1153 invalidateSolution(problem);
    1154 problem->firstrun = TRUE;
    1155
    1156 return SCIP_OKAY; /*lint !e527*/
    1157} /*lint !e715*/
    1158
    1159
    1160/** add constraints */
    1161static
    1162SCIP_DECL_NLPIADDCONSTRAINTS(nlpiAddConstraintsConopt)
    1163{
    1164 assert(nlpi != NULL);
    1165 assert(problem != NULL);
    1166 assert(problem->oracle != NULL);
    1167
    1168 SCIP_CALL( SCIPnlpiOracleAddConstraints(scip, problem->oracle, nconss, lhss, rhss,
    1169 nlininds, lininds, linvals, exprs, names) );
    1170
    1171 invalidateSolution(problem);
    1172 problem->firstrun = TRUE;
    1173
    1174 return SCIP_OKAY; /*lint !e527*/
    1175} /*lint !e715*/
    1176
    1177/** sets or overwrites objective, a minimization problem is expected */
    1178static
    1179SCIP_DECL_NLPISETOBJECTIVE(nlpiSetObjectiveConopt)
    1180{
    1181 assert(nlpi != NULL);
    1182 assert(problem != NULL);
    1183 assert(problem->oracle != NULL);
    1184
    1185 SCIP_CALL( SCIPnlpiOracleSetObjective(scip, problem->oracle, constant, nlins, lininds, linvals, expr) );
    1186
    1187 invalidateSolution(problem);
    1188 problem->firstrun = TRUE;
    1189
    1190 return SCIP_OKAY; /*lint !e527*/
    1191} /*lint !e715*/
    1192
    1193/** change variable bounds */
    1194static
    1195SCIP_DECL_NLPICHGVARBOUNDS(nlpiChgVarBoundsConopt)
    1196{
    1197 assert(nlpi != NULL);
    1198 assert(problem != NULL);
    1199 assert(problem->oracle != NULL);
    1200
    1201 SCIP_CALL( SCIPnlpiOracleChgVarBounds(scip, problem->oracle, nvars, indices, lbs, ubs) );
    1202
    1203 invalidateSolution(problem);
    1204
    1205 return SCIP_OKAY; /*lint !e527*/
    1206} /*lint !e715*/
    1207
    1208/** change constraint bounds */
    1209static
    1210SCIP_DECL_NLPICHGCONSSIDES(nlpiChgConsSidesConopt)
    1211{
    1212 SCIP_NLPIORACLE* oracle;
    1213
    1214 assert(nlpi != NULL);
    1215 assert(problem != NULL);
    1216
    1217 oracle = problem->oracle;
    1218 assert(oracle != NULL);
    1219
    1220 /* check if any range constraints appear or disappear; if they do, this means new slack variables,
    1221 * and thus a change in problem structure */
    1222 for( int i = 0; i < nconss; ++i )
    1223 {
    1224 SCIP_Real oldlhs;
    1225 SCIP_Real oldrhs;
    1226
    1227 assert(indices != NULL);
    1228 assert(indices[i] >= 0);
    1229 assert(indices[i] < SCIPnlpiOracleGetNConstraints(oracle));
    1230
    1231 oldlhs = SCIPnlpiOracleGetConstraintLhs(oracle, indices[i]);
    1232 oldrhs = SCIPnlpiOracleGetConstraintRhs(oracle, indices[i]);
    1233
    1234 if( !SCIPisInfinity(scip, -oldlhs) && !SCIPisInfinity(scip, oldrhs) && SCIPisLT(scip, oldlhs, oldrhs) )
    1235 {
    1236 /* the old constraint is a range constraint, check if this changes with the new sides */
    1237 if( lhss == NULL || rhss == NULL || SCIPisInfinity(scip, -lhss[i]) || SCIPisInfinity(scip, rhss[i]) ||
    1238 SCIPisEQ(scip, lhss[i], rhss[i]) )
    1239 {
    1240 problem->firstrun = TRUE;
    1241 break;
    1242 }
    1243 }
    1244 else
    1245 {
    1246 /* the old constraint is not a range constraint, check if this changes with the new sides */
    1247 if( lhss != NULL && rhss != NULL && !SCIPisInfinity(scip, -lhss[i]) && !SCIPisInfinity(scip, rhss[i]) &&
    1248 SCIPisLT(scip, lhss[i], rhss[i]) )
    1249 {
    1250 problem->firstrun = TRUE;
    1251 break;
    1252 }
    1253 }
    1254 }
    1255
    1256 SCIP_CALL( SCIPnlpiOracleChgConsSides(scip, oracle, nconss, indices, lhss, rhss) );
    1257
    1258 invalidateSolution(problem);
    1259
    1260 return SCIP_OKAY; /*lint !e527*/
    1261} /*lint !e715*/
    1262
    1263/** delete a set of variables */
    1264static
    1265SCIP_DECL_NLPIDELVARSET(nlpiDelVarSetConopt)
    1266{
    1267 assert(nlpi != NULL);
    1268 assert(problem != NULL);
    1269 assert(problem->oracle != NULL);
    1270
    1271 SCIP_CALL( SCIPnlpiOracleDelVarSet(scip, problem->oracle, dstats) );
    1272
    1273 invalidateSolution(problem);
    1274 problem->firstrun = TRUE;
    1275
    1276 return SCIP_OKAY; /*lint !e527*/
    1277} /*lint !e715*/
    1278
    1279/** delete a set of constraints */
    1280static
    1281SCIP_DECL_NLPIDELCONSSET(nlpiDelConstraintSetConopt)
    1282{
    1283 assert(nlpi != NULL);
    1284 assert(problem != NULL);
    1285 assert(problem->oracle != NULL);
    1286
    1287 SCIP_CALL( SCIPnlpiOracleDelConsSet(scip, problem->oracle, dstats) );
    1288
    1289 invalidateSolution(problem);
    1290 problem->firstrun = TRUE;
    1291
    1292 return SCIP_OKAY; /*lint !e527*/
    1293} /*lint !e715*/
    1294
    1295/** changes (or adds) linear coefficients in a constraint or objective */
    1296static
    1297SCIP_DECL_NLPICHGLINEARCOEFS(nlpiChgLinearCoefsConopt)
    1298{
    1299 assert(nlpi != NULL);
    1300 assert(problem != NULL);
    1301 assert(problem->oracle != NULL);
    1302
    1303 SCIP_CALL( SCIPnlpiOracleChgLinearCoefs(scip, problem->oracle, idx, nvals, varidxs, vals) );
    1304
    1305 invalidateSolution(problem);
    1306 problem->firstrun = TRUE;
    1307
    1308 return SCIP_OKAY; /*lint !e527*/
    1309} /*lint !e715*/
    1310
    1311/** replaces the expression tree of a constraint or objective */
    1312static
    1313SCIP_DECL_NLPICHGEXPR(nlpiChgExprConopt)
    1314{
    1315 assert(nlpi != NULL);
    1316 assert(problem != NULL);
    1317 assert(problem->oracle != NULL);
    1318
    1319 SCIP_CALL( SCIPnlpiOracleChgExpr(scip, problem->oracle, idxcons, expr) );
    1320
    1321 invalidateSolution(problem);
    1322 problem->firstrun = TRUE;
    1323
    1324 return SCIP_OKAY; /*lint !e527*/
    1325} /*lint !e715*/
    1326
    1327/** change the constant offset in the objective */
    1328static
    1329SCIP_DECL_NLPICHGOBJCONSTANT(nlpiChgObjConstantConopt)
    1330{
    1331 assert(nlpi != NULL);
    1332 assert(problem != NULL);
    1333 assert(problem->oracle != NULL);
    1334
    1335 SCIP_CALL( SCIPnlpiOracleChgObjConstant(scip, problem->oracle, objconstant) );
    1336
    1337 return SCIP_OKAY; /*lint !e527*/
    1338} /*lint !e715*/
    1339
    1340/** sets initial guess */
    1341static
    1342SCIP_DECL_NLPISETINITIALGUESS(nlpiSetInitialGuessConopt)
    1343{
    1344 assert(nlpi != NULL);
    1345 assert(problem != NULL);
    1346 assert(problem->oracle != NULL);
    1347
    1348 if( primalvalues != NULL )
    1349 {
    1350 if( !problem->initguess )
    1351 {
    1352 SCIP_CALL( SCIPduplicateMemoryArray(scip, &problem->initguess, primalvalues, SCIPnlpiOracleGetNVars(problem->oracle)) );
    1353 }
    1354 else
    1355 BMScopyMemoryArray(problem->initguess, primalvalues, SCIPnlpiOracleGetNVars(problem->oracle));
    1356 }
    1357 else
    1358 SCIPfreeMemoryArrayNull(scip, &problem->initguess);
    1359
    1360 return SCIP_OKAY;
    1361} /*lint !e715*/
    1362
    1363/** try to solve NLP
    1364 *
    1365 * Note that SCIP will already have reset a timelimit of SCIP_REAL_MAX to the time remaining for the SCIP solve in SCIPnlpiSolve().
    1366 */
    1367static
    1368SCIP_DECL_NLPISOLVE(nlpiSolveConopt)
    1369{
    1370 SCIP_NLPIDATA* data;
    1371 int COI_Error; /* CONOPT error counter */
    1372
    1373 assert(nlpi != NULL);
    1374 assert(problem != NULL);
    1375
    1376 data = SCIPnlpiGetData(nlpi);
    1377 assert(data != NULL);
    1378
    1379 SCIPdebugMsg(scip, "solve with parameters " SCIP_NLPPARAM_PRINT(param));
    1380
    1381 SCIP_CALL( SCIPnlpiOracleResetEvalTime(scip, problem->oracle) );
    1382
    1383 if( param.timelimit == 0.0 )
    1384 {
    1385 /* there is nothing we can do if we are not given any time */
    1386 problem->niterations = 0;
    1387 problem->solvetime = 0.0;
    1388 problem->termstat = SCIP_NLPTERMSTAT_TIMELIMIT;
    1389 problem->solstat = SCIP_NLPSOLSTAT_UNKNOWN;
    1390
    1391 return SCIP_OKAY;
    1392 }
    1393
    1394 problem->niterations = -1;
    1395 problem->solvetime = -1.0;
    1396
    1397 /* set CONOPT parameters */
    1398 handleConoptParam(problem, param);
    1399
    1400 /* initialize Conopt data if necessary */
    1401 if( problem->firstrun )
    1402 {
    1403 SCIP_CALL( initConopt(scip, data, problem) );
    1404 problem->firstrun = FALSE;
    1405 }
    1406
    1407 /* measure time */
    1408 SCIP_CALL( SCIPresetClock(scip, data->solvetime) );
    1409 SCIP_CALL( SCIPstartClock(scip, data->solvetime) );
    1410
    1411 /* optimize */
    1412 COI_Error = COI_Solve(problem->CntVect);
    1413
    1414 /* CONOPT may return either a positive error code, which is one of its own error codes,
    1415 * or a negative error code that is a SCIP_RETCODE returned from one of the callbacks */
    1416 if( COI_Error )
    1417 {
    1418 switch( COI_Error )
    1419 {
    1420 case -1:
    1421 SCIPdebugMsg(scip, "Insufficient memory in CONOPT callback\n");
    1422 break;
    1423 case -2:
    1424 SCIPdebugMsg(scip, "Problem structure computation error in CONOPT's ReadMatrix callback\n");
    1425 break;
    1426 default:
    1427 SCIPdebugMsg(scip, "Errors encountered in CONOPT during solution, %d\n", COI_Error);
    1428 }
    1429 }
    1430
    1431 /* store statistics (some statistics are passed back to SCIP by the Status callback) */
    1432 problem->solvetime = SCIPgetClockTime(scip, data->solvetime);
    1433
    1434 return SCIP_OKAY; /*lint !e527*/
    1435} /*lint !e715*/
    1436
    1437/** gives solution status */
    1438static
    1439SCIP_DECL_NLPIGETSOLSTAT(nlpiGetSolstatConopt)
    1440{
    1441 assert(nlpi != NULL);
    1442 assert(problem != NULL);
    1443
    1444 return problem->solstat;
    1445} /*lint !e715*/
    1446
    1447/** gives termination reason */
    1448static
    1449SCIP_DECL_NLPIGETTERMSTAT(nlpiGetTermstatConopt)
    1450{
    1451 assert(nlpi != NULL);
    1452 assert(problem != NULL);
    1453
    1454 return problem->termstat;
    1455} /*lint !e715*/
    1456
    1457/** gives primal and dual solution values */
    1458static
    1459SCIP_DECL_NLPIGETSOLUTION(nlpiGetSolutionConopt)
    1460{
    1461 assert(problem != NULL);
    1462
    1463 if( primalvalues != NULL )
    1464 *primalvalues = problem->lastprimal;
    1465
    1466 if( consdualvalues != NULL )
    1467 *consdualvalues = problem->lastdualcons;
    1468
    1469 if( varlbdualvalues != NULL )
    1470 *varlbdualvalues = problem->lastduallb;
    1471
    1472 if( varubdualvalues != NULL )
    1473 *varubdualvalues = problem->lastdualub;
    1474
    1475 if( objval != NULL )
    1476 *objval = problem->objval;
    1477
    1478 return SCIP_OKAY; /*lint !e527*/
    1479} /*lint !e715*/
    1480
    1481/** gives solve statistics */
    1482static
    1483SCIP_DECL_NLPIGETSTATISTICS(nlpiGetStatisticsConopt)
    1484{
    1485 assert(nlpi != NULL);
    1486 assert(problem != NULL);
    1487 assert(statistics != NULL);
    1488
    1489 statistics->niterations = problem->niterations;
    1490 statistics->totaltime = problem->solvetime;
    1491 statistics->evaltime = SCIPnlpiOracleGetEvalTime(scip, problem->oracle);
    1492 statistics->consviol = SCIP_INVALID; /* TODO currently unavailable in CONOPT; might change */
    1493 statistics->boundviol = 0.0;
    1494
    1495 return SCIP_OKAY;
    1496} /*lint !e715*/
    1497
    1498/*
    1499 * NLP solver interface specific interface methods
    1500 */
    1501
    1502/** create solver interface for Conopt solver and includes it into SCIP */
    1504 SCIP* scip /**< SCIP data structure */
    1505 )
    1506{
    1507 SCIP_NLPIDATA* nlpidata;
    1508
    1509 /* create Conopt solver interface data */
    1511
    1512#if defined(CONOPT_LICENSE_INT_1) && defined(CONOPT_LICENSE_INT_2) && defined(CONOPT_LICENSE_INT_3) && \
    1513 defined(CONOPT_LICENSE_TEXT)
    1514 nlpidata->license_int_1 = CONOPT_LICENSE_INT_1;
    1515 nlpidata->license_int_2 = CONOPT_LICENSE_INT_2;
    1516 nlpidata->license_int_3 = CONOPT_LICENSE_INT_3;
    1517 (void) SCIPsnprintf(nlpidata->license_text, (int)sizeof(nlpidata->license_text), "%s", CONOPT_LICENSE_TEXT);
    1518#endif
    1519
    1520 /* create and include solver interface */
    1523 nlpiCopyConopt, nlpiFreeConopt, nlpiGetSolverPointerConopt,
    1524 nlpiCreateProblemConopt, nlpiFreeProblemConopt, nlpiGetProblemPointerConopt,
    1525 nlpiAddVarsConopt, nlpiAddConstraintsConopt, nlpiSetObjectiveConopt,
    1526 nlpiChgVarBoundsConopt, nlpiChgConsSidesConopt, nlpiDelVarSetConopt, nlpiDelConstraintSetConopt,
    1527 nlpiChgLinearCoefsConopt, nlpiChgExprConopt, nlpiChgObjConstantConopt,
    1528 nlpiSetInitialGuessConopt, nlpiSolveConopt,
    1529 nlpiGetSolstatConopt, nlpiGetTermstatConopt, nlpiGetSolutionConopt, nlpiGetStatisticsConopt,
    1530 nlpidata) );
    1531
    1533
    1534 return SCIP_OKAY;
    1535}
    1536
    1537/** sets the license to be passed to CONOPT's COIDEF_License */
    1539 SCIP_NLPI* nlpi, /**< CONOPT NLPI */
    1540 int integer_1, /**< CONOPT_LICENSE_INT_1 */
    1541 int integer_2, /**< CONOPT_LICENSE_INT_2 */
    1542 int integer_3, /**< CONOPT_LICENSE_INT_3 */
    1543 const char* text /**< CONOPT_LICENSE_TEXT */
    1544 )
    1545{
    1546 SCIP_NLPIDATA* data;
    1547 assert(nlpi != NULL);
    1548
    1549 data = SCIPnlpiGetData(nlpi);
    1550 assert(data != NULL);
    1551
    1552 data->license_int_1 = integer_1;
    1553 data->license_int_2 = integer_2;
    1554 data->license_int_3 = integer_3;
    1555 (void) SCIPsnprintf(data->license_text, (int)sizeof(data->license_text), "%s", text);
    1556}
    1557
    1558#define STR_HELPER(x) #x
    1559#define STR(x) STR_HELPER(x)
    1560
    1561/** gets string that identifies CONOPT */
    1563 void
    1564 )
    1565{
    1566 return "CONOPT " STR(CONOPT_VERSION_MAJOR) "." STR(CONOPT_VERSION_MINOR) "." STR(CONOPT_VERSION_PATCH);
    1567}
    1568
    1569/** gets string that describes CONOPT */
    1571 void
    1572 )
    1573{
    1574 return "Feasible path solver for large-scale nonlinear problems (conopt.com)";
    1575}
    1576
    1577/** returns whether CONOPT is available, i.e., whether it has been linked in */
    1579 void
    1580 )
    1581{
    1582 return TRUE;
    1583}
    #define NULL
    Definition: def.h:255
    #define SCIP_REAL_MAX
    Definition: def.h:165
    #define SCIP_INVALID
    Definition: def.h:185
    #define SCIP_Bool
    Definition: def.h:98
    #define MIN(x, y)
    Definition: def.h:231
    #define SCIP_Real
    Definition: def.h:163
    #define TRUE
    Definition: def.h:100
    #define FALSE
    Definition: def.h:101
    #define MAX(x, y)
    Definition: def.h:227
    #define SCIPABORT()
    Definition: def.h:334
    #define SCIP_CALL(x)
    Definition: def.h:362
    void SCIPinfoMessage(SCIP *scip, FILE *file, const char *formatstr,...)
    Definition: scip_message.c:208
    #define SCIPdebugMsgPrint
    Definition: scip_message.h:79
    #define SCIPdebugMsg
    Definition: scip_message.h:78
    void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
    Definition: scip_message.c:120
    SCIP_RETCODE SCIPincludeNlpSolverConopt(SCIP *scip)
    Definition: nlpi_conopt.c:1503
    SCIP_RETCODE SCIPnlpiOracleEvalObjectiveValue(SCIP *scip, SCIP_NLPIORACLE *oracle, const SCIP_Real *x, SCIP_Real *objval)
    Definition: nlpioracle.c:2124
    SCIP_RETCODE SCIPnlpiOracleChgLinearCoefs(SCIP *scip, SCIP_NLPIORACLE *oracle, int considx, int nentries, const int *varidxs, const SCIP_Real *newcoefs)
    Definition: nlpioracle.c:1774
    SCIP_RETCODE SCIPnlpiOracleGetHessianLagSparsity(SCIP *scip, SCIP_NLPIORACLE *oracle, const int **offset, const int **allnz, SCIP_Bool colwise)
    Definition: nlpioracle.c:2670
    SCIP_RETCODE SCIPnlpiOracleChgVarBounds(SCIP *scip, SCIP_NLPIORACLE *oracle, int nvars, const int *indices, const SCIP_Real *lbs, const SCIP_Real *ubs)
    Definition: nlpioracle.c:1474
    SCIP_RETCODE SCIPnlpiOracleAddConstraints(SCIP *scip, SCIP_NLPIORACLE *oracle, int nconss, const SCIP_Real *lhss, const SCIP_Real *rhss, const int *nlininds, int *const *lininds, SCIP_Real *const *linvals, SCIP_EXPR **exprs, const char **consnames)
    Definition: nlpioracle.c:1384
    SCIP_RETCODE SCIPnlpiOracleDelVarSet(SCIP *scip, SCIP_NLPIORACLE *oracle, int *delstats)
    Definition: nlpioracle.c:1546
    SCIP_RETCODE SCIPnlpiOracleCreate(SCIP *scip, SCIP_NLPIORACLE **oracle)
    Definition: nlpioracle.c:1200
    SCIP_RETCODE SCIPnlpiOracleEvalObjectiveGradient(SCIP *scip, SCIP_NLPIORACLE *oracle, const SCIP_Real *x, SCIP_Bool isnewx, SCIP_Real *objval, SCIP_Real *objgrad)
    Definition: nlpioracle.c:2205
    SCIP_RETCODE SCIPnlpiOracleResetEvalTime(SCIP *scip, SCIP_NLPIORACLE *oracle)
    Definition: nlpioracle.c:2821
    SCIP_RETCODE SCIPnlpiOracleSetObjective(SCIP *scip, SCIP_NLPIORACLE *oracle, const SCIP_Real constant, int nlin, const int *lininds, const SCIP_Real *linvals, SCIP_EXPR *expr)
    Definition: nlpioracle.c:1445
    SCIP_Real SCIPnlpiOracleGetConstraintRhs(SCIP_NLPIORACLE *oracle, int considx)
    Definition: nlpioracle.c:2038
    SCIP_Real SCIPnlpiOracleGetEvalTime(SCIP *scip, SCIP_NLPIORACLE *oracle)
    Definition: nlpioracle.c:2837
    SCIP_RETCODE SCIPnlpiOracleChgConsSides(SCIP *scip, SCIP_NLPIORACLE *oracle, int nconss, const int *indices, const SCIP_Real *lhss, const SCIP_Real *rhss)
    Definition: nlpioracle.c:1511
    SCIP_Real SCIPnlpiOracleGetConstraintLhs(SCIP_NLPIORACLE *oracle, int considx)
    Definition: nlpioracle.c:2025
    SCIP_RETCODE SCIPnlpiOracleGetJacobianColSparsity(SCIP *scip, SCIP_NLPIORACLE *oracle, const int **coloffsets, const int **rows, const SCIP_Bool **rownlflags, int *nnlnz)
    Definition: nlpioracle.c:2318
    SCIP_RETCODE SCIPnlpiOracleAddVars(SCIP *scip, SCIP_NLPIORACLE *oracle, int nvars, const SCIP_Real *lbs, const SCIP_Real *ubs, const char **varnames)
    Definition: nlpioracle.c:1298
    SCIP_RETCODE SCIPnlpiOracleEvalHessianLag(SCIP *scip, SCIP_NLPIORACLE *oracle, const SCIP_Real *x, SCIP_Bool isnewx_obj, SCIP_Bool isnewx_cons, SCIP_Real objfactor, const SCIP_Real *lambda, SCIP_Real *hessian, SCIP_Bool colwise)
    Definition: nlpioracle.c:2770
    SCIP_RETCODE SCIPnlpiOracleEvalConstraintGradient(SCIP *scip, SCIP_NLPIORACLE *oracle, const int considx, const SCIP_Real *x, SCIP_Bool isnewx, SCIP_Real *conval, SCIP_Real *congrad)
    Definition: nlpioracle.c:2234
    int SCIPnlpiOracleGetNVars(SCIP_NLPIORACLE *oracle)
    Definition: nlpioracle.c:1933
    int SCIPnlpiOracleGetNConstraints(SCIP_NLPIORACLE *oracle)
    Definition: nlpioracle.c:1943
    SCIP_RETCODE SCIPnlpiOracleGetObjGradientNnz(SCIP *scip, SCIP_NLPIORACLE *oracle, const int **nz, const SCIP_Bool **nlnz, int *nnz, int *nnlnz)
    Definition: nlpioracle.c:2410
    SCIP_RETCODE SCIPnlpiOracleDelConsSet(SCIP *scip, SCIP_NLPIORACLE *oracle, int *delstats)
    Definition: nlpioracle.c:1688
    SCIP_RETCODE SCIPnlpiOracleSetProblemName(SCIP *scip, SCIP_NLPIORACLE *oracle, const char *name)
    Definition: nlpioracle.c:1262
    SCIP_RETCODE SCIPnlpiOracleChgObjConstant(SCIP *scip, SCIP_NLPIORACLE *oracle, SCIP_Real objconstant)
    Definition: nlpioracle.c:1916
    SCIP_RETCODE SCIPnlpiOracleEvalConstraintValue(SCIP *scip, SCIP_NLPIORACLE *oracle, int considx, const SCIP_Real *x, SCIP_Real *conval)
    Definition: nlpioracle.c:2149
    SCIP_Real SCIPnlpiOracleGetConstraintLinearCoef(SCIP_NLPIORACLE *oracle, int considx, int varpos)
    Definition: nlpioracle.c:2064
    const SCIP_Real * SCIPnlpiOracleGetVarLbs(SCIP_NLPIORACLE *oracle)
    Definition: nlpioracle.c:1953
    const SCIP_Real * SCIPnlpiOracleGetVarUbs(SCIP_NLPIORACLE *oracle)
    Definition: nlpioracle.c:1963
    SCIP_RETCODE SCIPnlpiOracleFree(SCIP *scip, SCIP_NLPIORACLE **oracle)
    Definition: nlpioracle.c:1230
    SCIP_RETCODE SCIPnlpiOracleChgExpr(SCIP *scip, SCIP_NLPIORACLE *oracle, int considx, SCIP_EXPR *expr)
    Definition: nlpioracle.c:1870
    void SCIPsetLicenseConopt(SCIP_NLPI *nlpi, int integer_1, int integer_2, int integer_3, const char *text)
    Definition: nlpi_conopt.c:1538
    const char * SCIPgetSolverDescConopt(void)
    Definition: nlpi_conopt.c:1570
    SCIP_Bool SCIPisConoptAvailableConopt(void)
    Definition: nlpi_conopt.c:1578
    const char * SCIPgetSolverNameConopt(void)
    Definition: nlpi_conopt.c:1562
    SCIP_RETCODE SCIPincludeExternalCodeInformation(SCIP *scip, const char *name, const char *description)
    Definition: scip_general.c:769
    #define SCIPfreeCleanBufferArray(scip, ptr)
    Definition: scip_mem.h:146
    #define SCIPallocCleanBufferArray(scip, ptr, num)
    Definition: scip_mem.h:142
    #define SCIPfreeMemoryArrayNull(scip, ptr)
    Definition: scip_mem.h:81
    #define SCIPallocClearBlockMemory(scip, ptr)
    Definition: scip_mem.h:91
    #define SCIPallocClearBlockMemoryArray(scip, ptr, num)
    Definition: scip_mem.h:97
    #define SCIPallocBufferArray(scip, ptr, num)
    Definition: scip_mem.h:124
    #define SCIPfreeBufferArray(scip, ptr)
    Definition: scip_mem.h:136
    #define SCIPduplicateMemoryArray(scip, ptr, source, num)
    Definition: scip_mem.h:76
    #define SCIPfreeBlockMemory(scip, ptr)
    Definition: scip_mem.h:108
    #define SCIPfreeBlockMemoryArrayNull(scip, ptr, num)
    Definition: scip_mem.h:111
    #define SCIPduplicateBlockMemoryArray(scip, ptr, source, num)
    Definition: scip_mem.h:105
    SCIP_RETCODE SCIPincludeNlpi(SCIP *scip, const char *name, const char *description, int priority, SCIP_DECL_NLPICOPY((*nlpicopy)), SCIP_DECL_NLPIFREE((*nlpifree)), SCIP_DECL_NLPIGETSOLVERPOINTER((*nlpigetsolverpointer)), SCIP_DECL_NLPICREATEPROBLEM((*nlpicreateproblem)), SCIP_DECL_NLPIFREEPROBLEM((*nlpifreeproblem)), SCIP_DECL_NLPIGETPROBLEMPOINTER((*nlpigetproblempointer)), SCIP_DECL_NLPIADDVARS((*nlpiaddvars)), SCIP_DECL_NLPIADDCONSTRAINTS((*nlpiaddconstraints)), SCIP_DECL_NLPISETOBJECTIVE((*nlpisetobjective)), SCIP_DECL_NLPICHGVARBOUNDS((*nlpichgvarbounds)), SCIP_DECL_NLPICHGCONSSIDES((*nlpichgconssides)), SCIP_DECL_NLPIDELVARSET((*nlpidelvarset)), SCIP_DECL_NLPIDELCONSSET((*nlpidelconsset)), SCIP_DECL_NLPICHGLINEARCOEFS((*nlpichglinearcoefs)), SCIP_DECL_NLPICHGEXPR((*nlpichgexpr)), SCIP_DECL_NLPICHGOBJCONSTANT((*nlpichgobjconstant)), SCIP_DECL_NLPISETINITIALGUESS((*nlpisetinitialguess)), SCIP_DECL_NLPISOLVE((*nlpisolve)), SCIP_DECL_NLPIGETSOLSTAT((*nlpigetsolstat)), SCIP_DECL_NLPIGETTERMSTAT((*nlpigettermstat)), SCIP_DECL_NLPIGETSOLUTION((*nlpigetsolution)), SCIP_DECL_NLPIGETSTATISTICS((*nlpigetstatistics)), SCIP_NLPIDATA *nlpidata)
    Definition: scip_nlpi.c:113
    SCIP_NLPI * SCIPfindNlpi(SCIP *scip, const char *name)
    Definition: scip_nlpi.c:179
    SCIP_NLPIDATA * SCIPnlpiGetData(SCIP_NLPI *nlpi)
    Definition: nlpi.c:712
    SCIP_RETCODE SCIPcreateClock(SCIP *scip, SCIP_CLOCK **clck)
    Definition: scip_timing.c:76
    SCIP_RETCODE SCIPresetClock(SCIP *scip, SCIP_CLOCK *clck)
    Definition: scip_timing.c:144
    SCIP_RETCODE SCIPfreeClock(SCIP *scip, SCIP_CLOCK **clck)
    Definition: scip_timing.c:127
    SCIP_Real SCIPgetClockTime(SCIP *scip, SCIP_CLOCK *clck)
    Definition: scip_timing.c:319
    SCIP_RETCODE SCIPstartClock(SCIP *scip, SCIP_CLOCK *clck)
    Definition: scip_timing.c:161
    SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
    SCIP_Bool SCIPisEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
    SCIP_Bool SCIPisLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
    void SCIPfreeRandom(SCIP *scip, SCIP_RANDNUMGEN **randnumgen)
    SCIP_Real SCIPrandomGetReal(SCIP_RANDNUMGEN *randnumgen, SCIP_Real minrandval, SCIP_Real maxrandval)
    Definition: misc.c:10245
    SCIP_RETCODE SCIPcreateRandom(SCIP *scip, SCIP_RANDNUMGEN **randnumgen, unsigned int initialseed, SCIP_Bool useglobalseed)
    int SCIPsnprintf(char *t, int len, const char *s,...)
    Definition: misc.c:10827
    #define BMScopyMemoryArray(ptr, source, num)
    Definition: memory.h:134
    #define BMSclearMemoryArray(ptr, num)
    Definition: memory.h:130
    static SCIP_DECL_NLPICHGCONSSIDES(nlpiChgConsSidesConopt)
    Definition: nlpi_conopt.c:1210
    static SCIP_DECL_NLPICHGLINEARCOEFS(nlpiChgLinearCoefsConopt)
    Definition: nlpi_conopt.c:1297
    static int COI_CALLCONV LagrStr(int HSRW[], int HSCL[], int *NODRV, int NUMVAR, int NUMCON, int NHESS, void *USRMEM)
    Definition: nlpi_conopt.c:781
    #define NLPI_PRIORITY
    Definition: nlpi_conopt.c:57
    #define STR(x)
    Definition: nlpi_conopt.c:1559
    #define MAXPERTURB
    Definition: nlpi_conopt.c:60
    static SCIP_DECL_NLPIFREEPROBLEM(nlpiFreeProblemConopt)
    Definition: nlpi_conopt.c:1096
    static void handleConoptParam(SCIP_NLPIPROBLEM *problem, const SCIP_NLPPARAM param)
    Definition: nlpi_conopt.c:966
    static SCIP_DECL_NLPICHGOBJCONSTANT(nlpiChgObjConstantConopt)
    Definition: nlpi_conopt.c:1329
    static SCIP_DECL_NLPIADDCONSTRAINTS(nlpiAddConstraintsConopt)
    Definition: nlpi_conopt.c:1162
    static SCIP_DECL_NLPISETOBJECTIVE(nlpiSetObjectiveConopt)
    Definition: nlpi_conopt.c:1179
    static SCIP_DECL_NLPIGETSOLSTAT(nlpiGetSolstatConopt)
    Definition: nlpi_conopt.c:1439
    static int COI_CALLCONV 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)
    Definition: nlpi_conopt.c:222
    static int COI_CALLCONV 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)
    Definition: nlpi_conopt.c:697
    #define NLPI_NAME
    Definition: nlpi_conopt.c:55
    static SCIP_DECL_NLPICHGEXPR(nlpiChgExprConopt)
    Definition: nlpi_conopt.c:1313
    static int COI_CALLCONV LagrVal(const double X[], const double U[], const int HSRW[], const int HSCL[], double HSVL[], int *NODRV, int NUMVAR, int NUMCON, int NHESS, void *USRMEM)
    Definition: nlpi_conopt.c:822
    static SCIP_DECL_NLPICREATEPROBLEM(nlpiCreateProblemConopt)
    Definition: nlpi_conopt.c:1067
    #define nlpiGetSolverPointerConopt
    Definition: nlpi_conopt.c:1062
    static SCIP_DECL_NLPIDELVARSET(nlpiDelVarSetConopt)
    Definition: nlpi_conopt.c:1265
    #define nlpiGetProblemPointerConopt
    Definition: nlpi_conopt.c:1140
    static SCIP_DECL_NLPIDELCONSSET(nlpiDelConstraintSetConopt)
    Definition: nlpi_conopt.c:1281
    static SCIP_DECL_NLPICHGVARBOUNDS(nlpiChgVarBoundsConopt)
    Definition: nlpi_conopt.c:1195
    #define DEFAULT_RANDSEED
    Definition: nlpi_conopt.c:59
    static int COI_CALLCONV 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)
    Definition: nlpi_conopt.c:123
    static int COI_CALLCONV ErrMsg(int ROWNO, int COLNO, int POSNO, const char *MSG, void *USRMEM)
    Definition: nlpi_conopt.c:542
    static SCIP_RETCODE initConopt(SCIP *scip, SCIP_NLPIDATA *data, SCIP_NLPIPROBLEM *problem)
    Definition: nlpi_conopt.c:869
    static int COI_CALLCONV Status(int MODSTA, int SOLSTA, int ITER, double OBJVAL, void *USRMEM)
    Definition: nlpi_conopt.c:569
    static SCIP_DECL_NLPIGETTERMSTAT(nlpiGetTermstatConopt)
    Definition: nlpi_conopt.c:1449
    static SCIP_DECL_NLPIGETSOLUTION(nlpiGetSolutionConopt)
    Definition: nlpi_conopt.c:1459
    static SCIP_DECL_NLPISETINITIALGUESS(nlpiSetInitialGuessConopt)
    Definition: nlpi_conopt.c:1342
    static SCIP_DECL_NLPIADDVARS(nlpiAddVarsConopt)
    Definition: nlpi_conopt.c:1145
    static SCIP_DECL_NLPIGETSTATISTICS(nlpiGetStatisticsConopt)
    Definition: nlpi_conopt.c:1483
    static SCIP_DECL_NLPIFREE(nlpiFreeConopt)
    Definition: nlpi_conopt.c:1033
    static int COI_CALLCONV Message(int SMSG, int DMSG, int NMSG, char *MSGV[], void *USRMEM)
    Definition: nlpi_conopt.c:510
    static int COI_CALLCONV Option(int NCALL, double *RVAL, int *IVAL, int *LVAL, char *NAME, void *USRMEM)
    Definition: nlpi_conopt.c:743
    static SCIP_DECL_NLPICOPY(nlpiCopyConopt)
    Definition: nlpi_conopt.c:1007
    #define NLPI_DESC
    Definition: nlpi_conopt.c:56
    static SCIP_DECL_NLPISOLVE(nlpiSolveConopt)
    Definition: nlpi_conopt.c:1368
    static void invalidateSolution(SCIP_NLPIPROBLEM *problem)
    Definition: nlpi_conopt.c:852
    CONOPT NLP interface.
    methods to store an NLP and request function, gradient, and Hessian values
    public methods for message output
    #define SCIPerrorMessage
    Definition: pub_message.h:64
    public data structures and miscellaneous methods
    general public methods
    public methods for memory management
    public methods for message handling
    public methods for nonlinear relaxation
    public methods for NLPI solver interfaces
    public methods for numerical tolerances
    public methods for random numbers
    public methods for timing
    @ RHS
    SCIP_Real timelimit
    Definition: type_nlpi.h:72
    SCIP_Bool warmstart
    Definition: type_nlpi.h:77
    SCIP_Real opttol
    Definition: type_nlpi.h:70
    SCIP_NLPPARAM_FASTFAIL fastfail
    Definition: type_nlpi.h:75
    SCIP_Real lobjlimit
    Definition: type_nlpi.h:68
    unsigned short verblevel
    Definition: type_nlpi.h:74
    SCIP_Real * lastprimal
    Definition: nlpi_conopt.c:90
    SCIP_Real * lastduallb
    Definition: nlpi_conopt.c:92
    coiHandle_t CntVect
    Definition: nlpi_conopt.c:97
    SCIP_Real * lastdualcons
    Definition: nlpi_conopt.c:91
    SCIP_Bool firstrun
    Definition: nlpi_conopt.c:81
    SCIP_NLPIORACLE * oracle
    Definition: nlpi_conopt.c:78
    SCIP_RANDNUMGEN * randnumgen
    Definition: nlpi_conopt.c:79
    SCIP_Real solvetime
    Definition: nlpi_conopt.c:86
    SCIP_NLPTERMSTAT termstat
    Definition: nlpi_conopt.c:85
    SCIP_Real opttol
    Definition: nlpi_conopt.c:101
    SCIP_Real * lastdualub
    Definition: nlpi_conopt.c:93
    SCIP_Real objval
    Definition: nlpi_conopt.c:88
    SCIP_Real * initguess
    Definition: nlpi_conopt.c:82
    SCIP_NLPSOLSTAT solstat
    Definition: nlpi_conopt.c:84
    type definitions for clocks and timing issues
    #define SCIP_NLPPARAM_PRINT(param)
    Definition: type_nlpi.h:142
    enum SCIP_NlpSolStat SCIP_NLPSOLSTAT
    Definition: type_nlpi.h:168
    @ SCIP_NLPTERMSTAT_OKAY
    Definition: type_nlpi.h:173
    @ SCIP_NLPTERMSTAT_TIMELIMIT
    Definition: type_nlpi.h:174
    @ SCIP_NLPTERMSTAT_NUMERICERROR
    Definition: type_nlpi.h:178
    @ SCIP_NLPTERMSTAT_OTHER
    Definition: type_nlpi.h:182
    @ SCIP_NLPTERMSTAT_EVALERROR
    Definition: type_nlpi.h:179
    @ SCIP_NLPTERMSTAT_ITERLIMIT
    Definition: type_nlpi.h:175
    @ SCIP_NLPTERMSTAT_INTERRUPT
    Definition: type_nlpi.h:177
    #define SCIP_DECL_NLPIGETSOLVERPOINTER(x)
    Definition: type_nlpi.h:233
    #define SCIP_DECL_NLPIGETPROBLEMPOINTER(x)
    Definition: type_nlpi.h:272
    @ SCIP_NLPSOLSTAT_UNBOUNDED
    Definition: type_nlpi.h:165
    @ SCIP_NLPSOLSTAT_GLOBINFEASIBLE
    Definition: type_nlpi.h:164
    @ SCIP_NLPSOLSTAT_LOCINFEASIBLE
    Definition: type_nlpi.h:163
    @ SCIP_NLPSOLSTAT_FEASIBLE
    Definition: type_nlpi.h:162
    @ SCIP_NLPSOLSTAT_LOCOPT
    Definition: type_nlpi.h:161
    @ SCIP_NLPSOLSTAT_GLOBOPT
    Definition: type_nlpi.h:160
    @ SCIP_NLPSOLSTAT_UNKNOWN
    Definition: type_nlpi.h:166
    enum SCIP_NlpTermStat SCIP_NLPTERMSTAT
    Definition: type_nlpi.h:184
    struct SCIP_NlpiData SCIP_NLPIDATA
    Definition: type_nlpi.h:52
    @ SCIP_OKAY
    Definition: type_retcode.h:42
    @ SCIP_ERROR
    Definition: type_retcode.h:43
    enum SCIP_Retcode SCIP_RETCODE
    Definition: type_retcode.h:63