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