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