Scippy

SCIP

Solving Constraint Integer Programs

sepa_convexproj.c
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program and library */
4 /* SCIP --- Solving Constraint Integer Programs */
5 /* */
6 /* Copyright (C) 2002-2021 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SCIP; see the file COPYING. If not visit scipopt.org. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file sepa_convexproj.c
17  * @ingroup DEFPLUGINS_SEPA
18  * @brief convexproj separator
19  * @author Felipe Serrano
20  *
21  * @todo should separator only be run when SCIPallColsInLP is true?
22  * @todo check if it makes sense to implement the copy callback
23  * @todo add SCIPisStopped(scip) to the condition of time consuming loops
24  */
25 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
26 
27 #include <assert.h>
28 #include <string.h>
29 
30 #include "blockmemshell/memory.h"
31 #include "scip/scip_expr.h"
32 #include "scip/scip_nlpi.h"
33 #include "scip/expr_varidx.h"
34 #include "scip/expr_pow.h"
35 #include "scip/expr_sum.h"
36 #include "scip/pub_message.h"
37 #include "scip/pub_misc.h"
38 #include "scip/pub_nlp.h"
39 #include "scip/pub_sepa.h"
40 #include "scip/pub_var.h"
41 #include "scip/scip_cut.h"
42 #include "scip/scip_general.h"
43 #include "scip/scip_lp.h"
44 #include "scip/scip_mem.h"
45 #include "scip/scip_message.h"
46 #include "scip/scip_nlp.h"
47 #include "scip/scip_numerics.h"
48 #include "scip/scip_param.h"
49 #include "scip/scip_prob.h"
50 #include "scip/scip_sepa.h"
51 #include "scip/scip_sol.h"
52 #include "scip/scip_solvingstats.h"
53 #include "scip/scip_timing.h"
54 #include "scip/scip_tree.h"
55 #include "scip/sepa_convexproj.h"
56 #include <string.h>
57 
58 
59 #define SEPA_NAME "convexproj"
60 #define SEPA_DESC "separate at projection of point onto convex region"
61 #define SEPA_PRIORITY 0
62 #define SEPA_FREQ -1
63 #define SEPA_MAXBOUNDDIST 1.0
64 #define SEPA_USESSUBSCIP FALSE /**< does the separator use a secondary SCIP instance? */
65 #define SEPA_DELAY TRUE /**< should separation method be delayed, if other separators found cuts? */
66 
67 #define DEFAULT_MAXDEPTH -1 /**< maximum depth at which the separator is applied; -1 means no limit */
68 #define DEFAULT_NLPITERLIM 250 /**< default NLP iteration limit */
69 
70 #define VIOLATIONFAC 100 /**< points regarded violated if max violation > VIOLATIONFAC*SCIPfeastol() */
71 
72 /*
73  * Data structures
74  */
75 
76 /** side that makes an nlrow convex */
78 {
79  LHS = 0, /**< left hand side */
80  RHS = 1 /**< right hand side */
81 };
82 typedef enum ConvexSide CONVEXSIDE;
83 
84 /** separator data
85  * it keeps the nlpi which represents the projection problem (see sepa_convexproj.h); it also keeps the convex nlrows
86  * and the side which actually makes them convex; when separating, we use the nlpi to compute the projection and then
87  * the convex nlrows to compute the actual gradient cuts */
88 struct SCIP_SepaData
89 {
90  SCIP_NLPI* nlpi; /**< nlpi used to create the nlpi problem */
91  SCIP_NLPIPROBLEM* nlpiprob; /**< nlpi problem representing the convex NLP relaxation */
92  SCIP_VAR** nlpivars; /**< array containing all variables of the nlpi */
93  SCIP_HASHMAP* var2nlpiidx; /**< mapping between variables and nlpi indices */
94  int nlpinvars; /**< total number of nlpi variables */
95 
96  SCIP_Bool skipsepa; /**< should separator be skipped? */
97 
98  SCIP_NLROW** nlrows; /**< convex nlrows */
99  CONVEXSIDE* convexsides; /**< which sides make the nlrows convex */
100  SCIP_Real* constraintviolation;/**< array storing the violation of constraint by current solution; 0.0 if it is not violated */
101  int nnlrows; /**< total number of nlrows */
102  int nlrowssize; /**< memory allocated for nlrows, convexsides and nlrowsidx */
103 
104  /* parameter */
105  int nlpiterlimit; /**< iteration limit of NLP solver; 0 for no limit */
106  int maxdepth; /**< maximal depth at which the separator is applied */
107 
108  int ncuts; /**< number of cuts generated */
109 };
110 
111 
112 /*
113  * Local methods
114  */
115 
116 /** clears the sepadata data */
117 static
119  SCIP* scip, /**< SCIP data structure */
120  SCIP_SEPADATA* sepadata /**< separator data */
121  )
122 {
123  assert(sepadata != NULL);
124 
125  /* nlrowssize gets allocated first and then its decided whether to create the nlpiprob */
126  if( sepadata->nlrowssize > 0 )
127  {
128  SCIPfreeBlockMemoryArray(scip, &sepadata->constraintviolation, sepadata->nlrowssize);
129  SCIPfreeBlockMemoryArray(scip, &sepadata->convexsides, sepadata->nlrowssize);
130  SCIPfreeBlockMemoryArray(scip, &sepadata->nlrows, sepadata->nlrowssize);
131  sepadata->nlrowssize = 0;
132  }
133 
134  if( sepadata->nlpiprob != NULL )
135  {
136  assert(sepadata->nlpi != NULL);
137 
138  SCIPfreeBlockMemoryArray(scip, &sepadata->nlpivars, sepadata->nlpinvars);
139 
140  SCIPhashmapFree(&sepadata->var2nlpiidx);
141  SCIP_CALL( SCIPfreeNlpiProblem(scip, sepadata->nlpi, &sepadata->nlpiprob) );
142 
143  sepadata->nlpinvars = 0;
144  sepadata->nnlrows = 0;
145  }
146  assert(sepadata->nlpinvars == 0);
147  assert(sepadata->nnlrows == 0);
148  assert(sepadata->nlrowssize == 0);
149 
150  sepadata->skipsepa = FALSE;
151 
152  return SCIP_OKAY;
153 }
154 
155 /** computes gradient cut (linearization) of nlrow at projection */
156 static
158  SCIP* scip, /**< SCIP data structure */
159  SCIP_SEPA* sepa, /**< the cut separator itself */
160  SCIP_SOL* projection, /**< point where we compute gradient cut */
161  SCIP_NLROW* nlrow, /**< constraint for which we generate gradient cut */
162  CONVEXSIDE convexside, /**< which side makes the nlrow convex */
163  SCIP_Real activity, /**< activity of constraint at projection */
164  SCIP_EXPRITER* exprit, /**< expression iterator that can be used */
165  SCIP_ROW** row /**< storage for cut */
166  )
167 {
168  char rowname[SCIP_MAXSTRLEN];
169  SCIP_SEPADATA* sepadata;
170  SCIP_Real gradx0; /* <grad f(x_0), x_0> */
171  SCIP_EXPR* expr;
172  int i;
173 
174  assert(scip != NULL);
175  assert(sepa != NULL);
176  assert(nlrow != NULL);
177  assert(row != NULL);
178 
179  sepadata = SCIPsepaGetData(sepa);
180 
181  assert(sepadata != NULL);
182 
183  gradx0 = 0.0;
184 
185  /* an nlrow has a linear part and expression; ideally one would just build the gradient but we
186  * do not know if the different parts share variables or not, so we can't just build the gradient; for this reason
187  * we create the row right away and compute the gradients of each part independently and add them to the row; the
188  * row takes care to add coeffs corresponding to the same variable when they appear in different parts of the nlrow
189  * NOTE: a gradient cut is globally valid whenever the constraint from which it is deduced is globally valid; since
190  * we build the convex relaxation using only globally valid constraints, the cuts are globally valid
191  */
192  (void) SCIPsnprintf(rowname, SCIP_MAXSTRLEN, "proj_cut_%s_%u", SCIPnlrowGetName(nlrow), ++(sepadata->ncuts));
193  SCIP_CALL( SCIPcreateEmptyRowSepa(scip, row, sepa, rowname, -SCIPinfinity(scip), SCIPinfinity(scip), TRUE, FALSE ,
194  TRUE) );
195 
196  SCIP_CALL( SCIPcacheRowExtensions(scip, *row) );
197 
198  /* linear part */
199  for( i = 0; i < SCIPnlrowGetNLinearVars(nlrow); i++ )
200  {
201  gradx0 += SCIPgetSolVal(scip, projection, SCIPnlrowGetLinearVars(nlrow)[i]) * SCIPnlrowGetLinearCoefs(nlrow)[i];
202  SCIP_CALL( SCIPaddVarToRow(scip, *row, SCIPnlrowGetLinearVars(nlrow)[i], SCIPnlrowGetLinearCoefs(nlrow)[i]) );
203  }
204 
205  expr = SCIPnlrowGetExpr(nlrow);
206  assert(expr != NULL);
207 
208  SCIP_CALL( SCIPevalExprGradient(scip, expr, projection, 0L) );
209 
211  for( ; !SCIPexpriterIsEnd(exprit); expr = SCIPexpriterGetNext(exprit) ) /*lint !e441*/ /*lint !e440*/
212  {
213  SCIP_Real grad;
214  SCIP_VAR* var;
215 
216  if( !SCIPisExprVar(scip, expr) )
217  continue;
218 
219  grad = SCIPexprGetDerivative(expr);
220  var = SCIPgetVarExprVar(expr);
221  assert(var != NULL);
222 
223  gradx0 += grad * SCIPgetSolVal(scip, projection, var);
224  SCIP_CALL( SCIPaddVarToRow(scip, *row, var, grad) );
225  }
226 
227  SCIP_CALL( SCIPflushRowExtensions(scip, *row) );
228 
229  SCIPdebugPrintf("gradient: ");
230  SCIPdebug( SCIP_CALL( SCIPprintRow(scip, *row, NULL) ) );
231  SCIPdebugPrintf("gradient dot x_0: %g\n", gradx0);
232 
233  /* gradient cut is f(x_0) - <grad f(x_0), x_0> + <grad f(x_0), x> <= rhs or >= lhs */
234  if( convexside == RHS )
235  {
236  assert(!SCIPisInfinity(scip, SCIPnlrowGetRhs(nlrow)));
237  SCIP_CALL( SCIPchgRowRhs(scip, *row, SCIPnlrowGetRhs(nlrow) - activity + gradx0) );
238  }
239  else
240  {
241  assert(convexside == LHS);
242  assert(!SCIPisInfinity(scip, -SCIPnlrowGetLhs(nlrow)));
243  SCIP_CALL( SCIPchgRowLhs(scip, *row, SCIPnlrowGetLhs(nlrow) - activity + gradx0) );
244  }
245 
246  SCIPdebugPrintf("gradient cut: ");
247  SCIPdebug( SCIP_CALL( SCIPprintRow(scip, *row, NULL) ) );
248 
249  return SCIP_OKAY;
250 }
251 
252 /** set quadratic part of objective function: \f$ \sum_i x_i^2 \f$
253  *
254  * the objective function is \f$ ||x - x_0||^2 \f$,
255  * where \f$ x_0 \f$ is the point to separate; the only part that changes is the term \f$ -2 \langle x_0, x \rangle \f$
256  * which is linear and is set every time we want to separate a point, see separateCuts()
257  */
258 static
260  SCIP* scip, /**< SCIP data structure */
261  SCIP_SEPADATA* sepadata /**< the cut separator data */
262  )
263 {
264  SCIP_EXPR* exprsum;
265  SCIP_EXPR** exprspow;
266  int i;
267 
268  assert(scip != NULL);
269  assert(sepadata != NULL);
270  assert(sepadata->nlpi != NULL);
271  assert(sepadata->nlpiprob != NULL);
272  assert(sepadata->var2nlpiidx != NULL);
273  assert(sepadata->nlpinvars > 0);
274 
275  SCIP_CALL( SCIPallocBufferArray(scip, &exprspow, sepadata->nlpinvars) );
276  for( i = 0; i < sepadata->nlpinvars; i++ )
277  {
278  SCIP_VAR* var;
279  SCIP_EXPR* varexpr;
280 
281  var = sepadata->nlpivars[i];
282  assert(SCIPhashmapExists(sepadata->var2nlpiidx, (void*)var) );
283 
284  SCIP_CALL( SCIPcreateExprVaridx(scip, &varexpr, SCIPhashmapGetImageInt(sepadata->var2nlpiidx, (void*)var), NULL, NULL) );
285  SCIP_CALL( SCIPcreateExprPow(scip, &exprspow[i], varexpr, 2.0, NULL, NULL) );
286  SCIP_CALL( SCIPreleaseExpr(scip, &varexpr) );
287  }
288 
289  SCIP_CALL( SCIPcreateExprSum(scip, &exprsum, sepadata->nlpinvars, exprspow, NULL, 0.0, NULL, NULL) );
290 
291  /* set quadratic part of objective function */
292  SCIP_CALL( SCIPsetNlpiObjective(scip, sepadata->nlpi, sepadata->nlpiprob, 0, NULL, NULL, exprsum, 0.0) );
293 
294  /* free memory */
295  SCIP_CALL( SCIPreleaseExpr(scip, &exprsum) );
296  for( i = sepadata->nlpinvars-1; i >= 0; --i )
297  {
298  SCIP_CALL( SCIPreleaseExpr(scip, &exprspow[i]) );
299  }
300  SCIPfreeBufferArray(scip, &exprspow);
301 
302  return SCIP_OKAY;
303 }
304 
305 /** projects sol onto convex relaxation (stored in sepadata) and tries to generate gradient cuts at the projection
306  *
307  * it generates cuts only for the constraints that were violated by the LP solution and are now active or still
308  * violated (in case we don't solve to optimality).
309  * @todo: store a feasible solution if one is found to use as warmstart
310  */
311 static
313  SCIP* scip, /**< SCIP data structure */
314  SCIP_SEPA* sepa, /**< the cut separator itself */
315  SCIP_SOL* sol, /**< solution that should be separated */
316  SCIP_RESULT* result /**< pointer to store the result of the separation call */
317  )
318 {
319  SCIP_SEPADATA* sepadata;
320  SCIP_SOL* projection;
321  SCIP_Real* linvals;
322  SCIP_Real* nlpisol;
323  int nlpinvars;
324  int i;
325  int* lininds;
326  SCIP_Bool nlpunstable;
327  SCIP_EXPRITER* exprit;
328 
329  nlpunstable = FALSE;
330 
331  assert(sepa != NULL);
332 
333  sepadata = SCIPsepaGetData(sepa);
334 
335  assert(result != NULL);
336  assert(sepadata != NULL);
337  assert(sepadata->nnlrows > 0);
338  assert(sepadata->nlpi != NULL);
339  assert(sepadata->nlpinvars > 0);
340  assert(sepadata->nlrows != NULL);
341  assert(sepadata->nlpiprob != NULL);
342  assert(sepadata->var2nlpiidx != NULL);
343  assert(sepadata->convexsides != NULL);
344  assert(sepadata->constraintviolation != NULL);
345 
346  nlpinvars = sepadata->nlpinvars;
347  /* set linear part of objective function: \norm(x - x^0)^2 = \norm(x)^2 - \sum 2 * x_i * x^0_i + const
348  * we ignore the constant; x0 is `sol`
349  */
350  SCIP_CALL( SCIPallocBufferArray(scip, &linvals, nlpinvars) );
351  SCIP_CALL( SCIPallocBufferArray(scip, &lininds, nlpinvars) );
352  for( i = 0; i < nlpinvars; i++ )
353  {
354  SCIP_VAR* var;
355 
356  var = sepadata->nlpivars[i];
357  assert(SCIPhashmapExists(sepadata->var2nlpiidx, (void*)var) );
358 
359  lininds[i] = SCIPhashmapGetImageInt(sepadata->var2nlpiidx, (void*)var);
360  linvals[i] = - 2.0 * SCIPgetSolVal(scip, sol, var);
361 
362  /* if coefficient is too large, don't separate */
363  if( SCIPisHugeValue(scip, REALABS(linvals[i])) )
364  {
365  SCIPdebugMsg(scip, "Don't separate points too close to infinity\n");
366  goto CLEANUP;
367  }
368  }
369 
370  /* set linear part of objective function */
371  SCIP_CALL( SCIPchgNlpiLinearCoefs(scip, sepadata->nlpi, sepadata->nlpiprob, -1, nlpinvars, lininds, linvals) );
372 
373  /* compute the projection onto the convex NLP relaxation */
374  SCIP_CALL( SCIPsolveNlpi(scip, sepadata->nlpi, sepadata->nlpiprob,
375  .iterlimit = sepadata->nlpiterlimit > 0 ? sepadata->nlpiterlimit : INT_MAX,
376  .feastol = SCIPfeastol(scip) / 10.0, /* use tighter tolerances for the NLP solver */
377  .opttol = MAX(SCIPfeastol(scip), SCIPdualfeastol(scip))) ); /*lint !e666*/
378  SCIPdebugMsg(scip, "NLP solstat = %d\n", SCIPgetNlpiSolstat(scip, sepadata->nlpi, sepadata->nlpiprob));
379 
380  /* if solution is feasible, add cuts */
381  switch( SCIPgetNlpiSolstat(scip, sepadata->nlpi, sepadata->nlpiprob) )
382  {
385  /* @todo: if solution is optimal, we might as well add the cut <x - P(x_0), x_0 - P(x_0)> <= 0
386  * even though this cut is implied by all the gradient cuts of the rows active at the projection,
387  * we do not add them all (only the gradient cuts of constraints that violated the LP solution */
389  /* generate cuts for violated constraints (at sol) that are active or still violated at the projection, since
390  * a suboptimal solution or numerical issues could give a solution of the projection problem where constraints
391  * are not active; if the solution of the projection problem is in the interior of the region, we do nothing
392  */
393 
394  /* get solution: build SCIP_SOL out of nlpi sol */
395  SCIP_CALL( SCIPgetNlpiSolution(scip, sepadata->nlpi, sepadata->nlpiprob, &nlpisol, NULL, NULL, NULL, NULL) );
396  assert(nlpisol != NULL);
397 
398  SCIP_CALL( SCIPcreateSol(scip, &projection, NULL) );
399  for( i = 0; i < nlpinvars; i++ )
400  {
401  SCIP_VAR* var;
402 
403  var = sepadata->nlpivars[i];
404  assert(SCIPhashmapExists(sepadata->var2nlpiidx, (void*)var) );
405 
406  SCIP_CALL( SCIPsetSolVal(scip, projection, var,
407  nlpisol[SCIPhashmapGetImageInt(sepadata->var2nlpiidx, (void *)var)]) );
408  }
409  SCIPdebug( SCIPprintSol(scip, projection, NULL, TRUE) );
410 
411  /** @todo this could just be created inside generateCut and the extra argument removed */
412  SCIP_CALL( SCIPcreateExpriter(scip, &exprit) );
413 
414  /* check for active or violated constraints */
415  for( i = 0; i < sepadata->nnlrows; ++i )
416  {
417  SCIP_NLROW* nlrow;
418  CONVEXSIDE convexside;
419  SCIP_Real activity;
420 
421  /* ignore constraints that are not violated by `sol` */
422  if( SCIPisFeasZero(scip, sepadata->constraintviolation[i]) )
423  continue;
424 
425  convexside = sepadata->convexsides[i];
426  nlrow = sepadata->nlrows[i];
427  assert(nlrow != NULL);
428 
429  /* check for currently active constraints at projected point */
430  SCIP_CALL( SCIPgetNlRowSolActivity(scip, nlrow, projection, &activity) );
431 
432  SCIPdebugMsg(scip, "NlRow activity at nlpi solution: %g <= %g <= %g\n", SCIPnlrowGetLhs(nlrow), activity,
433  SCIPnlrowGetRhs(nlrow) );
434 
435  /* if nlrow is active or violates the projection, build gradient cut at projection */
436  if( (convexside == RHS && SCIPisFeasGE(scip, activity, SCIPnlrowGetRhs(nlrow)))
437  || (convexside == LHS && SCIPisFeasLE(scip, activity, SCIPnlrowGetLhs(nlrow))) )
438  {
439  SCIP_ROW* row;
440 
441  SCIP_CALL( generateCut(scip, sepa, projection, nlrow, convexside, activity, exprit,
442  &row) );
443 
444  SCIPdebugMsg(scip, "active or violated nlrow: (sols vio: %e)\n", sepadata->constraintviolation[i]);
445  SCIPdebug( SCIP_CALL( SCIPprintNlRow(scip, nlrow, NULL) ) );
446  SCIPdebugMsg(scip, "cut with efficacy %g generated\n", SCIPgetCutEfficacy(scip, sol, row));
447  SCIPdebug( SCIPprintRow(scip, row, NULL) );
448 
449  /* add cut if it is efficacious for the point we want to separate (sol) */
450  if( SCIPisCutEfficacious(scip, sol, row) )
451  {
452  SCIP_Bool infeasible;
453 
454  SCIP_CALL( SCIPaddRow(scip, row, FALSE, &infeasible) );
455 
456  if( infeasible )
457  {
458  *result = SCIP_CUTOFF;
459  SCIP_CALL( SCIPreleaseRow(scip, &row) );
460  break;
461  }
462  else
463  {
464  *result = SCIP_SEPARATED;
465  }
466  }
467 
468  /* release the row */
469  SCIP_CALL( SCIPreleaseRow(scip, &row) );
470  }
471  }
472 
473  SCIPfreeExpriter(&exprit);
474 
475 #ifdef SCIP_DEBUG
476  {
477  SCIP_Real distance;
478 
479  /* compute distance between LP sol and its projection (only makes sense when it is optimal) */
480  distance = 0.0;
481  for( i = 0; i < SCIPgetNNLPVars(scip); ++i )
482  {
483  SCIP_VAR* var;
484 
485  var = SCIPgetNLPVars(scip)[i];
486  assert(var != NULL);
487 
488  /* assert NLP solution is within the bounds of the variable (only make sense when sol is optimal) */
489  if( !SCIPisInfinity(scip, -SCIPvarGetLbLocal(var)) )
490  assert(SCIPisFeasLE(scip, SCIPvarGetLbLocal(var), SCIPvarGetNLPSol(var)));
491  if( !SCIPisInfinity(scip, SCIPvarGetUbLocal(var)) )
492  assert(SCIPisFeasLE(scip, SCIPvarGetNLPSol(var), SCIPvarGetUbLocal(var)));
493 
494  /*SCIPdebugMsg(scip, "NLP sol (LP sol): %s = %f (%g)\n", SCIPvarGetName(var),
495  * SCIPvarGetNLPSol(var), SCIPgetSolVal(scip, sol, var));
496  */
497 
498  distance += SQR( SCIPvarGetNLPSol(var) - SCIPgetSolVal(scip, sol, var) );
499  }
500 
501  SCIPdebugMsg(scip, "NLP objval: %e, distance: %e\n", SCIPgetNLPObjval(scip), distance);
502  }
503 #endif
504 
505  /* free solution */
506  SCIP_CALL( SCIPfreeSol(scip, &projection) );
507  break;
508 
511  /* fallthrough;
512  * @todo: write what it means to be locinfeasible and why it can't be used to cutoff the node */
514  /* unknown... assume numerical issues */
515  nlpunstable = TRUE;
516  break;
517 
519  default:
520  SCIPerrorMessage("Projection NLP is not unbounded by construction, should not get here!\n");
521  SCIPABORT();
522  nlpunstable = TRUE;
523  }
524 
525  /* if nlp is detected to be unstable, don't try to separate again */
526  if( nlpunstable )
527  {
528  /* @todo: maybe change objective function to \sum [(x_i - x_i^*)/max(|x_i^*|, 1)]^2
529  * or some other scaling when unstable and try again.
530  * maybe free it here */
531  sepadata->skipsepa = TRUE;
532  }
533 
534  /* reset objective */
535  BMSclearMemoryArray(linvals, nlpinvars);
536  SCIP_CALL( SCIPchgNlpiLinearCoefs(scip, sepadata->nlpi, sepadata->nlpiprob, -1, nlpinvars, lininds, linvals) );
537 
538 CLEANUP:
539  /* free memory */
540  SCIPfreeBufferArray(scip, &lininds);
541  SCIPfreeBufferArray(scip, &linvals);
542 
543  return SCIP_OKAY;
544 }
545 
546 /** computes the violation and maximum violation of the convex nlrows stored in sepadata wrt sol */
547 static
549  SCIP* scip, /**< SCIP data structure */
550  SCIP_SEPADATA* sepadata, /**< separator data */
551  SCIP_SOL* sol, /**< solution that should be separated */
552  SCIP_Real* maxviolation /**< buffer to store maximum violation */
553  )
554 {
555  SCIP_NLROW* nlrow;
556  int i;
557 
558  assert(sepadata != NULL);
559  assert(sepadata->nnlrows > 0);
560  assert(sepadata->nlrows != NULL);
561  assert(sepadata->convexsides != NULL);
562  assert(sepadata->constraintviolation != NULL);
563 
564  *maxviolation = 0.0;
565  for( i = 0; i < sepadata->nnlrows; i++ )
566  {
567  SCIP_Real activity;
568  SCIP_Real violation;
569 
570  nlrow = sepadata->nlrows[i];
571 
572  /* get activity of nlrow */
573  SCIP_CALL( SCIPgetNlRowSolActivity(scip, nlrow, sol, &activity) );
574 
575  /* violation = max{activity - rhs, 0.0} when convex and max{lhs - activity, 0.0} when concave */
576  if( sepadata->convexsides[i] == RHS )
577  {
579  assert(!SCIPisInfinity(scip, SCIPnlrowGetRhs(nlrow)));
580 
581  violation = activity - SCIPnlrowGetRhs(nlrow);
582  sepadata->constraintviolation[i] = MAX(violation, 0.0);
583  }
584  if( sepadata->convexsides[i] == LHS )
585  {
587  assert(!SCIPisInfinity(scip, -SCIPnlrowGetLhs(nlrow)));
588 
589  violation = SCIPnlrowGetLhs(nlrow) - activity;
590  sepadata->constraintviolation[i] = MAX(violation, 0.0);
591  }
592 
593  /* compute maximum */
594  if( *maxviolation < sepadata->constraintviolation[i] )
595  *maxviolation = sepadata->constraintviolation[i];
596  }
597 
598  SCIPdebugMsg(scip, "Maximum violation %g\n", *maxviolation);
599 
600  return SCIP_OKAY;
601 }
602 
603 
604 /** stores, from the constraints represented by nlrows, the nonlinear convex ones in sepadata */
605 static
607  SCIP* scip, /**< SCIP data structure */
608  SCIP_SEPADATA* sepadata, /**< separator data */
609  SCIP_NLROW** nlrows, /**< nlrows from which to store convex ones */
610  int nnlrows /**< number of nlrows */
611  )
612 {
613  int i;
614 
615  assert(scip != NULL);
616  assert(sepadata != NULL);
617 
618  SCIPdebugMsg(scip, "storing convex nlrows\n");
619 
620  sepadata->nlrowssize = nnlrows;
621  SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(sepadata->nlrows), nnlrows) );
622  SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(sepadata->convexsides), nnlrows) );
623  SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(sepadata->constraintviolation), nnlrows) );
624 
625  /* count the number of nonlinear convex rows and store them */
626  sepadata->nnlrows = 0;
627  for( i = 0; i < nnlrows; ++i )
628  {
629  SCIP_NLROW* nlrow;
630 
631  nlrow = nlrows[i];
632  assert(nlrow != NULL);
633 
634  /* linear case */
636  continue;
637 
638  /* nonlinear case */
640  {
641  sepadata->convexsides[sepadata->nnlrows] = RHS;
642  sepadata->nlrows[sepadata->nnlrows] = nlrow;
643  ++(sepadata->nnlrows);
644  }
645  else if( !SCIPisInfinity(scip, -SCIPnlrowGetLhs(nlrow)) && SCIPnlrowGetCurvature(nlrow) == SCIP_EXPRCURV_CONCAVE )
646  {
647  sepadata->convexsides[sepadata->nnlrows] = LHS;
648  sepadata->nlrows[sepadata->nnlrows] = nlrow;
649  ++(sepadata->nnlrows);
650  }
651  }
652 
653  return SCIP_OKAY;
654 }
655 
656 
657 /*
658  * Callback methods of separator
659  */
660 
661 
662 /** destructor of separator to free user data (called when SCIP is exiting) */
663 static
664 SCIP_DECL_SEPAFREE(sepaFreeConvexproj)
665 { /*lint --e{715}*/
666  SCIP_SEPADATA* sepadata;
667 
668  assert(strcmp(SCIPsepaGetName(sepa), SEPA_NAME) == 0);
669 
670  /* free separator data */
671  sepadata = SCIPsepaGetData(sepa);
672  assert(sepadata != NULL);
673 
674  SCIP_CALL( sepadataClear(scip, sepadata) );
675 
676  SCIPfreeBlockMemory(scip, &sepadata);
677 
678  SCIPsepaSetData(sepa, NULL);
679 
680  return SCIP_OKAY;
681 }
682 
683 /** solving process deinitialization method of separator (called before branch and bound process data is freed) */
684 static
685 SCIP_DECL_SEPAEXITSOL(sepaExitsolConvexproj)
686 { /*lint --e{715}*/
687  SCIP_SEPADATA* sepadata;
688 
689  assert(sepa != NULL);
690 
691  sepadata = SCIPsepaGetData(sepa);
692 
693  assert(sepadata != NULL);
694 
695  SCIP_CALL( sepadataClear(scip, sepadata) );
696 
697  return SCIP_OKAY;
698 }
699 
700 
701 /** LP solution separation method of separator */
702 static
703 SCIP_DECL_SEPAEXECLP(sepaExeclpConvexproj)
704 { /*lint --e{715}*/
705  SCIP_Real maxviolation;
706  SCIP_SOL* lpsol;
707  SCIP_SEPADATA* sepadata;
708 
709  *result = SCIP_DIDNOTRUN;
710 
711  sepadata = SCIPsepaGetData(sepa);
712  assert(sepadata != NULL);
713 
714  /* do not run if there is no interesting convex relaxation (with at least one nonlinear convex constraint),
715  * or if we have found it to be numerically unstable
716  * @todo: should it be with at least 2 nonlinear convex constraints?
717  */
718  if( sepadata->skipsepa )
719  {
720  SCIPdebugMsg(scip, "not running because convex relaxation is uninteresting or numerically unstable\n");
721  return SCIP_OKAY;
722  }
723 
724  /* the separator needs an NLP solver */
725  if( SCIPgetNNlpis(scip) == 0 )
726  return SCIP_OKAY;
727 
728  /* only call separator up to a maximum depth */
729  if( sepadata->maxdepth >= 0 && depth > sepadata->maxdepth )
730  return SCIP_OKAY;
731 
732  /* only call separator, if we are not close to terminating */
733  if( SCIPisStopped(scip) )
734  return SCIP_OKAY;
735 
736  /* do not run if SCIP does not have constructed an NLP */
737  if( !SCIPisNLPConstructed(scip) )
738  {
739  SCIPdebugMsg(scip, "NLP not constructed, skipping convex projection separator\n");
740  return SCIP_OKAY;
741  }
742 
743  /* recompute convex NLP relaxation if the variable set changed and we are still at the root node */
744  if( sepadata->nlpiprob != NULL && SCIPgetNVars(scip) != sepadata->nlpinvars && SCIPgetDepth(scip) == 0 )
745  {
746  SCIP_CALL( sepadataClear(scip, sepadata) );
747  assert(sepadata->nlpiprob == NULL);
748  }
749 
750  /* create or update convex NLP relaxation */
751  if( sepadata->nlpiprob == NULL )
752  {
753  /* store convex nonlinear constraints */
755 
756  /* check that convex NLP relaxation is interesting (more than one nonlinear constraint) */
757  if( sepadata->nnlrows < 1 )
758  {
759  SCIPdebugMsg(scip, "convex relaxation uninteresting, don't run\n");
760  sepadata->skipsepa = TRUE;
761  return SCIP_OKAY;
762  }
763 
764  sepadata->nlpinvars = SCIPgetNVars(scip);
765  sepadata->nlpi = SCIPgetNlpis(scip)[0];
766  assert(sepadata->nlpi != NULL);
767 
768  SCIP_CALL( SCIPhashmapCreate(&sepadata->var2nlpiidx, SCIPblkmem(scip), sepadata->nlpinvars) );
769  SCIP_CALL( SCIPduplicateBlockMemoryArray(scip, &sepadata->nlpivars, SCIPgetVars(scip), sepadata->nlpinvars) ); /*lint !e666*/
770 
771  SCIP_CALL( SCIPcreateNlpiProblemFromNlRows(scip, sepadata->nlpi, &sepadata->nlpiprob, "convexproj-nlp", SCIPgetNLPNlRows(scip), SCIPgetNNLPNlRows(scip),
772  sepadata->var2nlpiidx, NULL, NULL, SCIPgetCutoffbound(scip), FALSE, TRUE) );
773 
774  /* add rows of the LP
775  * we do not sue the depth argument of the callback because we want to build a globally valid initia lrelaxation
776  */
777  if( SCIPgetDepth(scip) == 0 )
778  {
779  SCIP_CALL( SCIPaddNlpiProblemRows(scip, sepadata->nlpi, sepadata->nlpiprob, sepadata->var2nlpiidx,
781  }
782 
783  /* set quadratic part of objective function */
784  SCIP_CALL( setQuadraticObj(scip, sepadata) );
785  }
786  else
787  {
788  SCIP_CALL( SCIPupdateNlpiProblem(scip, sepadata->nlpi, sepadata->nlpiprob, sepadata->var2nlpiidx,
789  sepadata->nlpivars, sepadata->nlpinvars, SCIPgetCutoffbound(scip)) );
790  }
791 
792  /* assert that the lp solution satisfies the cutoff bound; if this fails then we shouldn't have a cutoff bound in the
793  * nlpi, since then the projection could be in the interior of the actual convex relaxation */
796 
797  /* get current sol: LP or pseudo solution if LP sol is not available */
799 
800  /* do not run if current solution's violation is small */
801  SCIP_CALL( computeMaxViolation(scip, sepadata, lpsol, &maxviolation) );
802  if( maxviolation < VIOLATIONFAC * SCIPfeastol(scip) )
803  {
804  SCIPdebugMsg(scip, "solution doesn't violate constraints enough, do not separate\n");
805  SCIP_CALL( SCIPfreeSol(scip, &lpsol) );
806  return SCIP_OKAY;
807  }
808 
809  /* run the separator */
810  *result = SCIP_DIDNOTFIND;
811 
812  /* separateCuts computes the projection and then gradient cuts on each constraint that was originally violated */
813  SCIP_CALL( separateCuts(scip, sepa, lpsol, result) );
814 
815  /* free memory */
816  SCIP_CALL( SCIPfreeSol(scip, &lpsol) );
817 
818  return SCIP_OKAY;
819 }
820 
821 
822 /*
823  * separator specific interface methods
824  */
825 
826 /** creates the convexproj separator and includes it in SCIP */
828  SCIP* scip /**< SCIP data structure */
829  )
830 {
831  SCIP_SEPADATA* sepadata;
832  SCIP_SEPA* sepa;
833 
834  /* create convexproj separator data */
835  SCIP_CALL( SCIPallocBlockMemory(scip, &sepadata) );
836 
837  /* this sets all data in sepadata to 0 */
838  BMSclearMemory(sepadata);
839 
840  /* include separator */
843  sepaExeclpConvexproj, NULL,
844  sepadata) );
845  assert(sepa != NULL);
846 
847  /* set non fundamental callbacks via setter functions */
848  SCIP_CALL( SCIPsetSepaFree(scip, sepa, sepaFreeConvexproj) );
849  SCIP_CALL( SCIPsetSepaExitsol(scip, sepa, sepaExitsolConvexproj) );
850 
851  /* add convexproj separator parameters */
852  SCIP_CALL( SCIPaddIntParam(scip, "separating/" SEPA_NAME "/maxdepth",
853  "maximal depth at which the separator is applied (-1: unlimited)",
854  &sepadata->maxdepth, FALSE, DEFAULT_MAXDEPTH, -1, INT_MAX, NULL, NULL) );
855 
856  SCIP_CALL( SCIPaddIntParam(scip, "separating/" SEPA_NAME "/nlpiterlimit",
857  "iteration limit of NLP solver; 0 for no limit",
858  &sepadata->nlpiterlimit, TRUE, DEFAULT_NLPITERLIM, 0, INT_MAX, NULL, NULL) );
859 
860  return SCIP_OKAY;
861 }
enum SCIP_Result SCIP_RESULT
Definition: type_result.h:52
#define SCIPfreeBlockMemoryArray(scip, ptr, num)
Definition: scip_mem.h:101
SCIP_ROW ** SCIPgetLPRows(SCIP *scip)
Definition: scip_lp.c:596
SCIP_Bool SCIPisFeasZero(SCIP *scip, SCIP_Real val)
int SCIPgetNNLPNlRows(SCIP *scip)
Definition: scip_nlp.c:332
convexproj separator
SCIP_RETCODE SCIPexpriterInit(SCIP_EXPRITER *iterator, SCIP_EXPR *expr, SCIP_EXPRITER_TYPE type, SCIP_Bool allowrevisit)
Definition: expriter.c:491
SCIP_Real SCIPfeastol(SCIP *scip)
static SCIP_RETCODE storeNonlinearConvexNlrows(SCIP *scip, SCIP_SEPADATA *sepadata, SCIP_NLROW **nlrows, int nnlrows)
#define SCIPallocBlockMemoryArray(scip, ptr, num)
Definition: scip_mem.h:84
SCIP_Bool SCIPisNLPConstructed(SCIP *scip)
Definition: scip_nlp.c:101
SCIP_RETCODE SCIPcreateExprPow(SCIP *scip, SCIP_EXPR **expr, SCIP_EXPR *child, SCIP_Real exponent, SCIP_DECL_EXPR_OWNERCREATE((*ownercreate)), void *ownercreatedata)
Definition: expr_pow.c:3160
SCIP_RETCODE SCIPcacheRowExtensions(SCIP *scip, SCIP_ROW *row)
Definition: scip_lp.c:1626
public methods for SCIP parameter handling
static SCIP_DECL_SEPAEXECLP(sepaExeclpConvexproj)
static SCIP_RETCODE computeMaxViolation(SCIP *scip, SCIP_SEPADATA *sepadata, SCIP_SOL *sol, SCIP_Real *maxviolation)
public methods for memory management
SCIP_Real SCIPgetCutoffbound(SCIP *scip)
SCIP_RETCODE SCIPflushRowExtensions(SCIP *scip, SCIP_ROW *row)
Definition: scip_lp.c:1649
#define SCIP_MAXSTRLEN
Definition: def.h:293
SCIP_RETCODE SCIPaddVarToRow(SCIP *scip, SCIP_ROW *row, SCIP_VAR *var, SCIP_Real val)
Definition: scip_lp.c:1686
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
Definition: var.c:17966
static SCIP_DECL_SEPAEXITSOL(sepaExitsolConvexproj)
public methods for timing
SCIP_VAR ** SCIPnlrowGetLinearVars(SCIP_NLROW *nlrow)
Definition: nlp.c:1774
SCIP_Real SCIPdualfeastol(SCIP *scip)
SCIP_Bool SCIPisFeasGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
#define FALSE
Definition: def.h:87
SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize)
Definition: misc.c:3014
const char * SCIPnlrowGetName(SCIP_NLROW *nlrow)
Definition: nlp.c:1843
static SCIP_RETCODE setQuadraticObj(SCIP *scip, SCIP_SEPADATA *sepadata)
SCIP_Real SCIPinfinity(SCIP *scip)
int SCIPsnprintf(char *t, int len, const char *s,...)
Definition: misc.c:10755
#define TRUE
Definition: def.h:86
#define SCIPdebug(x)
Definition: pub_message.h:84
const char * SCIPsepaGetName(SCIP_SEPA *sepa)
Definition: sepa.c:720
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:54
SCIP_Real SCIPnlrowGetRhs(SCIP_NLROW *nlrow)
Definition: nlp.c:1814
int SCIPnlrowGetNLinearVars(SCIP_NLROW *nlrow)
Definition: nlp.c:1764
public methods for problem variables
#define SCIPfreeBlockMemory(scip, ptr)
Definition: scip_mem.h:99
SCIP_RETCODE SCIPgetNlRowSolActivity(SCIP *scip, SCIP_NLROW *nlrow, SCIP_SOL *sol, SCIP_Real *activity)
Definition: scip_nlp.c:1454
SCIP_EXPRCURV SCIPnlrowGetCurvature(SCIP_NLROW *nlrow)
Definition: nlp.c:1824
SCIP_NLPI ** SCIPgetNlpis(SCIP *scip)
Definition: scip_nlpi.c:177
#define SCIPfreeBufferArray(scip, ptr)
Definition: scip_mem.h:127
#define SCIPdebugMsg
Definition: scip_message.h:69
SCIP_RETCODE SCIPaddIntParam(SCIP *scip, const char *name, const char *desc, int *valueptr, SCIP_Bool isadvanced, int defaultvalue, int minvalue, int maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip_param.c:74
public methods for separator plugins
SCIP_RETCODE SCIPcreateExprSum(SCIP *scip, SCIP_EXPR **expr, int nchildren, SCIP_EXPR **children, SCIP_Real *coefficients, SCIP_Real constant, SCIP_DECL_EXPR_OWNERCREATE((*ownercreate)), void *ownercreatedata)
Definition: expr_sum.c:1062
SCIP_RETCODE SCIPevalExprGradient(SCIP *scip, SCIP_EXPR *expr, SCIP_SOL *sol, SCIP_Longint soltag)
Definition: scip_expr.c:1656
public methods for numerical tolerances
SCIP_SEPADATA * SCIPsepaGetData(SCIP_SEPA *sepa)
Definition: sepa.c:610
public methods for querying solving statistics
SCIP_Bool SCIPhashmapExists(SCIP_HASHMAP *hashmap, void *origin)
Definition: misc.c:3363
public methods for the branch-and-bound tree
int SCIPgetNNlpis(SCIP *scip)
Definition: scip_nlpi.c:190
public methods for NLPI solver interfaces
#define SCIPduplicateBlockMemoryArray(scip, ptr, source, num)
Definition: scip_mem.h:96
SCIP_Bool SCIPisCutEfficacious(SCIP *scip, SCIP_SOL *sol, SCIP_ROW *cut)
Definition: scip_cut.c:108
int SCIPgetNNLPVars(SCIP *scip)
Definition: scip_nlp.c:192
#define SEPA_PRIORITY
handler for variable index expressions
#define SCIPerrorMessage
Definition: pub_message.h:55
SCIP_Real SCIPexprGetDerivative(SCIP_EXPR *expr)
Definition: expr.c:3898
#define SCIPdebugPrintf
Definition: pub_message.h:90
SCIP_RETCODE SCIPincludeSepaConvexproj(SCIP *scip)
SCIP_RETCODE SCIPupdateNlpiProblem(SCIP *scip, SCIP_NLPI *nlpi, SCIP_NLPIPROBLEM *nlpiprob, SCIP_HASHMAP *var2nlpiidx, SCIP_VAR **nlpivars, int nlpinvars, SCIP_Real cutoffbound)
Definition: scip_nlpi.c:720
SCIP_VAR * SCIPgetVarExprVar(SCIP_EXPR *expr)
Definition: expr_var.c:403
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
Definition: scip_mem.c:48
public functions to work with algebraic expressions
void SCIPhashmapFree(SCIP_HASHMAP **hashmap)
Definition: misc.c:3048
void SCIPsepaSetData(SCIP_SEPA *sepa, SCIP_SEPADATA *sepadata)
Definition: sepa.c:620
#define NULL
Definition: lpi_spx1.cpp:155
power and signed power expression handlers
#define REALABS(x)
Definition: def.h:201
int SCIPgetNLPRows(SCIP *scip)
Definition: scip_lp.c:617
#define SEPA_DESC
#define SCIP_CALL(x)
Definition: def.h:384
SCIP_NLROW ** SCIPgetNLPNlRows(SCIP *scip)
Definition: scip_nlp.c:310
SCIP_Bool SCIPisFeasLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_RETCODE SCIPaddRow(SCIP *scip, SCIP_ROW *row, SCIP_Bool forcecut, SCIP_Bool *infeasible)
Definition: scip_cut.c:241
SCIP_RETCODE SCIPcreateExpriter(SCIP *scip, SCIP_EXPRITER **iterator)
Definition: scip_expr.c:2286
public methods for NLP management
SCIP_RETCODE SCIPincludeSepaBasic(SCIP *scip, SCIP_SEPA **sepa, const char *name, const char *desc, int priority, int freq, SCIP_Real maxbounddist, SCIP_Bool usessubscip, SCIP_Bool delay, SCIP_DECL_SEPAEXECLP((*sepaexeclp)), SCIP_DECL_SEPAEXECSOL((*sepaexecsol)), SCIP_SEPADATA *sepadata)
Definition: scip_sepa.c:100
SCIP_Bool SCIPisHugeValue(SCIP *scip, SCIP_Real val)
SCIP_RETCODE SCIPaddNlpiProblemRows(SCIP *scip, SCIP_NLPI *nlpi, SCIP_NLPIPROBLEM *nlpiprob, SCIP_HASHMAP *var2idx, SCIP_ROW **rows, int nrows)
Definition: scip_nlpi.c:772
#define SCIPallocBufferArray(scip, ptr, num)
Definition: scip_mem.h:115
SCIP_RETCODE SCIPsetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var, SCIP_Real val)
Definition: scip_sol.c:1212
public data structures and miscellaneous methods
SCIP_RETCODE SCIPsetSepaExitsol(SCIP *scip, SCIP_SEPA *sepa, SCIP_DECL_SEPAEXITSOL((*sepaexitsol)))
Definition: scip_sepa.c:222
#define SCIP_Bool
Definition: def.h:84
SCIP_RETCODE SCIPchgRowRhs(SCIP *scip, SCIP_ROW *row, SCIP_Real rhs)
Definition: scip_lp.c:1598
SCIP_LPSOLSTAT SCIPgetLPSolstat(SCIP *scip)
Definition: scip_lp.c:159
static SCIP_RETCODE separateCuts(SCIP *scip, SCIP_SEPA *sepa, SCIP_SOL *sol, SCIP_RESULT *result)
SCIP_Real SCIPvarGetNLPSol(SCIP_VAR *var)
Definition: var.c:18297
int SCIPgetDepth(SCIP *scip)
Definition: scip_tree.c:661
SCIP_RETCODE SCIPreleaseExpr(SCIP *scip, SCIP_EXPR **expr)
Definition: scip_expr.c:1407
#define MAX(x, y)
Definition: tclique_def.h:83
#define DEFAULT_MAXDEPTH
SCIP_RETCODE SCIPcreateEmptyRowSepa(SCIP *scip, SCIP_ROW **row, SCIP_SEPA *sepa, const char *name, SCIP_Real lhs, SCIP_Real rhs, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool removable)
Definition: scip_lp.c:1444
#define SEPA_NAME
SCIP_RETCODE SCIPchgRowLhs(SCIP *scip, SCIP_ROW *row, SCIP_Real lhs)
Definition: scip_lp.c:1574
SCIP_Real SCIPgetCutEfficacy(SCIP *scip, SCIP_SOL *sol, SCIP_ROW *cut)
Definition: scip_cut.c:85
public methods for cuts and aggregation rows
SCIP_RETCODE SCIPfreeSol(SCIP *scip, SCIP_SOL **sol)
Definition: scip_sol.c:976
SCIP_EXPR * SCIPexpriterGetNext(SCIP_EXPRITER *iterator)
Definition: expriter.c:848
SCIP_RETCODE SCIPcreateNlpiProblemFromNlRows(SCIP *scip, SCIP_NLPI *nlpi, SCIP_NLPIPROBLEM **nlpiprob, const char *name, SCIP_NLROW **nlrows, int nnlrows, SCIP_HASHMAP *var2idx, SCIP_HASHMAP *nlrow2idx, SCIP_Real *nlscore, SCIP_Real cutoffbound, SCIP_Bool setobj, SCIP_Bool onlyconvex)
Definition: scip_nlpi.c:434
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
#define SCIPsolveNlpi(scip, nlpi,...)
Definition: scip_nlpi.h:199
#define BMSclearMemory(ptr)
Definition: memory.h:122
public methods for the LP relaxation, rows and columns
int SCIPgetNVars(SCIP *scip)
Definition: scip_prob.c:1990
void SCIPfreeExpriter(SCIP_EXPRITER **iterator)
Definition: scip_expr.c:2300
public methods for nonlinear relaxation
SCIP_Real * SCIPnlrowGetLinearCoefs(SCIP_NLROW *nlrow)
Definition: nlp.c:1784
#define DEFAULT_NLPITERLIM
SCIP_RETCODE SCIPreleaseRow(SCIP *scip, SCIP_ROW **row)
Definition: scip_lp.c:1553
#define SEPA_FREQ
general public methods
SCIP_RETCODE SCIPsetSepaFree(SCIP *scip, SCIP_SEPA *sepa, SCIP_DECL_SEPAFREE((*sepafree)))
Definition: scip_sepa.c:158
SCIP_Real SCIPgetLPObjval(SCIP *scip)
Definition: scip_lp.c:238
public methods for solutions
public methods for message output
SCIP_Bool SCIPisExprVar(SCIP *scip, SCIP_EXPR *expr)
Definition: scip_expr.c:1421
SCIP_VAR ** SCIPgetVars(SCIP *scip)
Definition: scip_prob.c:1945
#define SEPA_USESSUBSCIP
#define SCIP_Real
Definition: def.h:177
SCIP_Bool SCIPisStopped(SCIP *scip)
Definition: scip_general.c:694
public methods for message handling
static SCIP_DECL_SEPAFREE(sepaFreeConvexproj)
SCIP_RETCODE SCIPprintRow(SCIP *scip, SCIP_ROW *row, FILE *file)
Definition: scip_lp.c:2197
SCIP_RETCODE SCIPprintNlRow(SCIP *scip, SCIP_NLROW *nlrow, FILE *file)
Definition: scip_nlp.c:1547
SCIP_RETCODE SCIPcreateCurrentSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip_sol.c:474
static SCIP_RETCODE generateCut(SCIP *scip, SCIP_SEPA *sepa, SCIP_SOL *projection, SCIP_NLROW *nlrow, CONVEXSIDE convexside, SCIP_Real activity, SCIP_EXPRITER *exprit, SCIP_ROW **row)
sum expression handler
SCIP_Real SCIPgetNLPObjval(SCIP *scip)
Definition: scip_nlp.c:603
SCIP_Bool SCIPisLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
Definition: var.c:17976
ConvexSide
#define SEPA_MAXBOUNDDIST
public methods for separators
#define BMSclearMemoryArray(ptr, num)
Definition: memory.h:123
SCIP_Bool SCIPexpriterIsEnd(SCIP_EXPRITER *iterator)
Definition: expriter.c:959
SCIPallocBlockMemory(scip, subsol))
int SCIPhashmapGetImageInt(SCIP_HASHMAP *hashmap, void *origin)
Definition: misc.c:3221
#define SEPA_DELAY
SCIP_Real SCIPnlrowGetLhs(SCIP_NLROW *nlrow)
Definition: nlp.c:1804
#define SCIPABORT()
Definition: def.h:356
public methods for global and local (sub)problems
SCIP_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var)
Definition: scip_sol.c:1352
SCIP_RETCODE SCIPcreateExprVaridx(SCIP *scip, SCIP_EXPR **expr, int varidx, SCIP_DECL_EXPR_OWNERCREATE((*ownercreate)), void *ownercreatedata)
Definition: expr_varidx.c:210
enum ConvexSide CONVEXSIDE
struct SCIP_SepaData SCIP_SEPADATA
Definition: type_sepa.h:43
SCIP_VAR ** SCIPgetNLPVars(SCIP *scip)
Definition: scip_nlp.c:170
SCIP_EXPR * SCIPnlrowGetExpr(SCIP_NLROW *nlrow)
Definition: nlp.c:1794
static SCIP_RETCODE sepadataClear(SCIP *scip, SCIP_SEPADATA *sepadata)
#define VIOLATIONFAC
SCIP_RETCODE SCIPcreateSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip_sol.c:319
memory allocation routines
SCIP_RETCODE SCIPprintSol(SCIP *scip, SCIP_SOL *sol, FILE *file, SCIP_Bool printzeros)
Definition: scip_sol.c:1766