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