Scippy

SCIP

Solving Constraint Integer Programs

nlpi_all.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-2021 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SCIP; see the file COPYING. If not visit scipopt.org. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file nlpi_all.c
17  * @ingroup NLPIS
18  * @brief NLP interface that uses all available NLP interfaces
19  * @author Benjamin Mueller
20  */
21 
22 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
23 
24 #include "nlpi/nlpi_all.h"
25 #include "nlpi/nlpi.h"
26 #include "scip/pub_misc.h"
27 #include "scip/pub_message.h"
28 #ifdef SCIP_STATISTIC
29 #include "nlpi/struct_nlpi.h"
30 #endif
31 
32 #include <string.h>
33 
34 #define NLPI_NAME "all" /* short concise name of solver */
35 #define NLPI_DESC "NLP interface that uses all available NLP interfaces" /* description of solver */
36 #define NLPI_PRIORITY -3000 /* priority of NLP solver */
37 
38 /*
39  * Data structures
40  */
41 
42 struct SCIP_NlpiData
43 {
44  SCIP_NLPI** nlpis; /**< array containing all nlpis */
45  BMS_BLKMEM* blkmem; /**< block memory */
46  int nnlpis; /**< total number of nlpis */
47  SCIP_MESSAGEHDLR* messagehdlr; /**< message handler */
48 };
49 
51 {
52  SCIP_NLPIPROBLEM** nlpiproblems; /**< array containing all nlpi problems */
53  int nnlpiproblems; /**< total number of nlpi problems */
54  int bestidx; /**< index of NLP solver with the best solution */
55 };
56 
57 #ifdef SCIP_STATISTIC
58 static int _nnlps = 0; /**< number of NLPs that have been solved */
59 #endif
60 
61 /*
62  * Local methods
63  */
64 
65 /*
66  * Callback methods of NLP solver interface
67  */
68 
69 /** copy method of NLP interface (called when SCIP copies plugins)
70  *
71  * input:
72  * - blkmem block memory in target SCIP
73  * - sourcenlpi the NLP interface to copy
74  * - targetnlpi buffer to store pointer to copy of NLP interface
75  */
76 static
77 SCIP_DECL_NLPICOPY( nlpiCopyAll )
78 {
79  SCIP_NLPIDATA* sourcedata;
81 
82  assert(sourcenlpi != NULL);
83  assert(targetnlpi != NULL);
84 
85  sourcedata = SCIPnlpiGetData(sourcenlpi);
86  assert(sourcedata != NULL);
87  assert(sourcedata->nnlpis > 1);
88  assert(sourcedata->nlpis[0] != NULL);
89 
90  /* create target nlpis */
91  SCIP_CALL( SCIPcreateNlpSolverAll(blkmem, targetnlpi, sourcedata->nlpis, sourcedata->nnlpis) );
92  assert(*targetnlpi != NULL);
93 
94  SCIP_CALL( SCIPnlpiGetRealPar(sourcedata->nlpis[0], NULL, SCIP_NLPPAR_INFINITY, &infinity) );
95  SCIP_CALL( SCIPnlpiSetRealPar(*targetnlpi, NULL, SCIP_NLPPAR_INFINITY, infinity) );
96  SCIP_CALL( SCIPnlpiSetMessageHdlr(*targetnlpi, sourcedata->messagehdlr) );
97 
98  return SCIP_OKAY; /*lint !e527*/
99 } /*lint !e715*/
100 
101 /** destructor of NLP interface to free nlpi data
102  *
103  * input:
104  * - nlpi datastructure for solver interface
105  */
106 static
107 SCIP_DECL_NLPIFREE( nlpiFreeAll )
108 {
109  SCIP_NLPIDATA* data;
110  int i;
111 
112  assert(nlpi != NULL);
113 
114  data = SCIPnlpiGetData(nlpi);
115  assert(data != NULL);
116 
117  for( i = data->nnlpis - 1; i >= 0; --i )
118  {
119  SCIP_CALL( SCIPnlpiFree(&data->nlpis[i]) );
120  }
121 
122  BMSfreeBlockMemoryArrayNull(data->blkmem, &data->nlpis, data->nnlpis);
123  BMSfreeBlockMemory(data->blkmem, &data);
124 
125  return SCIP_OKAY; /*lint !e527*/
126 } /*lint !e715*/
127 
128 /** gets pointer for NLP solver
129  *
130  * to do dirty stuff
131  *
132  * input:
133  * - nlpi datastructure for solver interface
134  *
135  * return: void pointer to solver
136  */
137 static
138 SCIP_DECL_NLPIGETSOLVERPOINTER(nlpiGetSolverPointerAll)
139 {
140  assert(nlpi != NULL);
141 
142  return NULL; /*lint !e527*/
143 } /*lint !e715*/
144 
145 /** creates a problem instance
146  *
147  * input:
148  * - nlpi datastructure for solver interface
149  * - problem pointer to store the problem data
150  * - name name of problem, can be NULL
151  */
152 static
153 SCIP_DECL_NLPICREATEPROBLEM(nlpiCreateProblemAll)
154 {
155  SCIP_NLPIDATA* data;
156  int i;
157 
158  assert(nlpi != NULL);
159  assert(problem != NULL);
160 
161  data = SCIPnlpiGetData(nlpi);
162  assert(data != NULL);
163 
164  SCIP_ALLOC( BMSallocBlockMemory(data->blkmem, problem) );
165 
166  /* initialize problem */
167  BMSclearMemory((*problem));
168  SCIP_ALLOC( BMSallocBlockMemoryArray(data->blkmem, &(*problem)->nlpiproblems, data->nnlpis) );
169  (*problem)->nnlpiproblems = data->nnlpis;
170 
171  for( i = 0; i < data->nnlpis; ++i )
172  {
173  assert(data->nlpis[i] != NULL);
174  SCIP_CALL( SCIPnlpiCreateProblem(data->nlpis[i], &((*problem)->nlpiproblems[i]), name) );
175  }
176 
177  return SCIP_OKAY;
178 } /*lint !e715*/
179 
180 /** free a problem instance
181  *
182  * input:
183  * - nlpi datastructure for solver interface
184  * - problem pointer where problem data is stored
185  */
186 static
187 SCIP_DECL_NLPIFREEPROBLEM(nlpiFreeProblemAll)
188 {
189  SCIP_NLPIDATA* data;
190  int i;
191 
192  assert(nlpi != NULL);
193  assert(problem != NULL);
194  assert(*problem != NULL);
195 
196  data = SCIPnlpiGetData(nlpi);
197  assert(data != NULL);
198 
199  for( i = 0; i < data->nnlpis; ++i )
200  {
201  assert(data->nlpis[i] != NULL);
202  SCIP_CALL( SCIPnlpiFreeProblem(data->nlpis[i], &(*problem)->nlpiproblems[i]) );
203  }
204 
205  BMSfreeBlockMemoryArrayNull(data->blkmem, &(*problem)->nlpiproblems, data->nnlpis);
206  BMSfreeBlockMemory(data->blkmem, problem);
207 
208  return SCIP_OKAY;
209 } /*lint !e715*/
210 
211 /** gets pointer to solver-internal problem instance
212  *
213  * to do dirty stuff
214  *
215  * input:
216  * - nlpi datastructure for solver interface
217  * - problem datastructure for problem instance
218  *
219  * return: void pointer to problem instance
220  */
221 static
222 SCIP_DECL_NLPIGETPROBLEMPOINTER(nlpiGetProblemPointerAll)
223 {
224  assert(nlpi != NULL);
225  assert(problem != NULL);
226 
227  return NULL;
228 } /*lint !e715*/
229 
230 /** add variables
231  *
232  * input:
233  * - nlpi datastructure for solver interface
234  * - problem datastructure for problem instance
235  * - nvars number of variables
236  * - lbs lower bounds of variables, can be NULL if -infinity
237  * - ubs upper bounds of variables, can be NULL if +infinity
238  * - varnames names of variables, can be NULL
239  */
240 static
241 SCIP_DECL_NLPIADDVARS( nlpiAddVarsAll )
242 {
243  SCIP_NLPIDATA* nlpidata;
244  int i;
245 
246  nlpidata = SCIPnlpiGetData(nlpi);
247  assert(nlpidata != NULL);
248 
249  for( i = 0; i < nlpidata->nnlpis; ++i )
250  {
251  assert(nlpidata->nlpis[i] != NULL);
252  assert(problem->nlpiproblems[i] != NULL);
253 
254  SCIP_CALL( SCIPnlpiAddVars(nlpidata->nlpis[i], problem->nlpiproblems[i], nvars, lbs, ubs, varnames) );
255  }
256 
257  return SCIP_OKAY;
258 } /*lint !e715*/
259 
260 
261 /** add constraints
262  * quadratic coefficiens: row oriented matrix for each constraint
263  *
264  * input:
265  * - nlpi datastructure for solver interface
266  * - problem datastructure for problem instance
267  * - ncons number of added constraints
268  * - lhss left hand sides of constraints
269  * - rhss right hand sides of constraints
270  * - nlininds number of linear coefficients for each constraint
271  * may be NULL in case of no linear part
272  * - lininds indices of variables for linear coefficients for each constraint
273  * may be NULL in case of no linear part
274  * - linvals values of linear coefficient for each constraint
275  * may be NULL in case of no linear part
276  * - nquadrows number of columns in matrix of quadratic part for each constraint
277  * may be NULL in case of no quadratic part in any constraint
278  * - quadrowidxs indices of variables for which a quadratic part is specified
279  * may be NULL in case of no quadratic part in any constraint
280  * - quadoffsets start index of each rows quadratic coefficients in quadinds[.] and quadvals[.]
281  * indices are given w.r.t. quadrowidxs., i.e., quadoffsets[.][i] gives the start index of row quadrowidxs[.][i] in quadvals[.]
282  * quadoffsets[.][nquadrows[.]] gives length of quadinds[.] and quadvals[.]
283  * entry of array may be NULL in case of no quadratic part
284  * may be NULL in case of no quadratic part in any constraint
285  * - quadinds column indices w.r.t. quadrowidxs, i.e., quadrowidxs[quadinds[.][i]] gives the index of the variable corresponding
286  * to entry i, entry of array may be NULL in case of no quadratic part
287  * may be NULL in case of no quadratic part in any constraint
288  * - quadvals coefficient values
289  * entry of array may be NULL in case of no quadratic part
290  * may be NULL in case of no quadratic part in any constraint
291  * - exprvaridxs indices of variables in expression tree, maps variable indices in expression tree to indices in nlp
292  * entry of array may be NULL in case of no expression tree
293  * may be NULL in case of no expression tree in any constraint
294  * - exprtrees expression tree for nonquadratic part of constraints
295  * entry of array may be NULL in case of no nonquadratic part
296  * may be NULL in case of no nonquadratic part in any constraint
297  * - names of constraints, may be NULL or entries may be NULL
298  */
299 static
300 SCIP_DECL_NLPIADDCONSTRAINTS( nlpiAddConstraintsAll )
301 {
302  SCIP_NLPIDATA* nlpidata;
303  int i;
304 
305  nlpidata = SCIPnlpiGetData(nlpi);
306  assert(nlpidata != NULL);
307 
308  for( i = 0; i < nlpidata->nnlpis; ++i )
309  {
310  assert(nlpidata->nlpis[i] != NULL);
311  assert(problem->nlpiproblems[i] != NULL);
312 
313  SCIP_CALL( SCIPnlpiAddConstraints(nlpidata->nlpis[i], problem->nlpiproblems[i], ncons, lhss, rhss, nlininds,
314  lininds, linvals, nquadelems, quadelems, exprvaridxs, exprtrees, names) );
315  }
316 
317  return SCIP_OKAY;
318 } /*lint !e715*/
319 
320 /** sets or overwrites objective, a minimization problem is expected
321  * May change sparsity pattern.
322  *
323  * input:
324  * - nlpi datastructure for solver interface
325  * - problem datastructure for problem instance
326  * - nlins number of linear variables
327  * - lininds variable indices
328  * may be NULL in case of no linear part
329  * - linvals coefficient values
330  * may be NULL in case of no linear part
331  * - nquadcols number of columns in matrix of quadratic part
332  * - quadcols indices of variables for which a quadratic part is specified
333  * may be NULL in case of no quadratic part
334  * - quadoffsets start index of each rows quadratic coefficients in quadinds and quadvals
335  * quadoffsets[.][nquadcols] gives length of quadinds and quadvals
336  * may be NULL in case of no quadratic part
337  * - quadinds column indices
338  * may be NULL in case of no quadratic part
339  * - quadvals coefficient values
340  * may be NULL in case of no quadratic part
341  * - exprvaridxs indices of variables in expression tree, maps variable indices in expression tree to indices in nlp
342  * may be NULL in case of no expression tree
343  * - exprtree expression tree for nonquadratic part of objective function
344  * may be NULL in case of no nonquadratic part
345  * - constant objective value offset
346  */
347 static
348 SCIP_DECL_NLPISETOBJECTIVE( nlpiSetObjectiveAll )
349 {
350  SCIP_NLPIDATA* nlpidata;
351  int i;
352 
353  nlpidata = SCIPnlpiGetData(nlpi);
354  assert(nlpidata != NULL);
355 
356  for( i = 0; i < nlpidata->nnlpis; ++i )
357  {
358  assert(nlpidata->nlpis[i] != NULL);
359  assert(problem->nlpiproblems[i] != NULL);
360 
361  SCIP_CALL( SCIPnlpiSetObjective(nlpidata->nlpis[i], problem->nlpiproblems[i], nlins, lininds, linvals, nquadelems,
362  quadelems, exprvaridxs, exprtree, constant) );
363  }
364 
365  return SCIP_OKAY;
366 } /*lint !e715*/
367 
368 /** change variable bounds
369  *
370  * input:
371  * - nlpi datastructure for solver interface
372  * - problem datastructure for problem instance
373  * - nvars number of variables to change bounds
374  * - indices indices of variables to change bounds
375  * - lbs new lower bounds
376  * - ubs new upper bounds
377  */
378 static
379 SCIP_DECL_NLPICHGVARBOUNDS( nlpiChgVarBoundsAll )
380 {
381  SCIP_NLPIDATA* nlpidata;
382  int i;
383 
384  nlpidata = SCIPnlpiGetData(nlpi);
385  assert(nlpidata != NULL);
386 
387  for( i = 0; i < nlpidata->nnlpis; ++i )
388  {
389  assert(nlpidata->nlpis[i] != NULL);
390  assert(problem->nlpiproblems[i] != NULL);
391 
392  SCIP_CALL( SCIPnlpiChgVarBounds(nlpidata->nlpis[i], problem->nlpiproblems[i], nvars, indices, lbs, ubs) );
393  }
394 
395  return SCIP_OKAY;
396 } /*lint !e715*/
397 
398 /** change constraint bounds
399  *
400  * input:
401  * - nlpi datastructure for solver interface
402  * - problem datastructure for problem instance
403  * - nconss number of constraints to change sides
404  * - indices indices of constraints to change sides
405  * - lhss new left hand sides
406  * - rhss new right hand sides
407  */
408 static
409 SCIP_DECL_NLPICHGCONSSIDES( nlpiChgConsSidesAll )
410 {
411  SCIP_NLPIDATA* nlpidata;
412  int i;
413 
414  nlpidata = SCIPnlpiGetData(nlpi);
415  assert(nlpidata != NULL);
416 
417  for( i = 0; i < nlpidata->nnlpis; ++i )
418  {
419  assert(nlpidata->nlpis[i] != NULL);
420  assert(problem->nlpiproblems[i] != NULL);
421 
422  SCIP_CALL( SCIPnlpiChgConsSides(nlpidata->nlpis[i], problem->nlpiproblems[i], nconss, indices, lhss, rhss) );
423  }
424 
425  return SCIP_OKAY;
426 } /*lint !e715*/
427 
428 /** delete a set of variables
429  *
430  * input:
431  * - nlpi datastructure for solver interface
432  * - problem datastructure for problem instance
433  * - dstats deletion status of vars; 1 if var should be deleted, 0 if not
434  * - size of the dstats array
435  *
436  * output:
437  * - dstats new position of var, -1 if var was deleted
438  */
439 static
440 SCIP_DECL_NLPIDELVARSET( nlpiDelVarSetAll )
441 {
442  SCIP_NLPIDATA* nlpidata;
443  int* tmpdstats;
444  int i;
445 
446  nlpidata = SCIPnlpiGetData(nlpi);
447  assert(nlpidata != NULL);
448 
449  SCIP_ALLOC( BMSallocBlockMemoryArray(nlpidata->blkmem, &tmpdstats, dstatssize) );
450 
451  for( i = 0; i < nlpidata->nnlpis; ++i )
452  {
453  assert(nlpidata->nlpis[i] != NULL);
454  assert(problem->nlpiproblems[i] != NULL);
455 
456  if( i < nlpidata->nnlpis -1 )
457  {
458  /* restore dstats entries */
459  BMScopyMemoryArray(tmpdstats, dstats, dstatssize);
460 
461  SCIP_CALL( SCIPnlpiDelVarSet(nlpidata->nlpis[i], problem->nlpiproblems[i], tmpdstats, dstatssize) );
462  }
463  else
464  {
465  /* NOTE this works only when all dstats array are the same after calling the nlpidelvarset callback
466  * As long as all solvers use the SCIP NLPI oracle to store the NLP problem data, this is the case.
467  * @TODO Assert that the returned dstats are all the same?
468  */
469  SCIP_CALL( SCIPnlpiDelVarSet(nlpidata->nlpis[i], problem->nlpiproblems[i], dstats, dstatssize) );
470  }
471  }
472 
473  BMSfreeBlockMemoryArray(nlpidata->blkmem, &tmpdstats, dstatssize);
474 
475  return SCIP_OKAY;
476 } /*lint !e715*/
477 
478 /** delete a set of constraints
479  *
480  * input:
481  * - nlpi datastructure for solver interface
482  * - problem datastructure for problem instance
483  * - dstats deletion status of rows; 1 if row should be deleted, 0 if not
484  * - size of the dstats array
485  *
486  * output:
487  * - dstats new position of row, -1 if row was deleted
488  */
489 static
490 SCIP_DECL_NLPIDELCONSSET( nlpiDelConstraintSetAll )
491 {
492  SCIP_NLPIDATA* nlpidata;
493  int* tmpdstats;
494  int i;
495 
496  nlpidata = SCIPnlpiGetData(nlpi);
497  assert(nlpidata != NULL);
498 
499  SCIP_ALLOC( BMSallocBlockMemoryArray(nlpidata->blkmem, &tmpdstats, dstatssize) );
500 
501  for( i = 0; i < nlpidata->nnlpis; ++i )
502  {
503  assert(nlpidata->nlpis[i] != NULL);
504  assert(problem->nlpiproblems[i] != NULL);
505 
506  if( i < nlpidata->nnlpis - 1 )
507  {
508  /* restore dstats entries */
509  BMScopyMemoryArray(tmpdstats, dstats, dstatssize);
510 
511  SCIP_CALL( SCIPnlpiDelConsSet(nlpidata->nlpis[i], problem->nlpiproblems[i], tmpdstats, dstatssize) );
512  }
513  else
514  {
515  /* NOTE this works only when all dstats array are the same after calling the nlpidelconsset callback
516  * As long as all solvers use the SCIP NLPI oracle to store the NLP problem data, this is the case.
517  * @TODO Assert that the returned dstats are all the same?
518  */
519  SCIP_CALL( SCIPnlpiDelConsSet(nlpidata->nlpis[i], problem->nlpiproblems[i], dstats, dstatssize) );
520  }
521 
522  }
523 
524  BMSfreeBlockMemoryArray(nlpidata->blkmem, &tmpdstats, dstatssize);
525 
526  return SCIP_OKAY;
527 } /*lint !e715*/
528 
529 /** changes (or adds) linear coefficients in a constraint or objective
530  *
531  * input:
532  * - nlpi datastructure for solver interface
533  * - problem datastructure for problem instance
534  * - idx index of constraint or -1 for objective
535  * - nvals number of values in linear constraint to change
536  * - varidxs indices of variables which coefficient to change
537  * - vals new values for coefficients
538  */
539 static
540 SCIP_DECL_NLPICHGLINEARCOEFS( nlpiChgLinearCoefsAll )
541 {
542  SCIP_NLPIDATA* nlpidata;
543  int i;
544 
545  nlpidata = SCIPnlpiGetData(nlpi);
546  assert(nlpidata != NULL);
547 
548  for( i = 0; i < nlpidata->nnlpis; ++i )
549  {
550  assert(nlpidata->nlpis[i] != NULL);
551  assert(problem->nlpiproblems[i] != NULL);
552 
553  SCIP_CALL( SCIPnlpiChgLinearCoefs(nlpidata->nlpis[i], problem->nlpiproblems[i], idx, nvals, varidxs, vals) );
554  }
555 
556  return SCIP_OKAY;
557 } /*lint !e715*/
558 
559 /** changes (or adds) coefficients in the quadratic part of a constraint or objective
560  *
561  * input:
562  * - nlpi datastructure for solver interface
563  * - problem datastructure for problem instance
564  * - idx index of constraint or -1 for objective
565  * - nentries number of entries in quadratic matrix to change
566  * - rows row indices of entries in quadratic matrix where values should be changed
567  * - cols column indices of entries in quadratic matrix where values should be changed
568  * - values new values for entries in quadratic matrix
569  */
570 static
571 SCIP_DECL_NLPICHGQUADCOEFS( nlpiChgQuadraticCoefsAll )
572 {
573  SCIP_NLPIDATA* nlpidata;
574  int i;
575 
576  nlpidata = SCIPnlpiGetData(nlpi);
577  assert(nlpidata != NULL);
578 
579  for( i = 0; i < nlpidata->nnlpis; ++i )
580  {
581  assert(nlpidata->nlpis[i] != NULL);
582  assert(problem->nlpiproblems[i] != NULL);
583 
584  SCIP_CALL( SCIPnlpiChgQuadCoefs(nlpidata->nlpis[i], problem->nlpiproblems[i], idx, nquadelems, quadelems) );
585  }
586 
587  return SCIP_OKAY;
588 } /*lint !e715*/
589 
590 /** replaces the expression tree of a constraint or objective
591  *
592  * input:
593  * - nlpi datastructure for solver interface
594  * - problem datastructure for problem instance
595  * - idxcons index of constraint or -1 for objective
596  * - exprvaridxs indices of variables in expression tree, maps variable indices in expression tree to indices in nlp, or NULL
597  * - exprtree new expression tree for constraint or objective, or NULL to only remove previous tree
598  */
599 static
600 SCIP_DECL_NLPICHGEXPRTREE( nlpiChgExprtreeAll )
601 {
602  SCIP_NLPIDATA* nlpidata;
603  int i;
604 
605  nlpidata = SCIPnlpiGetData(nlpi);
606  assert(nlpidata != NULL);
607 
608  for( i = 0; i < nlpidata->nnlpis; ++i )
609  {
610  assert(nlpidata->nlpis[i] != NULL);
611  assert(problem->nlpiproblems[i] != NULL);
612 
613  SCIP_CALL( SCIPnlpiChgExprtree(nlpidata->nlpis[i], problem->nlpiproblems[i], idxcons, exprvaridxs, exprtree) );
614  }
615 
616  return SCIP_OKAY;
617 } /*lint !e715*/
618 
619 /** change one coefficient in the nonlinear part
620  *
621  * input:
622  * - nlpi datastructure for solver interface
623  * - problem datastructure for problem instance
624  * - idxcons index of constraint or -1 for objective
625  * - idxparam index of parameter
626  * - value new value for nonlinear parameter
627  *
628  * return: Error if parameter does not exist
629  */
630 static
631 SCIP_DECL_NLPICHGNONLINCOEF( nlpiChgNonlinCoefAll )
632 {
633  SCIP_NLPIDATA* nlpidata;
634  int i;
635 
636  nlpidata = SCIPnlpiGetData(nlpi);
637  assert(nlpidata != NULL);
638 
639  for( i = 0; i < nlpidata->nnlpis; ++i )
640  {
641  assert(nlpidata->nlpis[i] != NULL);
642  assert(problem->nlpiproblems[i] != NULL);
643 
644  SCIP_CALL( SCIPnlpiChgNonlinCoef(nlpidata->nlpis[i], problem->nlpiproblems[i], idxcons, idxparam, value) );
645  }
646 
647  return SCIP_OKAY;
648 } /*lint !e715*/
649 
650 /** change the constant offset in the objective
651  *
652  * input:
653  * - nlpi datastructure for solver interface
654  * - problem datastructure for problem instance
655  * - objconstant new value for objective constant
656  */
657 static
658 SCIP_DECL_NLPICHGOBJCONSTANT( nlpiChgObjConstantAll )
659 {
660  SCIP_NLPIDATA* nlpidata;
661  int i;
662 
663  nlpidata = SCIPnlpiGetData(nlpi);
664  assert(nlpidata != NULL);
665 
666  for( i = 0; i < nlpidata->nnlpis; ++i )
667  {
668  assert(nlpidata->nlpis[i] != NULL);
669  assert(problem->nlpiproblems[i] != NULL);
670 
671  SCIP_CALL( SCIPnlpiChgObjConstant(nlpidata->nlpis[i], problem->nlpiproblems[i], objconstant) );
672  }
673 
674  return SCIP_OKAY;
675 } /*lint !e715*/
676 
677 /** sets initial guess for primal variables
678  *
679  * input:
680  * - nlpi datastructure for solver interface
681  * - problem datastructure for problem instance
682  * - primalvalues initial primal values for variables, or NULL to clear previous values
683  * - consdualvalues initial dual values for constraints, or NULL to clear previous values
684  * - varlbdualvalues initial dual values for variable lower bounds, or NULL to clear previous values
685  * - varubdualvalues initial dual values for variable upper bounds, or NULL to clear previous values
686  */
687 static
688 SCIP_DECL_NLPISETINITIALGUESS( nlpiSetInitialGuessAll )
689 {
690  SCIP_NLPIDATA* nlpidata;
691  int i;
692 
693  nlpidata = SCIPnlpiGetData(nlpi);
694  assert(nlpidata != NULL);
695 
696  for( i = 0; i < nlpidata->nnlpis; ++i )
697  {
698  assert(nlpidata->nlpis[i] != NULL);
699  assert(problem->nlpiproblems[i] != NULL);
700 
701  SCIP_CALL( SCIPnlpiSetInitialGuess(nlpidata->nlpis[i], problem->nlpiproblems[i], primalvalues, consdualvalues,
702  varlbdualvalues, varubdualvalues) );
703  }
704 
705  return SCIP_OKAY;
706 } /*lint !e715*/
707 
708 /** tries to solve NLP
709  *
710  * input:
711  * - nlpi datastructure for solver interface
712  * - problem datastructure for problem instance
713  */
714 static
715 SCIP_DECL_NLPISOLVE( nlpiSolveAll )
716 {
717  SCIP_NLPIDATA* nlpidata;
718  SCIP_NLPTERMSTAT besttermstat;
719  SCIP_NLPSOLSTAT bestsolstat;
720  SCIP_Real bestsolval;
722  int i;
723 
724  nlpidata = SCIPnlpiGetData(nlpi);
725  assert(nlpidata != NULL);
726 
727  /* use first solver per default */
728  problem->bestidx = 0;
729 
730  /* initialize best solution values */
731  SCIP_CALL( SCIPnlpiGetRealPar(nlpidata->nlpis[0], problem->nlpiproblems[0], SCIP_NLPPAR_INFINITY, &infinity) );
732  besttermstat = SCIP_NLPTERMSTAT_OTHER;
733  bestsolstat = SCIP_NLPSOLSTAT_UNKNOWN;
734  bestsolval = infinity;
735 
736  for( i = 0; i < nlpidata->nnlpis; ++i )
737  {
738  SCIP_NLPTERMSTAT termstat;
739  SCIP_NLPSOLSTAT solstat;
740  SCIP_Real solval;
741  SCIP_Bool update;
742 
743  assert(nlpidata->nlpis[i] != NULL);
744  assert(problem->nlpiproblems[i] != NULL);
745 
746  /* solve NLP */
747  SCIP_CALL( SCIPnlpiSolve(nlpidata->nlpis[i], problem->nlpiproblems[i]) );
748 
749  termstat = SCIPnlpiGetTermstat(nlpidata->nlpis[i], problem->nlpiproblems[i]);
750  solstat = SCIPnlpiGetSolstat(nlpidata->nlpis[i], problem->nlpiproblems[i]);
751  solval = infinity;
752  update = FALSE;
753 
754  /* collect solution value */
755  if( solstat <= SCIP_NLPSOLSTAT_FEASIBLE )
756  {
757  SCIP_CALL( SCIPnlpiGetSolution(nlpidata->nlpis[i], problem->nlpiproblems[i],
758  NULL, NULL, NULL, NULL, &solval) );
759  assert(solval != infinity); /*lint !e777*/
760  }
761 
762  /* better termination status -> update best solver */
763  if( termstat < besttermstat )
764  update = TRUE;
765 
766  /* no feasible solutions have been found so far -> update best solver */
767  else if( bestsolstat >= SCIP_NLPSOLSTAT_LOCINFEASIBLE && solstat <= SCIP_NLPSOLSTAT_LOCINFEASIBLE )
768  update = TRUE;
769 
770  /* use solver with the better solution value */
771  else if( solval < bestsolval )
772  update = TRUE;
773 
774  /* update best solver */
775  if( update )
776  {
777  besttermstat = termstat;
778  bestsolstat = solstat;
779  bestsolval = solval;
780  problem->bestidx = i;
781  }
782 
783 #ifdef SCIP_STATISTIC
784  {
785  SCIP_NLPSTATISTICS stats;
786 
787  SCIP_CALL( SCIPnlpiGetStatistics(nlpidata->nlpis[i], problem->nlpiproblems[i], &stats) );
788 
789  SCIPstatisticMessage("%d solver %s termstat %d solstat %d solval %e iters %d time %g\n",
790  _nnlps, SCIPnlpiGetName(nlpidata->nlpis[i]), termstat, solstat, solval,
792  }
793 #endif
794  }
795 
796 #ifdef SCIP_STATISTIC
797  ++_nnlps;
798 #endif
799 
800  return SCIP_OKAY;
801 } /*lint !e715*/
802 
803 /** gives solution status
804  *
805  * input:
806  * - nlpi datastructure for solver interface
807  * - problem datastructure for problem instance
808  *
809  * return: Solution Status
810  */
811 static
812 SCIP_DECL_NLPIGETSOLSTAT( nlpiGetSolstatAll )
813 {
814  SCIP_NLPIDATA* nlpidata;
815 
816  nlpidata = SCIPnlpiGetData(nlpi);
817  assert(nlpidata != NULL);
818  assert(nlpidata->nlpis != NULL);
819  assert(nlpidata->nlpis[problem->bestidx] != NULL);
820  assert(problem->nlpiproblems != NULL);
821  assert(problem->nlpiproblems[problem->bestidx] != NULL);
822 
823  /* return the solution status of the first nlpi */
824  return SCIPnlpiGetSolstat(nlpidata->nlpis[problem->bestidx], problem->nlpiproblems[problem->bestidx]);
825 }
826 
827 /** gives termination reason
828  *
829  * input:
830  * - nlpi datastructure for solver interface
831  * - problem datastructure for problem instance
832  *
833  * return: Termination Status
834  */
835 static
836 SCIP_DECL_NLPIGETTERMSTAT( nlpiGetTermstatAll )
837 {
838  SCIP_NLPIDATA* nlpidata;
839 
840  nlpidata = SCIPnlpiGetData(nlpi);
841  assert(nlpidata != NULL);
842  assert(nlpidata->nlpis != NULL);
843  assert(nlpidata->nlpis[problem->bestidx] != NULL);
844  assert(problem->nlpiproblems != NULL);
845  assert(problem->nlpiproblems[problem->bestidx] != NULL);
846 
847  /* return the solution status of the first nlpi */
848  return SCIPnlpiGetTermstat(nlpidata->nlpis[problem->bestidx], problem->nlpiproblems[problem->bestidx]);
849 }
850 
851 /** gives primal and dual solution values
852  *
853  * solver can return NULL in dual values if not available
854  * but if solver provides dual values for one side of variable bounds, then it must also provide those for the other side
855  *
856  * for a ranged constraint, the dual variable is positive if the right hand side is active and negative if the left hand side is active
857  *
858  * input:
859  * - nlpi datastructure for solver interface
860  * - problem datastructure for problem instance
861  * - primalvalues buffer to store pointer to array to primal values, or NULL if not needed
862  * - consdualvalues buffer to store pointer to array to dual values of constraints, or NULL if not needed
863  * - varlbdualvalues buffer to store pointer to array to dual values of variable lower bounds, or NULL if not needed
864  * - varubdualvalues buffer to store pointer to array to dual values of variable lower bounds, or NULL if not needed
865  * - objval pointer store the objective value, or NULL if not needed
866  */
867 static
868 SCIP_DECL_NLPIGETSOLUTION( nlpiGetSolutionAll )
869 {
870  SCIP_NLPIDATA* nlpidata;
871 
872  nlpidata = SCIPnlpiGetData(nlpi);
873  assert(nlpidata != NULL);
874  assert(nlpidata->nlpis != NULL);
875  assert(nlpidata->nlpis[problem->bestidx] != NULL);
876  assert(problem->nlpiproblems != NULL);
877  assert(problem->nlpiproblems[problem->bestidx] != NULL);
878 
879  /* return the solution status of the first nlpi */
880  SCIP_CALL( SCIPnlpiGetSolution(nlpidata->nlpis[problem->bestidx], problem->nlpiproblems[problem->bestidx],
881  primalvalues, consdualvalues, varlbdualvalues, varubdualvalues, objval) );
882 
883  return SCIP_OKAY;
884 }
885 
886 /** gives solve statistics
887  *
888  * input:
889  * - nlpi datastructure for solver interface
890  * - problem datastructure for problem instance
891  * - statistics pointer to store statistics
892  *
893  * output:
894  * - statistics solve statistics
895  */
896 static
897 SCIP_DECL_NLPIGETSTATISTICS( nlpiGetStatisticsAll )
898 {
899  SCIP_NLPIDATA* nlpidata;
900 
901  nlpidata = SCIPnlpiGetData(nlpi);
902  assert(nlpidata != NULL);
903  assert(nlpidata->nlpis != NULL);
904  assert(nlpidata->nlpis[problem->bestidx] != NULL);
905  assert(problem->nlpiproblems != NULL);
906  assert(problem->nlpiproblems[problem->bestidx] != NULL);
907 
908  /* collect statistics of the first solver */
909  SCIP_CALL( SCIPnlpiGetStatistics(nlpidata->nlpis[problem->bestidx], problem->nlpiproblems[problem->bestidx],
910  statistics) );
911 
912  return SCIP_OKAY;
913 } /*lint !e715*/
914 
915 /** gives required size of a buffer to store a warmstart object
916  *
917  * input:
918  * - nlpi datastructure for solver interface
919  * - problem datastructure for problem instance
920  * - size pointer to store required size for warmstart buffer
921  *
922  * output:
923  * - size required size for warmstart buffer
924  */
925 static
926 SCIP_DECL_NLPIGETWARMSTARTSIZE( nlpiGetWarmstartSizeAll )
927 {
928  SCIPerrorMessage("method of NLP solver is not implemented\n");
929  return SCIP_OKAY;
930 } /*lint !e715*/
931 
932 /** stores warmstart information in buffer
933  *
934  * required size of buffer should have been obtained by SCIPnlpiGetWarmstartSize before
935  *
936  * input:
937  * - nlpi datastructure for solver interface
938  * - problem datastructure for problem instance
939  * - buffer memory to store warmstart information
940  *
941  * output:
942  * - buffer warmstart information in solver specific data structure
943  */
944 static
945 SCIP_DECL_NLPIGETWARMSTARTMEMO( nlpiGetWarmstartMemoAll )
946 {
947  SCIPerrorMessage("method of NLP solver is not implemented\n");
948  return SCIP_OKAY;
949 } /*lint !e715*/
950 
951 /** sets warmstart information in solver
952  *
953  * write warmstart to buffer
954  *
955  * input:
956  * - nlpi datastructure for solver interface
957  * - problem datastructure for problem instance
958  * - buffer warmstart information
959  */
960 static
961 SCIP_DECL_NLPISETWARMSTARTMEMO( nlpiSetWarmstartMemoAll )
962 {
963  SCIPerrorMessage("method of NLP solver is not implemented\n");
964  return SCIP_OKAY;
965 } /*lint !e715*/
966 
967 /** gets integer parameter of NLP
968  *
969  * input:
970  * - nlpi NLP interface structure
971  * - problem datastructure for problem instance
972  * - type parameter number
973  * - ival pointer to store the parameter value
974  *
975  * output:
976  * - ival parameter value
977  */
978 static
979 SCIP_DECL_NLPIGETINTPAR( nlpiGetIntParAll )
980 {
981  SCIP_NLPIDATA* nlpidata;
982 
983  nlpidata = SCIPnlpiGetData(nlpi);
984  assert(nlpidata != NULL);
985  assert(nlpidata->nlpis != NULL);
986  assert(nlpidata->nlpis[0] != NULL);
987 
988  /* take the first nlpi */
989  SCIP_CALL( SCIPnlpiGetIntPar(nlpidata->nlpis[0], problem->nlpiproblems[0], type, ival) );
990 
991  return SCIP_OKAY;
992 } /*lint !e715*/
993 
994 /** sets integer parameter of NLP
995  *
996  * input:
997  * - nlpi NLP interface structure
998  * - problem datastructure for problem instance
999  * - type parameter number
1000  * - ival parameter value
1001  */
1002 static
1003 SCIP_DECL_NLPISETINTPAR( nlpiSetIntParAll )
1004 {
1005  SCIP_NLPIDATA* nlpidata;
1006  int i;
1007 
1008  nlpidata = SCIPnlpiGetData(nlpi);
1009  assert(nlpidata != NULL);
1010 
1011  for( i = 0; i < nlpidata->nnlpis; ++i )
1012  {
1013  assert(nlpidata->nlpis[i] != NULL);
1014  assert(problem->nlpiproblems[i] != NULL);
1015 
1016  SCIP_CALL( SCIPnlpiSetIntPar(nlpidata->nlpis[i], problem->nlpiproblems[i], type, ival) );
1017  }
1018 
1019  return SCIP_OKAY;
1020 } /*lint !e715*/
1021 
1022 /** gets floating point parameter of NLP
1023  *
1024  * input:
1025  * - nlpi NLP interface structure
1026  * - problem datastructure for problem instance, can be NULL only if type == SCIP_NLPPAR_INFINITY
1027  * - type parameter number
1028  * - dval pointer to store the parameter value
1029  *
1030  * output:
1031  * - dval parameter value
1032  */
1033 static
1034 SCIP_DECL_NLPIGETREALPAR( nlpiGetRealParAll )
1035 {
1036  SCIP_NLPIDATA* nlpidata;
1037 
1038  nlpidata = SCIPnlpiGetData(nlpi);
1039  assert(nlpidata != NULL);
1040  assert(nlpidata->nlpis != NULL);
1041  assert(nlpidata->nlpis[0] != NULL);
1042 
1043  /* take the first nlpi */
1044  SCIP_CALL( SCIPnlpiGetRealPar(nlpidata->nlpis[0], problem->nlpiproblems[0], type, dval) );
1045 
1046  return SCIP_OKAY;
1047 } /*lint !e715*/
1048 
1049 /** sets floating point parameter of NLP
1050  *
1051  * input:
1052  * - nlpi NLP interface structure
1053  * - problem datastructure for problem instance, can be NULL only if type == SCIP_NLPPAR_INFINITY
1054  * - type parameter number
1055  * - dval parameter value
1056  */
1057 static
1058 SCIP_DECL_NLPISETREALPAR( nlpiSetRealParAll )
1059 {
1060  SCIP_NLPIDATA* nlpidata;
1061  int i;
1062 
1063  nlpidata = SCIPnlpiGetData(nlpi);
1064  assert(nlpidata != NULL);
1065 
1066  for( i = 0; i < nlpidata->nnlpis; ++i )
1067  {
1068  assert(nlpidata->nlpis[i] != NULL);
1069 
1070  if( type == SCIP_NLPPAR_INFINITY )
1071  {
1072  SCIP_CALL( SCIPnlpiSetRealPar(nlpidata->nlpis[i], NULL, type, dval) );
1073  }
1074  else
1075  {
1076  assert(problem->nlpiproblems != NULL);
1077  assert(problem->nlpiproblems[i] != NULL);
1078 
1079  SCIP_CALL( SCIPnlpiSetRealPar(nlpidata->nlpis[i], problem->nlpiproblems[i], type, dval) );
1080  }
1081  }
1082 
1083  return SCIP_OKAY;
1084 } /*lint !e715*/
1085 
1086 /** gets string parameter of NLP
1087  *
1088  * input:
1089  * - nlpi NLP interface structure
1090  * - problem datastructure for problem instance
1091  * - type parameter number
1092  * - sval pointer to store the string value, the user must not modify the string
1093  *
1094  * output:
1095  * - sval parameter value
1096  */
1097 static
1098 SCIP_DECL_NLPIGETSTRINGPAR( nlpiGetStringParAll )
1099 {
1100  SCIP_NLPIDATA* nlpidata;
1101 
1102  nlpidata = SCIPnlpiGetData(nlpi);
1103  assert(nlpidata != NULL);
1104  assert(nlpidata->nlpis != NULL);
1105  assert(nlpidata->nlpis[0] != NULL);
1106 
1107  /* take the first nlpi */
1108  SCIP_CALL( SCIPnlpiGetStringPar(nlpidata->nlpis[0], problem->nlpiproblems[0], type, sval) );
1109 
1110  return SCIP_OKAY;
1111 } /*lint !e715*/
1112 
1113 /** sets string parameter of NLP
1114  *
1115  * input:
1116  * - nlpi NLP interface structure
1117  * - problem datastructure for problem instance
1118  * - type parameter number
1119  * - sval parameter value
1120  */
1121 static
1122 SCIP_DECL_NLPISETSTRINGPAR( nlpiSetStringParAll )
1123 {
1124  SCIP_NLPIDATA* nlpidata;
1125  int i;
1126 
1127  nlpidata = SCIPnlpiGetData(nlpi);
1128  assert(nlpidata != NULL);
1129 
1130  for( i = 0; i < nlpidata->nnlpis; ++i )
1131  {
1132  assert(nlpidata->nlpis[i] != NULL);
1133  assert(problem->nlpiproblems[i] != NULL);
1134 
1135  SCIP_CALL( SCIPnlpiSetStringPar(nlpidata->nlpis[i], problem->nlpiproblems[i], type, sval) );
1136  }
1137 
1138  return SCIP_OKAY;
1139 } /*lint !e715*/
1140 
1141 /** sets message handler for message output
1142  *
1143  * input:
1144  * - nlpi NLP interface structure
1145  * - messagehdlr SCIP message handler, or NULL to suppress all output
1146  */
1147 static
1148 SCIP_DECL_NLPISETMESSAGEHDLR( nlpiSetMessageHdlrAll )
1149 {
1150  SCIP_NLPIDATA* nlpidata;
1151  int i;
1152 
1153  assert(nlpi != NULL);
1154 
1155  nlpidata = SCIPnlpiGetData(nlpi);
1156  assert(nlpidata != NULL);
1157 
1158  nlpidata->messagehdlr = messagehdlr;
1159 
1160  for( i = 0; i < nlpidata->nnlpis; ++i )
1161  {
1162  assert(nlpidata->nlpis[i] != NULL);
1163 
1164  SCIP_CALL( SCIPnlpiSetMessageHdlr(nlpidata->nlpis[i], messagehdlr) );
1165  }
1166 
1167  return SCIP_OKAY; /*lint !e527*/
1168 } /*lint !e715*/
1169 
1170 /*
1171  * NLP solver interface specific interface methods
1172  */
1173 
1174 /** create solver interface for All solver */
1176  BMS_BLKMEM* blkmem, /**< block memory data structure */
1177  SCIP_NLPI** nlpi, /**< pointer to buffer for nlpi address */
1178  SCIP_NLPI** nlpis, /**< array containing existing nlpis */
1179  int nnlpis /**< total number of nlpis */
1180  )
1181 {
1182  SCIP_NLPIDATA* nlpidata;
1183  int i;
1184 
1185  assert(blkmem != NULL);
1186  assert(nlpi != NULL);
1187  assert(nlpis != NULL || nnlpis == 0);
1188 
1189  /* the number of nlpis must be >= 2 */
1190  if( nnlpis < 2 )
1191  {
1192  *nlpi = NULL;
1193  return SCIP_OKAY;
1194  }
1195  assert(nlpis != NULL);
1196 
1197  /* create all solver interface data */
1198  SCIP_ALLOC( BMSallocBlockMemory(blkmem, &nlpidata) );
1199  BMSclearMemory(nlpidata);
1200  nlpidata->blkmem = blkmem;
1201 
1202  SCIP_ALLOC( BMSallocBlockMemoryArray(blkmem, &nlpidata->nlpis, nnlpis) );
1203 
1204  /* copy nlpis */
1205  for( i = 0; i < nnlpis; ++i )
1206  {
1207  SCIP_CALL( SCIPnlpiCopy(blkmem, nlpis[i], &nlpidata->nlpis[i]) );
1208  }
1209  nlpidata->nnlpis = nnlpis;
1210 
1211  /* create solver interface */
1212  SCIP_CALL( SCIPnlpiCreate(nlpi,
1214  nlpiCopyAll, nlpiFreeAll, nlpiGetSolverPointerAll,
1215  nlpiCreateProblemAll, nlpiFreeProblemAll, nlpiGetProblemPointerAll,
1216  nlpiAddVarsAll, nlpiAddConstraintsAll, nlpiSetObjectiveAll,
1217  nlpiChgVarBoundsAll, nlpiChgConsSidesAll, nlpiDelVarSetAll, nlpiDelConstraintSetAll,
1218  nlpiChgLinearCoefsAll, nlpiChgQuadraticCoefsAll, nlpiChgExprtreeAll, nlpiChgNonlinCoefAll,
1219  nlpiChgObjConstantAll, nlpiSetInitialGuessAll, nlpiSolveAll, nlpiGetSolstatAll, nlpiGetTermstatAll,
1220  nlpiGetSolutionAll, nlpiGetStatisticsAll,
1221  nlpiGetWarmstartSizeAll, nlpiGetWarmstartMemoAll, nlpiSetWarmstartMemoAll,
1222  nlpiGetIntParAll, nlpiSetIntParAll, nlpiGetRealParAll, nlpiSetRealParAll, nlpiGetStringParAll, nlpiSetStringParAll,
1223  nlpiSetMessageHdlrAll,
1224  nlpidata) );
1225 
1226  return SCIP_OKAY;
1227 }
SCIP_RETCODE SCIPcreateNlpSolverAll(BMS_BLKMEM *blkmem, SCIP_NLPI **nlpi, SCIP_NLPI **nlpis, int nnlpis)
Definition: nlpi_all.c:1175
#define NLPI_DESC
Definition: nlpi_all.c:35
SCIP_RETCODE SCIPnlpiGetRealPar(SCIP_NLPI *nlpi, SCIP_NLPIPROBLEM *problem, SCIP_NLPPARAM type, SCIP_Real *dval)
Definition: nlpi.c:654
#define BMSfreeBlockMemoryArrayNull(mem, ptr, num)
Definition: memory.h:459
SCIP_RETCODE SCIPnlpiAddVars(SCIP_NLPI *nlpi, SCIP_NLPIPROBLEM *problem, int nvars, const SCIP_Real *lbs, const SCIP_Real *ubs, const char **varnames)
Definition: nlpi.c:251
enum SCIP_NlpTermStat SCIP_NLPTERMSTAT
Definition: type_nlpi.h:84
static SCIP_DECL_NLPISETREALPAR(nlpiSetRealParAll)
Definition: nlpi_all.c:1058
static SCIP_DECL_NLPIGETWARMSTARTSIZE(nlpiGetWarmstartSizeAll)
Definition: nlpi_all.c:926
#define infinity
Definition: gastrans.c:71
data definitions for an NLP solver interface
internal methods for NLPI solver interfaces
static SCIP_DECL_NLPICHGNONLINCOEF(nlpiChgNonlinCoefAll)
Definition: nlpi_all.c:631
SCIP_RETCODE SCIPnlpiFree(SCIP_NLPI **nlpi)
Definition: nlpi.c:182
SCIP_NLPIDATA * SCIPnlpiGetData(SCIP_NLPI *nlpi)
Definition: nlpi.c:735
SCIP_RETCODE SCIPnlpiCreateProblem(SCIP_NLPI *nlpi, SCIP_NLPIPROBLEM **problem, const char *name)
Definition: nlpi.c:212
static SCIP_DECL_NLPISETSTRINGPAR(nlpiSetStringParAll)
Definition: nlpi_all.c:1122
SCIP_RETCODE SCIPnlpiChgVarBounds(SCIP_NLPI *nlpi, SCIP_NLPIPROBLEM *problem, int nvars, const int *indices, const SCIP_Real *lbs, const SCIP_Real *ubs)
Definition: nlpi.c:326
#define FALSE
Definition: def.h:73
SCIP_RETCODE SCIPnlpiSetStringPar(SCIP_NLPI *nlpi, SCIP_NLPIPROBLEM *problem, SCIP_NLPPARAM type, const char *sval)
Definition: nlpi.c:705
static SCIP_DECL_NLPICHGEXPRTREE(nlpiChgExprtreeAll)
Definition: nlpi_all.c:600
static SCIP_DECL_NLPISETMESSAGEHDLR(nlpiSetMessageHdlrAll)
Definition: nlpi_all.c:1148
#define TRUE
Definition: def.h:72
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:54
#define SCIPstatisticMessage
Definition: pub_message.h:114
SCIP_RETCODE SCIPnlpiDelVarSet(SCIP_NLPI *nlpi, SCIP_NLPIPROBLEM *problem, int *dstats, int dstatssize)
Definition: nlpi.c:362
SCIP_NLPIPROBLEM ** nlpiproblems
Definition: nlpi_all.c:52
SCIP_RETCODE SCIPnlpiSetRealPar(SCIP_NLPI *nlpi, SCIP_NLPIPROBLEM *problem, SCIP_NLPPARAM type, SCIP_Real dval)
Definition: nlpi.c:672
static SCIP_DECL_NLPICOPY(nlpiCopyAll)
Definition: nlpi_all.c:77
SCIP_RETCODE SCIPnlpiSetObjective(SCIP_NLPI *nlpi, SCIP_NLPIPROBLEM *problem, int nlins, const int *lininds, const SCIP_Real *linvals, int nquadelems, const SCIP_QUADELEM *quadelems, const int *exprvaridxs, const SCIP_EXPRTREE *exprtree, const SCIP_Real constant)
Definition: nlpi.c:301
SCIP_RETCODE SCIPnlpiSetMessageHdlr(SCIP_NLPI *nlpi, SCIP_MESSAGEHDLR *messagehdlr)
Definition: nlpi.c:722
static SCIP_DECL_NLPIGETREALPAR(nlpiGetRealParAll)
Definition: nlpi_all.c:1034
SCIP_RETCODE SCIPnlpiAddConstraints(SCIP_NLPI *nlpi, SCIP_NLPIPROBLEM *problem, int nconss, const SCIP_Real *lhss, const SCIP_Real *rhss, const int *nlininds, int *const *lininds, SCIP_Real *const *linvals, const int *nquadelems, SCIP_QUADELEM *const *quadelems, int *const *exprvaridxs, SCIP_EXPRTREE *const *exprtrees, const char **names)
Definition: nlpi.c:269
SCIP_RETCODE SCIPnlpiGetStatistics(SCIP_NLPI *nlpi, SCIP_NLPIPROBLEM *problem, SCIP_NLPSTATISTICS *statistics)
Definition: nlpi.c:557
static SCIP_DECL_NLPIGETPROBLEMPOINTER(nlpiGetProblemPointerAll)
Definition: nlpi_all.c:222
SCIP_RETCODE SCIPnlpiGetStringPar(SCIP_NLPI *nlpi, SCIP_NLPIPROBLEM *problem, SCIP_NLPPARAM type, const char **sval)
Definition: nlpi.c:688
static SCIP_DECL_NLPIGETSOLSTAT(nlpiGetSolstatAll)
Definition: nlpi_all.c:812
#define NLPI_PRIORITY
Definition: nlpi_all.c:36
#define SCIPerrorMessage
Definition: pub_message.h:55
SCIP_RETCODE SCIPnlpiGetSolution(SCIP_NLPI *nlpi, SCIP_NLPIPROBLEM *problem, SCIP_Real **primalvalues, SCIP_Real **consdualvalues, SCIP_Real **varlbdualvalues, SCIP_Real **varubdualvalues, SCIP_Real *objval)
Definition: nlpi.c:538
struct SCIP_NlpiData SCIP_NLPIDATA
Definition: type_nlpi.h:38
enum SCIP_NlpSolStat SCIP_NLPSOLSTAT
Definition: type_nlpi.h:69
static SCIP_DECL_NLPISOLVE(nlpiSolveAll)
Definition: nlpi_all.c:715
SCIP_NLPSOLSTAT SCIPnlpiGetSolstat(SCIP_NLPI *nlpi, SCIP_NLPIPROBLEM *problem)
Definition: nlpi.c:512
#define NULL
Definition: lpi_spx1.cpp:155
#define NLPI_NAME
Definition: nlpi_all.c:34
static SCIP_DECL_NLPISETOBJECTIVE(nlpiSetObjectiveAll)
Definition: nlpi_all.c:348
SCIP_RETCODE SCIPnlpiDelConsSet(SCIP_NLPI *nlpi, SCIP_NLPIPROBLEM *problem, int *dstats, int dstatssize)
Definition: nlpi.c:379
SCIP_RETCODE SCIPnlpiChgNonlinCoef(SCIP_NLPI *nlpi, SCIP_NLPIPROBLEM *problem, int considx, int paramidx, SCIP_Real value)
Definition: nlpi.c:448
static SCIP_DECL_NLPISETINTPAR(nlpiSetIntParAll)
Definition: nlpi_all.c:1003
#define SCIP_CALL(x)
Definition: def.h:370
static SCIP_DECL_NLPIGETSOLUTION(nlpiGetSolutionAll)
Definition: nlpi_all.c:868
static SCIP_DECL_NLPICHGLINEARCOEFS(nlpiChgLinearCoefsAll)
Definition: nlpi_all.c:540
SCIP_RETCODE SCIPnlpiSetInitialGuess(SCIP_NLPI *nlpi, SCIP_NLPIPROBLEM *problem, SCIP_Real *primalvalues, SCIP_Real *consdualvalues, SCIP_Real *varlbdualvalues, SCIP_Real *varubdualvalues)
Definition: nlpi.c:480
static SCIP_DECL_NLPIGETSTATISTICS(nlpiGetStatisticsAll)
Definition: nlpi_all.c:897
SCIP_RETCODE SCIPnlpiChgExprtree(SCIP_NLPI *nlpi, SCIP_NLPIPROBLEM *problem, int idxcons, const int *exprvaridxs, const SCIP_EXPRTREE *exprtree)
Definition: nlpi.c:431
#define BMSfreeBlockMemory(mem, ptr)
Definition: memory.h:456
public data structures and miscellaneous methods
#define SCIP_Bool
Definition: def.h:70
#define BMSallocBlockMemoryArray(mem, ptr, num)
Definition: memory.h:445
int SCIPnlpStatisticsGetNIterations(SCIP_NLPSTATISTICS *statistics)
Definition: nlpi.c:818
static SCIP_DECL_NLPIDELCONSSET(nlpiDelConstraintSetAll)
Definition: nlpi_all.c:490
#define BMSfreeBlockMemoryArray(mem, ptr, num)
Definition: memory.h:458
SCIP_RETCODE SCIPnlpiSetIntPar(SCIP_NLPI *nlpi, SCIP_NLPIPROBLEM *problem, SCIP_NLPPARAM type, int ival)
Definition: nlpi.c:637
static SCIP_DECL_NLPIGETSTRINGPAR(nlpiGetStringParAll)
Definition: nlpi_all.c:1098
static SCIP_DECL_NLPICHGOBJCONSTANT(nlpiChgObjConstantAll)
Definition: nlpi_all.c:658
static SCIP_DECL_NLPIADDCONSTRAINTS(nlpiAddConstraintsAll)
Definition: nlpi_all.c:300
static SCIP_DECL_NLPICHGQUADCOEFS(nlpiChgQuadraticCoefsAll)
Definition: nlpi_all.c:571
SCIP_RETCODE SCIPnlpiSolve(SCIP_NLPI *nlpi, SCIP_NLPIPROBLEM *problem)
Definition: nlpi.c:498
#define BMScopyMemoryArray(ptr, source, num)
Definition: memory.h:126
static SCIP_DECL_NLPIGETSOLVERPOINTER(nlpiGetSolverPointerAll)
Definition: nlpi_all.c:138
ALL NLP interface.
#define BMSclearMemory(ptr)
Definition: memory.h:121
static SCIP_DECL_NLPIGETTERMSTAT(nlpiGetTermstatAll)
Definition: nlpi_all.c:836
SCIP_RETCODE SCIPnlpiChgLinearCoefs(SCIP_NLPI *nlpi, SCIP_NLPIPROBLEM *problem, const int idx, int nvals, const int *varidxs, const SCIP_Real *vals)
Definition: nlpi.c:396
static SCIP_DECL_NLPICREATEPROBLEM(nlpiCreateProblemAll)
Definition: nlpi_all.c:153
SCIP_RETCODE SCIPnlpiCreate(SCIP_NLPI **nlpi, 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_NLPICHGQUADCOEFS((*nlpichgquadcoefs)), SCIP_DECL_NLPICHGEXPRTREE((*nlpichgexprtree)), SCIP_DECL_NLPICHGNONLINCOEF((*nlpichgnonlincoef)), 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_DECL_NLPIGETWARMSTARTSIZE((*nlpigetwarmstartsize)), SCIP_DECL_NLPIGETWARMSTARTMEMO((*nlpigetwarmstartmemo)), SCIP_DECL_NLPISETWARMSTARTMEMO((*nlpisetwarmstartmemo)), SCIP_DECL_NLPIGETINTPAR((*nlpigetintpar)), SCIP_DECL_NLPISETINTPAR((*nlpisetintpar)), SCIP_DECL_NLPIGETREALPAR((*nlpigetrealpar)), SCIP_DECL_NLPISETREALPAR((*nlpisetrealpar)), SCIP_DECL_NLPIGETSTRINGPAR((*nlpigetstringpar)), SCIP_DECL_NLPISETSTRINGPAR((*nlpisetstringpar)), SCIP_DECL_NLPISETMESSAGEHDLR((*nlpisetmessagehdlr)), SCIP_NLPIDATA *nlpidata)
Definition: nlpi.c:41
static SCIP_DECL_NLPISETINITIALGUESS(nlpiSetInitialGuessAll)
Definition: nlpi_all.c:688
SCIP_Real SCIPnlpStatisticsGetTotalTime(SCIP_NLPSTATISTICS *statistics)
Definition: nlpi.c:828
static SCIP_DECL_NLPIFREE(nlpiFreeAll)
Definition: nlpi_all.c:107
static SCIP_DECL_NLPISETWARMSTARTMEMO(nlpiSetWarmstartMemoAll)
Definition: nlpi_all.c:961
SCIP_RETCODE SCIPnlpiChgConsSides(SCIP_NLPI *nlpi, SCIP_NLPIPROBLEM *problem, int nconss, const int *indices, const SCIP_Real *lhss, const SCIP_Real *rhss)
Definition: nlpi.c:344
SCIP_RETCODE SCIPnlpiChgObjConstant(SCIP_NLPI *nlpi, SCIP_NLPIPROBLEM *problem, SCIP_Real objconstant)
Definition: nlpi.c:465
static SCIP_DECL_NLPIGETWARMSTARTMEMO(nlpiGetWarmstartMemoAll)
Definition: nlpi_all.c:945
SCIP_RETCODE SCIPnlpiFreeProblem(SCIP_NLPI *nlpi, SCIP_NLPIPROBLEM **problem)
Definition: nlpi.c:225
public methods for message output
#define SCIP_Real
Definition: def.h:163
static SCIP_DECL_NLPICHGVARBOUNDS(nlpiChgVarBoundsAll)
Definition: nlpi_all.c:379
SCIP_NLPTERMSTAT SCIPnlpiGetTermstat(SCIP_NLPI *nlpi, SCIP_NLPIPROBLEM *problem)
Definition: nlpi.c:524
static SCIP_DECL_NLPIFREEPROBLEM(nlpiFreeProblemAll)
Definition: nlpi_all.c:187
static SCIP_DECL_NLPIGETINTPAR(nlpiGetIntParAll)
Definition: nlpi_all.c:979
#define BMSallocBlockMemory(mem, ptr)
Definition: memory.h:443
static SCIP_DECL_NLPICHGCONSSIDES(nlpiChgConsSidesAll)
Definition: nlpi_all.c:409
struct BMS_BlkMem BMS_BLKMEM
Definition: memory.h:429
static SCIP_DECL_NLPIDELVARSET(nlpiDelVarSetAll)
Definition: nlpi_all.c:440
SCIP_RETCODE SCIPnlpiChgQuadCoefs(SCIP_NLPI *nlpi, SCIP_NLPIPROBLEM *problem, int idx, int nquadelems, const SCIP_QUADELEM *quadelems)
Definition: nlpi.c:414
#define SCIP_ALLOC(x)
Definition: def.h:381
SCIP_RETCODE SCIPnlpiCopy(BMS_BLKMEM *blkmem, SCIP_NLPI *sourcenlpi, SCIP_NLPI **targetnlpi)
Definition: nlpi.c:166
SCIP_RETCODE SCIPnlpiGetIntPar(SCIP_NLPI *nlpi, SCIP_NLPIPROBLEM *problem, SCIP_NLPPARAM type, int *ival)
Definition: nlpi.c:620
const char * SCIPnlpiGetName(SCIP_NLPI *nlpi)
Definition: nlpi.c:745
static SCIP_DECL_NLPIADDVARS(nlpiAddVarsAll)
Definition: nlpi_all.c:241