Scippy

SCIP

Solving Constraint Integer Programs

sepa_interminor.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-2025 Zuse Institute Berlin (ZIB) */
7/* */
8/* Licensed under the Apache License, Version 2.0 (the "License"); */
9/* you may not use this file except in compliance with the License. */
10/* You may obtain a copy of the License at */
11/* */
12/* http://www.apache.org/licenses/LICENSE-2.0 */
13/* */
14/* Unless required by applicable law or agreed to in writing, software */
15/* distributed under the License is distributed on an "AS IS" BASIS, */
16/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
17/* See the License for the specific language governing permissions and */
18/* limitations under the License. */
19/* */
20/* You should have received a copy of the Apache-2.0 license */
21/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */
22/* */
23/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24
25/**@file sepa_interminor.c
26 * @ingroup DEFPLUGINS_SEPA
27 * @brief minor separator with intersection cuts
28 * @author Felipe Serrano
29 * @author Antonia Chmiela
30 *
31 * Let X be the matrix of auxiliary variables added for bilinear terms, X_{ij} = x_ix_j.
32 * The separator enforces quadratic constraints det(2x2 minor of X) = 0 via intersection cuts.
33 */
34
35/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
36
37#include <assert.h>
38#include <string.h>
39
41#include "scip/expr.h"
42#include "scip/expr_var.h"
43#include "scip/expr_pow.h"
44#include "scip/expr_product.h"
45#include "scip/nlpi_ipopt.h"
46#include "scip/cons_nonlinear.h"
47
48
49
50#define SEPA_NAME "interminor"
51#define SEPA_DESC "intersection cuts separator to ensure that 2x2 minors of X (= xx') have determinant 0"
52#define SEPA_PRIORITY 0
53#define SEPA_FREQ -1
54#define SEPA_MAXBOUNDDIST 1.0
55#define SEPA_USESSUBSCIP FALSE /**< does the separator use a secondary SCIP instance? */
56#define SEPA_DELAY FALSE /**< should separation method be delayed, if other separators found cuts? */
57
58#define DEFAULT_MINCUTVIOL 1e-4 /**< default minimum required violation of a cut */
59#define DEFAULT_RANDSEED 157 /**< default random seed */
60#define DEFAULT_MAXROUNDS 10 /**< maximal number of separation rounds per node (-1: unlimited) */
61#define DEFAULT_MAXROUNDSROOT -1 /**< maximal number of separation rounds in the root node (-1: unlimited) */
62#define BINSEARCH_MAXITERS 120 /**< default iteration limit for binary search */
63#define DEFAULT_USESTRENGTHENING FALSE /**< default for using strengthend intersection cuts to separate */
64#define DEFAULT_USEBOUNDS FALSE /**< default for using nonnegativity bounds when separating */
65
66/* TODO find a smarter less blunt way how to handle problems with many 2x2 minors (eigena2, elec100, sjup2) */
67#define MAXNMINORS 100000 /**< maximal minors to consider; minor detection stops when MAXNMINORS many have been found */
68
69/*
70 * Data structures
71 */
72
73/** separator data */
74struct SCIP_SepaData
75{
76 SCIP_VAR** minors; /**< variables of 2x2 minors; each minor is stored like (auxvar_x^2,auxvar_y^2,auxvar_xy) */
77 SCIP_Bool* isdiagonal; /**< bool array determining if the variables appearing in the minor are diagonal */
78 int nminors; /**< total number of minors */
79 int minorssize; /**< size of minors array */
80 int maxrounds; /**< maximal number of separation rounds per node (-1: unlimited) */
81 int maxroundsroot; /**< maximal number of separation rounds in the root node (-1: unlimited) */
82 SCIP_Bool detectedminors; /**< has minor detection be called? */
83 SCIP_Real mincutviol; /**< minimum required violation of a cut */
84 SCIP_RANDNUMGEN* randnumgen; /**< random number generation */
85 SCIP_Bool usestrengthening; /**< whether to use strengthened intersection cuts to separate minors */
86 SCIP_Bool usebounds; /**< whether to also enforce nonegativity bounds of principle minors */
87};
88
89/* these represent a row */
90struct rowdata
91{
92 int* vals; /**< index of the column */
93 int rowidx; /**< index corresponding to variable of that row */
94 int nvals; /**< number of nonzero entries in column */
95 int valssize; /**< size of the array that is currently allocated */
96 SCIP_HASHMAP* auxvars; /**< entry of the matrix */
97};
98
99/*
100 * Local methods
101 */
102
103/** helper method to store a 2x2 minor in the separation data */
104static
106 SCIP* scip, /**< SCIP data structure */
107 SCIP_SEPADATA* sepadata, /**< separator data */
108 SCIP_VAR* auxvarxik, /**< auxiliary variable X_ik = x_i * x_k */
109 SCIP_VAR* auxvarxil, /**< auxiliary variable X_il = x_i * x_l */
110 SCIP_VAR* auxvarxjk, /**< auxiliary variable X_jk = x_j * x_k */
111 SCIP_VAR* auxvarxjl, /**< auxiliary variable X_jl = x_j * x_l */
112 SCIP_Bool isauxvarxikdiag, /**< is X_ik diagonal? (i.e. i = k) */
113 SCIP_Bool isauxvarxildiag, /**< is X_il diagonal? (i.e. i = l) */
114 SCIP_Bool isauxvarxjkdiag, /**< is X_jk diagonal? (i.e. j = k) */
115 SCIP_Bool isauxvarxjldiag /**< is X_jl diagonal? (i.e. j = l) */
116 )
117{
118 assert(sepadata != NULL);
119 assert(auxvarxik != NULL);
120 assert(auxvarxil != NULL);
121 assert(auxvarxjk != NULL);
122 assert(auxvarxjl != NULL);
123 assert(auxvarxik != auxvarxil);
124 assert(auxvarxjk != auxvarxjl);
125
126 SCIPdebugMsg(scip, "store 2x2 minor: [%s %s, %s %s]\n", SCIPvarGetName(auxvarxik), SCIPvarGetName(auxvarxil),
127 SCIPvarGetName(auxvarxjk), SCIPvarGetName(auxvarxjl));
128
129 /* reallocate if necessary */
130 if( sepadata->minorssize < 4 * (sepadata->nminors + 1) )
131 {
132 int newsize = SCIPcalcMemGrowSize(scip, 4 * (sepadata->nminors + 1));
133 assert(newsize >= 4 * (sepadata->nminors + 1));
134
135 SCIP_CALL( SCIPreallocBlockMemoryArray(scip, &(sepadata->minors), sepadata->minorssize, newsize) );
136 SCIP_CALL( SCIPreallocBlockMemoryArray(scip, &(sepadata->isdiagonal), sepadata->minorssize, newsize) );
137 sepadata->minorssize = newsize;
138 }
139
140 /* store minor */
141 sepadata->minors[4 * sepadata->nminors] = auxvarxik;
142 sepadata->minors[4 * sepadata->nminors + 1] = auxvarxil;
143 sepadata->minors[4 * sepadata->nminors + 2] = auxvarxjk;
144 sepadata->minors[4 * sepadata->nminors + 3] = auxvarxjl;
145 sepadata->isdiagonal[4 * sepadata->nminors] = isauxvarxikdiag;
146 sepadata->isdiagonal[4 * sepadata->nminors + 1] = isauxvarxildiag;
147 sepadata->isdiagonal[4 * sepadata->nminors + 2] = isauxvarxjkdiag;
148 sepadata->isdiagonal[4 * sepadata->nminors + 3] = isauxvarxjldiag;
149 ++(sepadata->nminors);
150
151 /* capture variables */
152 SCIP_CALL( SCIPcaptureVar(scip, auxvarxik) );
153 SCIP_CALL( SCIPcaptureVar(scip, auxvarxil) );
154 SCIP_CALL( SCIPcaptureVar(scip, auxvarxjk) );
155 SCIP_CALL( SCIPcaptureVar(scip, auxvarxjl) );
156
157 return SCIP_OKAY;
158}
159
160/** helper method to clear separation data */
161static
163 SCIP* scip, /**< SCIP data structure */
164 SCIP_SEPADATA* sepadata /**< separator data */
165 )
166{
167 int i;
168
169 assert(sepadata != NULL);
170
171 SCIPdebugMsg(scip, "clear separation data\n");
172
173 /* release captured variables */
174 for( i = 0; i < 4 * sepadata->nminors; ++i )
175 {
176 assert(sepadata->minors[i] != NULL);
177 SCIP_CALL( SCIPreleaseVar(scip, &sepadata->minors[i]) );
178 }
179
180 /* free memory */
181 SCIPfreeBlockMemoryArrayNull(scip, &sepadata->minors, sepadata->minorssize);
182 SCIPfreeBlockMemoryArrayNull(scip, &sepadata->isdiagonal, sepadata->minorssize);
183
184 /* reset counters */
185 sepadata->nminors = 0;
186 sepadata->minorssize = 0;
187
188 return SCIP_OKAY;
189}
190
191/** helper method to get the variables associated to a minor */
192static
194 SCIP_SEPADATA* sepadata, /**< separator data */
195 int idx, /**< index of the stored minor */
196 SCIP_VAR** auxvarxik, /**< auxiliary variable X_ik = x_i * x_k */
197 SCIP_VAR** auxvarxil, /**< auxiliary variable X_il = x_i * x_l */
198 SCIP_VAR** auxvarxjk, /**< auxiliary variable X_jk = x_j * x_k */
199 SCIP_VAR** auxvarxjl, /**< auxiliary variable X_jl = x_j * x_l */
200 SCIP_Bool* isauxvarxikdiag, /**< is X_ik diagonal? (i.e. i = k) */
201 SCIP_Bool* isauxvarxildiag, /**< is X_il diagonal? (i.e. i = l) */
202 SCIP_Bool* isauxvarxjkdiag, /**< is X_jk diagonal? (i.e. j = k) */
203 SCIP_Bool* isauxvarxjldiag /**< is X_jl diagonal? (i.e. j = l) */
204 )
205{
206 assert(auxvarxik != NULL);
207 assert(auxvarxil != NULL);
208 assert(auxvarxjk != NULL);
209 assert(auxvarxjl != NULL);
210
211 *auxvarxik = sepadata->minors[4 * idx];
212 *auxvarxil = sepadata->minors[4 * idx + 1];
213 *auxvarxjk = sepadata->minors[4 * idx + 2];
214 *auxvarxjl = sepadata->minors[4 * idx + 3];
215
216 *isauxvarxikdiag = sepadata->isdiagonal[4 * idx];
217 *isauxvarxildiag = sepadata->isdiagonal[4 * idx + 1];
218 *isauxvarxjkdiag = sepadata->isdiagonal[4 * idx + 2];
219 *isauxvarxjldiag = sepadata->isdiagonal[4 * idx + 3];
220
221 return SCIP_OKAY;
222}
223
224
225/** adds a new entry (i.e., auxvar) of in (row, col) of matrix M.
226 *
227 * we have a matrix, M, indexed by the variables
228 * M(xi, xk) is the auxiliary variable of xi * xk if it exists
229 * We store, for each row of the matrix, the indices of the nonzero column entries (assoc with the given row) and the auxiliary variable for xi * xk
230 * The nonzero column entries are stored as an array (struct rowdata)
231 * So we have a hashmap mapping each variable (row of the matrix) with its array representing the nonzero entries of the row.
232 */
233static
235 SCIP* scip, /**< SCIP data structure */
236 SCIP_HASHMAP* rowmap, /**< hashmap of the rows of the matrix */
237 SCIP_VAR* row, /**< variable corresponding to row of new entry */
238 SCIP_VAR* col, /**< variable corresponding to column of new entry */
239 SCIP_VAR* auxvar, /**< auxvar to insert into the matrix */
240 int* rowindices, /**< array of indices of all variables corresponding to a row */
241 int* nrows /**< number of rows */
242 )
243{
244 SCIPdebugMsg(scip, "inserting %s in row %s and col %s \n", SCIPvarGetName(auxvar), SCIPvarGetName(row), SCIPvarGetName(col));
245
246 /* check whether variable has an array associated to it */
247 if( SCIPhashmapExists(rowmap, (void*)row) )
248 {
249 struct rowdata* arr;
250
251 arr = (struct rowdata*)SCIPhashmapGetImage(rowmap, (void *)row);
252
253 /* reallocate if necessary */
254 if( arr->valssize < arr->nvals + 1 )
255 {
256 int newsize = SCIPcalcMemGrowSize(scip, arr->nvals + 1);
257 assert(newsize > arr->nvals + 1);
258
259 SCIP_CALL( SCIPreallocBufferArray(scip, &(arr->vals), newsize) );
260 arr->valssize = newsize;
261 }
262
263 /* insert */
264 arr->vals[arr->nvals] = SCIPvarGetProbindex(col);
265 SCIP_CALL( SCIPhashmapInsert(arr->auxvars, (void*)col, (void *)auxvar) );
266 arr->nvals += 1;
267 }
268 else
269 {
270 struct rowdata* arr;
271
272 /* create index array */
274 arr->valssize = 10;
275 arr->nvals = 0;
278
279 /* insert */
280 arr->rowidx = SCIPvarGetProbindex(row);
281 arr->vals[arr->nvals] = SCIPvarGetProbindex(col);
282 SCIP_CALL( SCIPhashmapInsert(arr->auxvars, (void*)col, (void *)auxvar) );
283 arr->nvals += 1;
284
285 /* store in hashmap */
286 SCIP_CALL( SCIPhashmapInsert(rowmap, (void*)row, (void *)arr) );
287
288 /* remember the new row */
289 rowindices[*nrows] = SCIPvarGetProbindex(row);
290 *nrows += 1;
291 }
292
293 return SCIP_OKAY;
294}
295
296/** method to detect and store principal minors */
297static
299 SCIP* scip, /**< SCIP data structure */
300 SCIP_SEPADATA* sepadata /**< separator data */
301 )
302{
303 SCIP_CONSHDLR* conshdlr;
304 SCIP_EXPRITER* it;
305 SCIP_HASHMAP* rowmap;
306 int* rowvars = NULL;
307 int* intersection;
308 int nrowvars = 0;
309 int c;
310 int i;
311
312#ifdef SCIP_STATISTIC
313 SCIP_Real totaltime = -SCIPgetTotalTime(scip);
314#endif
315
316 assert(sepadata != NULL);
317
318 /* check whether minor detection has been called already */
319 if( sepadata->detectedminors )
320 return SCIP_OKAY;
321
322 assert(sepadata->minors == NULL);
323 assert(sepadata->nminors == 0);
324
325 /* we assume that the auxiliary variables in the nonlinear constraint handler have been already generated */
326 sepadata->detectedminors = TRUE;
327
328 /* check whether there are nonlinear constraints available */
329 conshdlr = SCIPfindConshdlr(scip, "nonlinear");
330 if( conshdlr == NULL || SCIPconshdlrGetNConss(conshdlr) == 0 )
331 return SCIP_OKAY;
332
333 SCIPdebugMsg(scip, "call detectMinors()\n");
334
335 /* allocate memory */
340
341 /* initialize iterator */
343
344 for( c = 0; c < SCIPconshdlrGetNConss(conshdlr); ++c )
345 {
346 SCIP_CONS* cons;
347 SCIP_EXPR* expr;
348 SCIP_EXPR* root;
349
350 cons = SCIPconshdlrGetConss(conshdlr)[c];
351 assert(cons != NULL);
352 root = SCIPgetExprNonlinear(cons);
353 assert(root != NULL);
354
355 for( expr = SCIPexpriterRestartDFS(it, root); !SCIPexpriterIsEnd(it); expr = SCIPexpriterGetNext(it) ) /*lint !e441*//*lint !e440*/
356 {
357 SCIP_EXPR** children;
358 SCIP_VAR* auxvar;
359
360 SCIPdebugMsg(scip, "visit expression %p in constraint %s\n", (void*)expr, SCIPconsGetName(cons));
361
362 /* check whether the expression has an auxiliary variable */
363 auxvar = SCIPgetExprAuxVarNonlinear(expr);
364 if( auxvar == NULL )
365 {
366 SCIPdebugMsg(scip, "expression has no auxiliary variable -> skip\n");
367 continue;
368 }
369
370 children = SCIPexprGetChildren(expr);
371
372 /* check for expr = (x)^2 */
373 if( SCIPexprGetNChildren(expr) == 1 && SCIPisExprPower(scip, expr)
374 && SCIPgetExponentExprPow(expr) == 2.0
375 && SCIPgetExprAuxVarNonlinear(children[0]) != NULL )
376 {
377 SCIP_VAR* quadvar;
378
379 assert(children[0] != NULL);
380
381 quadvar = SCIPgetExprAuxVarNonlinear(children[0]);
382 assert(quadvar != NULL);
383
384 SCIP_CALL( insertIndex(scip, rowmap, quadvar, quadvar, auxvar, rowvars, &nrowvars) );
385 }
386 /* check for expr = x_i * x_k */
387 else if( SCIPexprGetNChildren(expr) == 2 && SCIPisExprProduct(scip, expr)
388 && SCIPgetExprAuxVarNonlinear(children[0]) != NULL && SCIPgetExprAuxVarNonlinear(children[1]) != NULL )
389 {
390 SCIP_VAR* xi;
391 SCIP_VAR* xk;
392
393 assert(children[0] != NULL);
394 assert(children[1] != NULL);
395
396 xi = SCIPgetExprAuxVarNonlinear(children[0]);
397 xk = SCIPgetExprAuxVarNonlinear(children[1]);
398
399 SCIP_CALL( insertIndex(scip, rowmap, xk, xi, auxvar, rowvars, &nrowvars) );
400 SCIP_CALL( insertIndex(scip, rowmap, xi, xk, auxvar, rowvars, &nrowvars) );
401 }
402 }
403 }
404
405 /* sort the column entries */
406 for( i = 0; i < nrowvars; ++i )
407 {
408 struct rowdata* row;
409
410 row = (struct rowdata*)SCIPhashmapGetImage(rowmap, (void *)SCIPgetVars(scip)[rowvars[i]]);
411 SCIPsortInt(row->vals, row->nvals);
412 }
413
414 /* store 2x2 minors */
415 /* TODO: we might store some minors twice since the matrix is symmetric. Handle that! (see unit test for example) */
416 for( i = 0; i < nrowvars; ++i )
417 {
418 int j;
419 struct rowdata* rowi;
420
421 rowi = (struct rowdata*)SCIPhashmapGetImage(rowmap, (void *)SCIPgetVars(scip)[rowvars[i]]);
422
423 for( j = i + 1; j < nrowvars && sepadata->nminors < MAXNMINORS ; ++j )
424 {
425 struct rowdata* rowj;
426 int ninter;
427
428 rowj = (struct rowdata*)SCIPhashmapGetImage(rowmap, (void *)SCIPgetVars(scip)[rowvars[j]]);
429
430 SCIPcomputeArraysIntersectionInt(rowi->vals, rowi->nvals, rowj->vals, rowj->nvals, intersection, &ninter);
431
432 if( ninter > 1)
433 {
434 int p;
435
436 for( p = 0; p < ninter - 1; ++p )
437 {
438 int q;
439
440 for( q = p + 1; q < ninter; ++q )
441 {
442 SCIP_HASHMAP* rowicols;
443 SCIP_HASHMAP* rowjcols;
444 SCIP_VAR* colk;
445 SCIP_VAR* coll;
446 SCIP_VAR* auxvarik;
447 SCIP_VAR* auxvaril;
448 SCIP_VAR* auxvarjk;
449 SCIP_VAR* auxvarjl;
450 int ii;
451 int jj;
452 int k;
453 int l;
454 SCIP_Bool isauxvarikdiag = FALSE;
455 SCIP_Bool isauxvarildiag = FALSE;
456 SCIP_Bool isauxvarjkdiag = FALSE;
457 SCIP_Bool isauxvarjldiag = FALSE;
458
459 ii = rowi->rowidx;
460 jj = rowj->rowidx;
461 k = intersection[p];
462 l = intersection[q];
463
464 rowicols = rowi->auxvars;
465 rowjcols = rowj->auxvars;
466
467 colk = SCIPgetVars(scip)[k];
468 coll = SCIPgetVars(scip)[l];
469
470 auxvarik = (SCIP_VAR*) SCIPhashmapGetImage(rowicols, colk);
471 auxvaril = (SCIP_VAR*) SCIPhashmapGetImage(rowicols, coll);
472 auxvarjk = (SCIP_VAR*) SCIPhashmapGetImage(rowjcols, colk);
473 auxvarjl = (SCIP_VAR*) SCIPhashmapGetImage(rowjcols, coll);
474
475 if( ii == k )
476 isauxvarikdiag = TRUE;
477 else if( ii == l )
478 isauxvarildiag = TRUE;
479 if( jj == k )
480 isauxvarjkdiag = TRUE;
481 else if( jj == l )
482 isauxvarjldiag = TRUE;
483
484 SCIP_CALL( sepadataAddMinor(scip, sepadata, auxvarik, auxvaril, auxvarjk, auxvarjl,
485 isauxvarikdiag, isauxvarildiag, isauxvarjkdiag, isauxvarjldiag) );
486 }
487 }
488 }
489 }
491 SCIPhashmapFree(&rowi->auxvars);
493 }
494
495 SCIPdebugMsg(scip, "found %d principal minors in total\n", sepadata->nminors);
496
497 /* free memory */
498 SCIPfreeBufferArray(scip, &intersection);
499 SCIPfreeBufferArray(scip, &rowvars);
500 SCIPhashmapFree(&rowmap);
501 SCIPfreeExpriter(&it);
502
503#ifdef SCIP_STATISTIC
504 totaltime += SCIPgetTotalTime(scip);
505 SCIPstatisticMessage("MINOR DETECT %s %f %d %d\n", SCIPgetProbName(scip), totaltime, sepadata->nminors, maxminors);
506#endif
507
508 return SCIP_OKAY;
509}
510
511/** constructs map between lp position of a basic variable and its row in the tableau */
512static
514 SCIP* scip, /**< SCIP data structure */
515 int* map /**< buffer to store the map */
516 )
517{
518 int* basisind;
519 int nrows;
520 int i;
521
522 nrows = SCIPgetNLPRows(scip);
523 SCIP_CALL( SCIPallocBufferArray(scip, &basisind, nrows) );
524
525 SCIP_CALL( SCIPgetLPBasisInd(scip, basisind) );
526 for( i = 0; i < nrows; ++i )
527 {
528 if( basisind[i] >= 0 )
529 map[basisind[i]] = i;
530 }
531
532 SCIPfreeBufferArray(scip, &basisind);
533
534 return SCIP_OKAY;
535}
536
537/** The restriction of the function representing the maximal S-free set to zlp + t * ray has the form
538 * sqrt(A t^2 + B t + C) - (D t + E).
539 * This function computes the coefficients A, B, C, D, E for the given ray.
540 */
541static
543 SCIP* scip, /**< SCIP data structure */
544 SCIP_Real* ray, /**< coefficients of ray */
545 SCIP_VAR** vars, /**< variables */
546 SCIP_Real* coefs, /**< buffer to store A, B, C, D, and E of cases 1, 2, 3, or 4a*/
547 SCIP_Real* coefs4b, /**< buffer to store A, B, C, D, and E of case 4b */
548 SCIP_Real* coefscondition, /**< buffer to store coefs for checking whether we are in case 4a or 4b */
549 SCIP_Bool usebounds, /**< TRUE if we want to separate non-negative bound */
550 SCIP_Real* ad, /**< coefs a and d for the hyperplane aTx + dTy <= 0 */
551 SCIP_Bool* success /**< FALSE if we need to abort generation because of numerics */
552 )
553{
554 SCIP_Real eigenvectors[16] = {1.0, 1.0, 0.0, 0.0, 0.0, 0.0, -1.0, 1.0, -1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0};
555 SCIP_Real eigenvalues[4] = {0.5, 0.5, -0.5, -0.5};
556 SCIP_Real eigencoef = 0.7071067811865475244008443621048490;
557 SCIP_Real* a;
558 SCIP_Real* b;
559 SCIP_Real* c;
560 SCIP_Real* d;
561 SCIP_Real* e;
564 SCIP_Real norm1;
565 SCIP_Real norm2;
566 int negidx;
567 int posidx;
568 int i;
569
570 *success = TRUE;
571
572 /* set all coefficients to zero */
573 memset(coefs, 0, 5 * sizeof(SCIP_Real));
574 memset(coefs4b, 0, 5 * sizeof(SCIP_Real));
575 norm1 = 0.0;
576 norm2 = 0.0;
577
578 a = coefs;
579 b = coefs + 1;
580 c = coefs + 2;
581 d = coefs + 3;
582 e = coefs + 4;
583
584 negidx = 2;
585 posidx = 0;
586 for( i = 0; i < 4; ++i )
587 {
588 int j;
589 SCIP_Real vzlp;
590 SCIP_Real vdotray;
591
592 vzlp = 0;
593 vdotray = 0;
594
595 /* compute eigenvec * ray and eigenvec * solution */
596 for( j = 0; j < 4; ++j )
597 {
598 vdotray += eigencoef * eigenvectors[4 * i + j] * ray[j];
599 vzlp += eigencoef * eigenvectors[4 * i + j] * SCIPvarGetLPSol(vars[j]);
600 }
601
602 if( eigenvalues[i] > 0 )
603 {
604 /* positive eigenvalue: compute D and E */
605 *d += eigenvalues[i] * vzlp * vdotray;
606 *e += eigenvalues[i] * SQR( vzlp );
607
608 if( usebounds )
609 {
610 norm1 += eigenvalues[i] * (1 - SQR( ad[posidx] )) * SQR( vzlp );
611 norm2 += sqrt( eigenvalues[i] ) * ad[posidx] * vzlp;
612 ++posidx;
613 }
614 }
615 else
616 {
617 /* negative eigenvalue: compute A, B, and C */
618 *a -= eigenvalues[i] * SQR( vdotray );
619 *b -= 2.0 * eigenvalues[i] * vzlp * vdotray;
620 *c -= eigenvalues[i] * SQR( vzlp );
621
622 if( usebounds )
623 {
624 coefs4b[0] -= eigenvalues[i] * (1 - SQR( ad[negidx] )) * SQR( vdotray );
625 coefs4b[1] -= 2.0 * eigenvalues[i] * (1 - SQR( ad[negidx] )) * vzlp * vdotray;
626 coefs4b[2] -= eigenvalues[i] * (1 - SQR( ad[negidx] )) * SQR( vzlp );
627 coefs4b[3] += sqrt( -eigenvalues[i] ) * ad[negidx] * vdotray;
628 coefs4b[4] += sqrt( -eigenvalues[i] ) * ad[negidx] * vzlp;
629 ++negidx;
630 }
631 }
632 }
633
634 assert(*e > 0);
635
636 if( sqrt( *c ) - sqrt( *e ) >= 0.0 )
637 {
638 assert(sqrt( *c ) - sqrt( *e ) < 1e-6);
639 *success = FALSE;
640 return SCIP_OKAY;
641 }
642
643 /* finish computation of coefficients when using bounds */
644 if( usebounds )
645 {
646 coefscondition[0] = norm2 / sqrt( *e );
647 coefscondition[1] = coefs4b[3];
648 coefscondition[2] = coefs4b[4];
649
650 coefs4b[0] *= norm1 / *e;
651 coefs4b[1] *= norm1 / *e;
652 coefs4b[2] *= norm1 / *e;
653 coefs4b[3] *= norm2 / sqrt( *e );
654 coefs4b[4] *= norm2 / sqrt( *e );
655
656 coefs4b[3] += *d / sqrt( *e );
657 coefs4b[4] += sqrt( *e );
658
659 assert( sqrt( coefs4b[2] ) - coefs4b[4] < 0.0 );
660 }
661
662 /* finish computation of D and E */
663 *e = sqrt( *e );
664 *d /= *e;
665
666 /* maybe we want to avoid a large dynamism between A, B and C */
667 max = 0.0;
669 for( i = 0; i < 3; ++i )
670 {
671 SCIP_Real absval;
672
673 absval = ABS(coefs[i]);
674 if( max < absval )
675 max = absval;
676 if( absval != 0.0 && absval < min )
677 min = absval;
678 }
679
680 if( SCIPisHugeValue(scip, max / min) )
681 {
682#ifdef DEBUG_INTERSECTIONCUT
683 printf("Bad numerics: max(A,B,C)/min(A,B,C) is too large (%g)\n", max / min);
684#endif
685 *success = FALSE;
686 return SCIP_OKAY;
687 }
688
689 /* some sanity checks */
690 assert(*c >= 0); /* radicand at zero */
691 assert(sqrt( *c ) - *e < 0); /* the function at 0 must be negative */
692 assert(*a >= 0); /* the function inside the root is convex */
693
694#ifdef DEBUG_INTERSECTIONCUT
695 SCIPinfoMessage(scip, NULL, "Restriction yields: a,b,c,d,e %g %g %g %g %g\n", coefs[0], coefs[1], coefs[2], coefs[3], coefs[4]);
696#endif
697
698 return SCIP_OKAY;
699}
700
701/** returns phi(zlp + t * ray) = sqrt(A t^2 + B t + C) - (D t + E) */ /*lint -e{715}*/
702static
704 SCIP* scip, /**< SCIP data structure */
705 SCIP_Real t, /**< argument of phi restricted to ray */
706 SCIP_Real a, /**< value of A */
707 SCIP_Real b, /**< value of B */
708 SCIP_Real c, /**< value of C */
709 SCIP_Real d, /**< value of D */
710 SCIP_Real e /**< value of E */
711 )
712{
713#ifdef INTERCUTS_DBLDBL
714 SCIP_Real QUAD(lin);
715 SCIP_Real QUAD(disc);
716 SCIP_Real QUAD(tmp);
717 SCIP_Real QUAD(root);
718
719 /* d * t + e */
720 SCIPquadprecProdDD(lin, d, t);
721 SCIPquadprecSumQD(lin, lin, e);
722
723 /* a * t * t */
724 SCIPquadprecSquareD(disc, t);
725 SCIPquadprecProdQD(disc, disc, a);
726
727 /* b * t */
728 SCIPquadprecProdDD(tmp, b, t);
729
730 /* a * t * t + b * t */
731 SCIPquadprecSumQQ(disc, disc, tmp);
732
733 /* a * t * t + b * t + c */
734 SCIPquadprecSumQD(disc, disc, c);
735
736 /* sqrt(above): can't take sqrt of 0! */
737 if( QUAD_TO_DBL(disc) == 0 )
738 {
739 QUAD_ASSIGN(root, 0.0);
740 }
741 else
742 {
743 SCIPquadprecSqrtQ(root, disc);
744 }
745
746 /* final result */
747 QUAD_SCALE(lin, -1.0);
748 SCIPquadprecSumQQ(tmp, root, lin);
749
750 assert(!SCIPisInfinity(scip, t) || QUAD_TO_DBL(tmp) <= 0);
751
752 return QUAD_TO_DBL(tmp);
753#else
754 return sqrt( a * t * t + b * t + c ) - ( d * t + e );
755#endif
756}
757
758/** helper function of computeRoot: we want phi to be <= 0 */
759static
761 SCIP* scip, /**< SCIP data structure */
762 SCIP_Real a, /**< value of A */
763 SCIP_Real b, /**< value of B */
764 SCIP_Real c, /**< value of C */
765 SCIP_Real d, /**< value of D */
766 SCIP_Real e, /**< value of E */
767 SCIP_Real* sol /**< buffer to store solution; also gives initial point */
768 )
769{
770 SCIP_Real lb = 0.0;
771 SCIP_Real ub = *sol;
772 SCIP_Real curr;
773 int i;
774
775 for( i = 0; i < BINSEARCH_MAXITERS; ++i )
776 {
777 SCIP_Real phival;
778
779 curr = (lb + ub) / 2.0;
780 phival = evalPhiAtRay(scip, curr, a, b, c, d, e);
781#ifdef INTERCUT_MOREDEBUG
782 printf("%d: lb,ub %.10f, %.10f. curr = %g -> phi at curr %g -> phi at lb %g \n", i, lb, ub, curr, phival, evalPhiAtRay(scip, lb, a, b, c, d, e));
783#endif
784
785 if( phival <= 0.0 )
786 {
787 lb = curr;
788 if( SCIPisFeasZero(scip, phival) || SCIPisFeasEQ(scip, ub, lb) )
789 break;
790 }
791 else
792 ub = curr;
793 }
794
795 *sol = lb;
796}
797
798/** checks if we are in case 4a, i.e., if
799 * (num(xhat_{r+1}(zlp)) / E) * sqrt(A * tsol^2 + B * tsol + C) + w(ray) * tsol + num(yhat_{s+1}(zlp)) <= 0
800 */
801static
803 SCIP_Real tsol, /**< t in the above formula */
804 SCIP_Real* coefs, /**< coefficients A, B, C, D, and E of case 4a */
805 SCIP_Real* coefscondition /**< extra coefficients needed for the evaluation of the condition:
806 * num(xhat_{r+1}(zlp)) / E; w(ray); num(yhat_{s+1}(zlp)) */
807 )
808{
809 return (coefscondition[0] * sqrt( coefs[0] * SQR( tsol ) + coefs[1] * tsol + coefs[2] ) + coefscondition[1] *
810 tsol + coefscondition[2]) <= 0.0;
811}
812
813/** finds smallest positive root phi by finding the smallest positive root of
814 * (A - D^2) t^2 + (B - 2 D*E) t + (C - E^2) = 0
815 *
816 * However, we are conservative and want a solution such that phi is negative, but close to 0;
817 * thus we correct the result with a binary search
818 */
819static
821 SCIP* scip, /**< SCIP data structure */
822 SCIP_Real* coefs /**< value of A */
823 )
824{
825 SCIP_Real sol;
826 SCIP_INTERVAL bounds;
827 SCIP_INTERVAL result;
828 SCIP_Real a = coefs[0];
829 SCIP_Real b = coefs[1];
830 SCIP_Real c = coefs[2];
831 SCIP_Real d = coefs[3];
832 SCIP_Real e = coefs[4];
833
834 /* there is an intersection point if and only if sqrt(A) > D: here we are beliving in math, this might cause
835 * numerical issues
836 */
837 if( sqrt( a ) <= d )
838 {
839 sol = SCIPinfinity(scip);
840
841 return sol;
842 }
843
845
846 /* SCIPintervalSolveUnivariateQuadExpressionPositiveAllScalar finds all x such that a x^2 + b x >= c and x in bounds.
847 * it is known that if tsol is the root we are looking for, then gamma(zlp + t * ray) <= 0 between 0 and tsol, thus
848 * tsol is the smallest t such that (A - D^2) t^2 + (B - 2 D*E) t + (C - E^2) >= 0
849 */
851 e, -(c - e * e), bounds);
852
853 /* it can still be empty because of our infinity, I guess... */
855
856 /* check that solution is acceptable, ideally it should be <= 0, however when it is positive, we trigger a binary
857 * search to make it negative. This binary search might return a solution point that is not at accurately 0 as the
858 * one obtained from the function above. Thus, it might fail to satisfy the condition of case 4b in some cases, e.g.,
859 * ex8_3_1, bchoco05, etc
860 */
861 if( evalPhiAtRay(scip, sol, a, b, c, d, e) <= 1e-10 )
862 {
863#ifdef INTERCUT_MOREDEBUG
864 printf("interval solution returned %g -> phival = %g, believe it\n", sol, evalPhiAtRay(sol, a, b, c, d, e));
865 printf("don't do bin search\n");
866#endif
867
868 return sol;
869 }
870 else
871 {
872 /* perform a binary search to make it negative: this might correct a wrong infinity (e.g. crudeoil_lee1_05) */
873#ifdef INTERCUT_MOREDEBUG
874 printf("do bin search because phival is %g\n", evalPhiAtRay(scip, sol, a, b, c, d, e));
875#endif
876 doBinarySearch(scip, a, b, c, d, e, &sol);
877 }
878
879 return sol;
880}
881
882/** The maximal S-free set is gamma(z) <= 0; we find the intersection point of the ray `ray` starting from zlp with the
883 * boundary of the S-free set.
884 * That is, we find t >= 0 such that gamma(zlp + t * ray) = 0.
885 *
886 * In cases 1,2, and 3, gamma is of the form
887 * gamma(zlp + t * ray) = sqrt(A t^2 + B t + C) - (D t + E)
888 *
889 * In the case 4 gamma is of the form
890 * gamma(zlp + t * ray) = sqrt(A t^2 + B t + C) - (D t + E) if some condition holds
891 * sqrt(A' t^2 + B' t + C') - (D' t + E') otherwise
892 *
893 * It can be shown (given the special properties of gamma) that the smallest positive root of each function of the form
894 * sqrt(a t^2 + b t + c) - (d t + e)
895 * is the same as the smallest positive root of the quadratic equation:
896 * (sqrt(a t^2 + b t + c) - (d t + e)) * (sqrt(a t^2 + b t + c) + (d t + e)) = 0
897 * <==> (a - d^2) t^2 + (b - 2 d*e) t + (c - e^2) = 0
898 *
899 * So, in cases 1, 2, and 3, this function just returns the solution of the above equation.
900 * In case 4, it first solves the equation assuming we are in the first piece.
901 * If there is no solution, then the second piece can't have a solution (first piece >= second piece for all t)
902 * Then we check if the solution satisfies the condition.
903 * If it doesn't then we solve the equation for the second piece.
904 * If it has a solution, then it _has_ to be the solution.
905 */
906static
908 SCIP* scip, /**< SCIP data structure */
909 SCIP_Bool usebounds, /**< whether we are in case 4 or not */
910 SCIP_Real* coefs, /**< values of A, B, C, D, and E of cases 1, 2, 3, or 4a */
911 SCIP_Real* coefs4b, /**< values of A, B, C, D, and E of case 4b */
912 SCIP_Real* coefscondition /**< values needed to evaluate condition of case 4 */
913 )
914{
915 SCIP_Real sol;
916 SCIP_Real sol4b;
917
918 assert(coefs != NULL);
919
920 if( ! usebounds )
921 return computeRoot(scip, coefs);
922
923 assert(coefs4b != NULL);
924 assert(coefscondition != NULL);
925
926 /* compute solution of first piece */
927 sol = computeRoot(scip, coefs);
928
929 /* if there is no solution --> second piece doesn't have solution */
930 if( SCIPisInfinity(scip, sol) )
931 {
932 /* this assert fails on multiplants_mtg5 the problem is that sqrt(A) <= D in 4a but not in 4b,
933 * now, this is impossible since the phi4a >= phi4b, so actually sqrt(A) is 10e-15 away from
934 * D in 4b
935 */
936 /* assert(SCIPisInfinity(scip, computeRoot(scip, coefs4b))); */
937 return sol;
938 }
939
940 /* if solution of 4a is in 4a, then return */
941 if( isCase4a(sol, coefs, coefscondition) )
942 return sol;
943
944 /* not on 4a --> then the intersection point is whatever 4b says: as phi4a >= phi4b, the solution of phi4b should
945 * always be larger (but shouldn't be equal at this point given that isCase4a failed, and the condition function
946 * evaluates to 0 when phi4a == phi4b) than the solution of phi4a; However, because of numerics (or limits in the
947 * binary search) we can find a slightly smaller solution; thus, we just keep the larger one
948 */
949 sol4b = computeRoot(scip, coefs4b);
950
951 return MAX(sol, sol4b);
952}
953
954/** adds cutcoef * (col - col*) to rowprep */
955static
957 SCIP* scip, /**< SCIP data structure */
958 SCIP_ROWPREP* rowprep, /**< rowprep to store intersection cut */
959 SCIP_Real cutcoef, /**< cut coefficient */
960 SCIP_COL* col /**< column to add to rowprep */
961 )
962{
963 assert(col != NULL);
964
965#ifdef DEBUG_INTERCUTS_NUMERICS
966 SCIPinfoMessage(scip, NULL, "adding col %s to cut. %g <= col <= %g\n", SCIPvarGetName(SCIPcolGetVar(col)),
968 SCIPinfoMessage(scip, NULL, "col is active at %s. Value %.15f\n", SCIPcolGetBasisStatus(col) == SCIP_BASESTAT_LOWER ? "lower bound" :
969 "upper bound" , SCIPcolGetPrimsol(col));
970#endif
971
972 SCIP_CALL( SCIPaddRowprepTerm(scip, rowprep, SCIPcolGetVar(col), cutcoef) );
973 SCIProwprepAddConstant(rowprep, -cutcoef * SCIPcolGetPrimsol(col) );
974
975 return SCIP_OKAY;
976}
977
978/** adds cutcoef * (slack - slack*) to rowprep
979 *
980 * row is lhs <= <coefs, vars> + constant <= rhs, thus slack is defined by
981 * slack + <coefs, vars> + constant = side
982 * If row (slack) is at upper, it means that <coefs,vars*> + constant = rhs, and so
983 * slack* = side - rhs --> slack - slack* = rhs - <coefs, vars> - constant.
984 * If row (slack) is at lower, then <coefs,vars*> + constant = lhs, and so
985 * slack* = side - lhs --> slack - slack* = lhs - <coefs, vars> - constant.
986 */
987static
989 SCIP* scip, /**< SCIP data structure */
990 SCIP_ROWPREP* rowprep, /**< rowprep to store intersection cut */
991 SCIP_Real cutcoef, /**< cut coefficient */
992 SCIP_ROW* row, /**< row, whose slack we are adding to rowprep */
993 SCIP_Bool* success /**< buffer to store whether the row is nonbasic enough */
994 )
995{
996 int i;
997 SCIP_COL** rowcols;
998 SCIP_Real* rowcoefs;
999 int nnonz;
1000
1001 assert(row != NULL);
1002
1003 rowcols = SCIProwGetCols(row);
1004 rowcoefs = SCIProwGetVals(row);
1005 nnonz = SCIProwGetNLPNonz(row);
1006
1007#ifdef DEBUG_INTERCUTS_NUMERICS
1008 SCIPinfoMessage(scip, NULL, "adding slack var row_%d to cut. %g <= row <= %g\n", SCIProwGetLPPos(row), SCIProwGetLhs(row), SCIProwGetRhs(row));
1009 SCIPinfoMessage(scip, NULL, "row is active at %s = %.15f Activity %.15f\n", SCIProwGetBasisStatus(row) == SCIP_BASESTAT_LOWER ? "lhs" :
1011 SCIPgetRowActivity(scip, row));
1012#endif
1013
1015 {
1016 assert(!SCIPisInfinity(scip, -SCIProwGetLhs(row)));
1018 {
1019 *success = FALSE;
1020 return SCIP_OKAY;
1021 }
1022
1023 SCIProwprepAddConstant(rowprep, SCIProwGetLhs(row) * cutcoef);
1024 }
1025 else
1026 {
1027 assert(!SCIPisInfinity(scip, SCIProwGetRhs(row)));
1029 {
1030 *success = FALSE;
1031 return SCIP_OKAY;
1032 }
1033
1034 SCIProwprepAddConstant(rowprep, SCIProwGetRhs(row) * cutcoef);
1035 }
1036
1037 for( i = 0; i < nnonz; i++ )
1038 {
1039 SCIP_CALL( SCIPaddRowprepTerm(scip, rowprep, SCIPcolGetVar(rowcols[i]), -rowcoefs[i] * cutcoef) );
1040 }
1041
1042 SCIProwprepAddConstant(rowprep, -SCIProwGetConstant(row) * cutcoef);
1043
1044 return SCIP_OKAY;
1045}
1046
1047/** get the tableau rows of the variables in vars */
1048static
1050 SCIP* scip, /**< SCIP data structure */
1051 SCIP_VAR** vars, /**< variables in the minor */
1052 int* basicvarpos2tableaurow,/**< map between basic var and its tableau row */
1053 SCIP_HASHMAP* tableau, /**< map between var an its tableau row */
1054 SCIP_Real** tableaurows, /**< buffer to store tableau row */
1055 SCIP_Bool* success /**< set to TRUE if no variable had basisstat = ZERO */
1056 )
1057{
1058 int v;
1059 int nrows;
1060 int ncols;
1061
1062 *success = TRUE;
1063
1064 nrows = SCIPgetNLPRows(scip);
1065 ncols = SCIPgetNLPCols(scip);
1066
1067 /* check if we have the tableau row of the variable and if not compute it */
1068 for( v = 0; v < 4; ++v )
1069 {
1070 if( ! SCIPhashmapExists(tableau, (void*)vars[v]) )
1071 {
1072 SCIP_COL* col;
1073
1074 /* get column of variable */
1075 col = SCIPvarGetCol(vars[v]);
1076
1077 /* if variable is basic, then get its tableau row and insert it in the hashmap */
1079 {
1080 int lppos;
1081 SCIP_Real* densetableaurow;
1082
1083 lppos = SCIPcolGetLPPos(col);
1084 SCIP_CALL( SCIPallocBufferArray(scip, &densetableaurow, ncols + nrows) );
1085
1086 SCIP_CALL( SCIPgetLPBInvRow(scip, basicvarpos2tableaurow[lppos], &densetableaurow[ncols], NULL, NULL) );
1087 SCIP_CALL( SCIPgetLPBInvARow(scip, basicvarpos2tableaurow[lppos], &densetableaurow[ncols], densetableaurow, NULL, NULL) );
1088
1089 /* insert tableau row in hashmap*/
1090 SCIP_CALL( SCIPhashmapInsert(tableau, (void*)vars[v], (void *)densetableaurow) );
1091 }
1092 else if( SCIPcolGetBasisStatus(col) == SCIP_BASESTAT_ZERO )
1093 {
1094 *success = FALSE;
1095 return SCIP_OKAY; /* don't even bother */
1096 }
1097 else
1098 {
1099 SCIP_CALL( SCIPhashmapInsert(tableau, (void*)vars[v], (void *)NULL) );
1100 }
1101 }
1102
1103 /* get tableau row of var */
1104 tableaurows[v] = (SCIP_Real *)SCIPhashmapGetImage(tableau, (void*)vars[v]);
1105 }
1106 return SCIP_OKAY;
1107}
1108
1109/** computes the cut coefs of the non-basic (non-slack) variables (correspond to cols) and adds them to the
1110 * intersection cut
1111 */
1112static
1114 SCIP* scip, /**< SCIP data structure */
1115 SCIP_VAR** vars, /**< variables */
1116 SCIP_Real** tableaurows, /**< tableau rows corresponding to the variables in vars */
1117 SCIP_ROWPREP* rowprep, /**< store cut */
1118 SCIP_Real* rays, /**< buffer to store rays */
1119 int* nrays, /**< pointer to store number of nonzero rays */
1120 int* rayslppos, /**< buffer to store lppos of nonzero rays */
1121 SCIP_Real* interpoints, /**< buffer to store intersection points or NULL if not needed */
1122 SCIP_Bool usebounds, /**< TRUE if we want to separate non-negative bound */
1123 SCIP_Real* ad, /**< coefs a and d for the hyperplane aTx + dTy <= 0 */
1124 SCIP_Bool* success /**< pointer to store whether the generation of cutcoefs was successful */
1125 )
1126{
1127 int i;
1128 int ncols;
1129 SCIP_COL** cols;
1130
1131 *success = TRUE;
1132
1133 /* loop over non-basic (non-slack) variables */
1134 cols = SCIPgetLPCols(scip);
1135 ncols = SCIPgetNLPCols(scip);
1136 for( i = 0; i < ncols; ++i )
1137 {
1138 SCIP_COL* col;
1139 SCIP_Real coefs[5];
1140 SCIP_Real coefs4b[5];
1141 SCIP_Real coefscondition[3];
1142 SCIP_Real factor;
1143 SCIP_Bool israynonzero;
1144 SCIP_Real cutcoef;
1145 SCIP_Real interpoint;
1146 int v;
1147
1148 col = cols[i];
1149
1150 /* set factor to store entries of ray as = [-BinvL, BinvU] */
1152 factor = -1.0;
1154 factor = 1.0;
1155 else if( SCIPcolGetBasisStatus(col) == SCIP_BASESTAT_ZERO )
1156 {
1157 *success = FALSE;
1158 return SCIP_OKAY;
1159 }
1160 else
1161 continue;
1162
1163 /* build the ray */
1164 israynonzero = FALSE;
1165 for( v = 0; v < 4; ++v )
1166 {
1167 if( tableaurows[v] != NULL )
1168 rays[(*nrays) * 4 + v] = factor * (SCIPisZero(scip, tableaurows[v][i]) ? 0.0 : tableaurows[v][i]);
1169 else
1170 {
1171 if( col == SCIPvarGetCol(vars[v]) )
1172 rays[(*nrays) * 4 + v] = -factor;
1173 else
1174 rays[(*nrays) * 4 + v] = 0.0;
1175 }
1176
1177 israynonzero = israynonzero || (rays[(*nrays) * 4 + v] != 0.0);
1178 }
1179
1180 /* do nothing if ray is 0 */
1181 if( ! israynonzero )
1182 continue;
1183
1184 /* compute the cut */
1185 SCIP_CALL( computeRestrictionToRay(scip, &rays[(*nrays) * 4], vars, coefs, coefs4b, coefscondition, usebounds,
1186 ad, success) );
1187
1188 if( *success == FALSE )
1189 return SCIP_OKAY;
1190
1191 /* compute intersection point */
1192 interpoint = computeIntersectionPoint(scip, usebounds, coefs, coefs4b, coefscondition);
1193
1194 /* store intersection points */
1195 interpoints[*nrays] = interpoint;
1196
1197 /* remember lppos */
1198 rayslppos[*nrays] = i;
1199
1200 /* count nonzero rays */
1201 *nrays += 1;
1202
1203 /* compute cut coef */
1204 cutcoef = SCIPisInfinity(scip, interpoint) ? 0.0 : 1.0 / interpoint;
1205
1206 /* add var to cut: if variable is nonbasic at upper we have to flip sign of cutcoef */
1209 cutcoef, col) );
1210 }
1211
1212 return SCIP_OKAY;
1213}
1214
1215/** computes the cut coefs of the non-basic slack variables (correspond to rows) and adds them to the
1216 * intersection cut
1217 */
1218static
1220 SCIP* scip, /**< SCIP data structure */
1221 SCIP_VAR** vars, /**< variables */
1222 SCIP_Real** tableaurows, /**< tableau rows corresponding to the variables in vars */
1223 SCIP_ROWPREP* rowprep, /**< store cut */
1224 SCIP_Real* rays, /**< buffer to store rays */
1225 int* nrays, /**< pointer to store number of nonzero rays */
1226 int* rayslppos, /**< buffer to store lppos of nonzero rays */
1227 SCIP_Real* interpoints, /**< buffer to store intersection points or NULL if not needed */
1228 SCIP_Bool usebounds, /**< TRUE if we want to separate non-negative bound */
1229 SCIP_Real* ad, /**< coefs a and d for the hyperplane aTx + dTy <= 0 */
1230 SCIP_Bool* success /**< pointer to store whether the generation of cutcoefs was successful */
1231 )
1232{
1233 int i;
1234 int nrows;
1235 int ncols;
1236 SCIP_ROW** rows;
1237
1238 nrows = SCIPgetNLPRows(scip);
1239 ncols = SCIPgetNLPCols(scip);
1240
1241 *success = TRUE;
1242
1243 /* loop over non-basic slack variables */
1244 rows = SCIPgetLPRows(scip);
1245 for( i = 0; i < nrows; ++i )
1246 {
1247 SCIP_ROW* row;
1248 SCIP_Real coefs[5];
1249 SCIP_Real coefs4b[5];
1250 SCIP_Real coefscondition[3];
1251 SCIP_Real factor;
1252 SCIP_Bool israynonzero;
1253 SCIP_Real cutcoef;
1254 SCIP_Real interpoint;
1255 int v;
1256
1257 row = rows[i];
1258
1259 /* set factor to store entries of ray as = [BinvL, -BinvU] */
1261 factor = 1.0;
1263 factor = -1.0;
1264 else if( SCIProwGetBasisStatus(row) == SCIP_BASESTAT_ZERO )
1265 {
1266 *success = FALSE;
1267 return SCIP_OKAY;
1268 }
1269 else
1270 continue;
1271
1272 /* build the ray */
1273 israynonzero = FALSE;
1274 for( v = 0; v < 4; ++v )
1275 {
1276 int idx;
1277
1278 idx = ncols + i;
1279
1280 if( tableaurows[v] != NULL )
1281 rays[(*nrays) * 4 + v] = factor * (SCIPisZero(scip, tableaurows[v][idx]) ? 0.0 : tableaurows[v][idx]);
1282 else
1283 {
1284 /* TODO: We assume that slack variables can never occure in the minor. This is correct, right? */
1285 rays[(*nrays) * 4 + v] = 0.0;
1286 }
1287
1288 israynonzero = israynonzero || (rays[(*nrays) * 4 + v] != 0.0);
1289 }
1290
1291 /* do nothing if ray is 0 */
1292 if( ! israynonzero )
1293 continue;
1294
1295 /* compute the cut */
1296 SCIP_CALL( computeRestrictionToRay(scip, &rays[(*nrays) * 4], vars, coefs, coefs4b, coefscondition, usebounds,
1297 ad, success) );
1298
1299 if( *success == FALSE )
1300 return SCIP_OKAY;
1301
1302 /* compute intersection point */
1303 interpoint = computeIntersectionPoint(scip, usebounds, coefs, coefs4b, coefscondition);
1304
1305 /* store intersection points */
1306 interpoints[*nrays] = interpoint;
1307
1308 /* store lppos of ray, make it negative so we can differentiate between cols and rows */
1309 rayslppos[*nrays] = -i - 1;
1310
1311 /* count nonzero rays */
1312 *nrays += 1;
1313
1314 /* compute cut coef */
1315 cutcoef = SCIPisInfinity(scip, interpoint) ? 0.0 : 1.0 / interpoint;
1316
1317 /* add var to cut: if variable is nonbasic at upper we have to flip sign of cutcoef */
1319
1321 -cutcoef, row, success) ); /* rows have flipper base status! */
1322 }
1323
1324 return SCIP_OKAY;
1325}
1326
1327/* checks if two rays are linearly dependent */
1328static
1330 SCIP* scip, /**< SCIP data structure */
1331 SCIP_Real* ray1, /**< coefficients of ray 1 */
1332 SCIP_Real* ray2, /**< coefficients of ray 2 */
1333 SCIP_Real* coef /**< pointer to store coef (s.t. r1 = coef * r2) in case rays are dependent */
1334 )
1335{
1336 int i;
1337
1338 *coef = 0.0;
1339
1340 for( i = 0; i < 4; ++i )
1341 {
1342 /* rays cannot be dependent if one ray has zero entry and the other one doesn't */
1343 if( (SCIPisZero(scip, ray1[i]) && ! SCIPisZero(scip, ray2[i])) ||
1344 (! SCIPisZero(scip, ray1[i]) && SCIPisZero(scip, ray2[i])) )
1345 {
1346 return FALSE;
1347 }
1348
1349 if( *coef != 0.0 )
1350 {
1351 /* cannot be dependent if the coefs aren't equal for all entries */
1352 if( ! SCIPisFeasEQ(scip, *coef, ray1[i] / ray2[i]) )
1353 return FALSE;
1354 }
1355 else
1356 *coef = ray1[i] / ray2[i];
1357 }
1358
1359 return TRUE;
1360}
1361
1362/** finds the smallest negative steplength for the current ray r_idx such that the combination
1363 * of r_idx with all rays not in the recession cone is in the recession cone
1364 */
1365static
1367 SCIP* scip, /**< SCIP data structure */
1368 SCIP_Real* rays, /**< rays */
1369 int nrays, /**< number of nonzero rays */
1370 int idx, /**< index of current ray we want to find rho for */
1371 SCIP_Real* interpoints, /**< intersection points of nonzero rays */
1372 SCIP_VAR** vars, /**< variables */
1373 SCIP_Real* rho, /**< pointer to store the optimal rho */
1374 SCIP_Bool usebounds, /**< TRUE if we want to separate non-negative bound */
1375 SCIP_Real* ad, /**< coefs a and d for the hyperplane aTx + dTy <= 0 */
1376 SCIP_Bool* success /**< TRUE if computation of rho was successful */
1377 )
1378{
1379 int i;
1380
1381 *success = TRUE;
1382
1383 /* go through all rays not in the recession cone and compute the largest negative steplength possible. The
1384 * smallest of them is then the steplength rho we use for the current ray */
1385 *rho = 0;
1386 for( i = 0; i < nrays; ++i )
1387 {
1388 SCIP_Real currentrho;
1389 SCIP_Real coef;
1390
1391 if( SCIPisInfinity(scip, interpoints[i]) )
1392 continue;
1393
1394 /* if the rays are linearly independent, we don't need to search for rho */
1395 if( raysAreDependent(scip, &rays[4 * i], &rays[4 * idx], &coef) )
1396 currentrho = coef * interpoints[i];
1397 else
1398 {
1399 SCIP_Real lb;
1400 SCIP_Real ub;
1401 SCIP_Real alpha;
1402 int j;
1403
1404 /* do binary search by lookig at the convex combinations of r_i and r_j */
1405 lb = 0.0;
1406 ub = 1.0;
1407
1408 for( j = 0; j < BINSEARCH_MAXITERS; ++j )
1409 {
1410 SCIP_Real coefs[5];
1411 SCIP_Real coefs4b[5];
1412 SCIP_Real coefscondition[3];
1413 SCIP_Real newray[4];
1414 SCIP_Real interpoint;
1415 int k;
1416
1417 alpha = (lb + ub) / 2.0;
1418
1419 /* build the ray alpha * ray_i + (1 - alpha) * ray_idx */
1420 for( k = 0; k < 4; ++k )
1421 newray[k] = alpha * rays[4 * i + k] - (1 - alpha) * rays[4 * idx + k];
1422
1423 /* restrict phi to the "new" ray */
1424 SCIP_CALL( computeRestrictionToRay(scip, newray, vars, coefs, coefs4b, coefscondition, usebounds,
1425 ad, success) );
1426
1427 if( ! *success )
1428 return SCIP_OKAY;
1429
1430 /* check if restriction to "new" ray is numerically nasty. If so, treat the corresponding rho as if phi is
1431 * positive
1432 */
1433
1434 /* compute intersection point */
1435 interpoint = computeIntersectionPoint(scip, usebounds, coefs, coefs4b, coefscondition);
1436
1437 /* no root exists */
1438 if( SCIPisInfinity(scip, interpoint) )
1439 {
1440 lb = alpha;
1441 if( SCIPisEQ(scip, ub, lb) )
1442 break;
1443 }
1444 else
1445 ub = alpha;
1446 }
1447
1448 /* now we found the best convex combination which we use to derive the corresponding coef. If alpha = 0, we
1449 * cannot move the ray in the recession cone, i.e. strengthening is not possible */
1450 if( SCIPisZero(scip, alpha) )
1451 {
1452 *rho = -SCIPinfinity(scip);
1453 return SCIP_OKAY;
1454 }
1455 else
1456 currentrho = (alpha - 1) * interpoints[i] / alpha;
1457 }
1458
1459 if( currentrho < *rho )
1460 *rho = currentrho;
1461 }
1462
1463 return SCIP_OKAY;
1464}
1465
1466/** computes negative steplengths for the rays that are in the recession cone of the S-free set, i.e.,
1467 * which have an infinite intersection point.
1468 */
1469static
1471 SCIP* scip, /**< SCIP data structure */
1472 SCIP_VAR** vars, /**< variables */
1473 SCIP_Real* rays, /**< rays */
1474 int nrays, /**< number of nonzero rays */
1475 int* rayslppos, /**< lppos of nonzero rays */
1476 SCIP_Real* interpoints, /**< intersection points */
1477 SCIP_ROWPREP* rowprep, /**< rowprep for the generated cut */
1478 SCIP_Bool usebounds, /**< TRUE if we want to separate non-negative bound */
1479 SCIP_Real* ad, /**< coefs a and d for the hyperplane aTx + dTy <= 0 */
1480 SCIP_Bool* success /**< if a cut candidate could be computed */
1481 )
1482{
1483 SCIP_COL** cols;
1484 SCIP_ROW** rows;
1485 int i;
1486
1487 *success = TRUE;
1488
1489 cols = SCIPgetLPCols(scip);
1490 rows = SCIPgetLPRows(scip);
1491
1492 /* go through all intersection points that are equal to infinity -> these correspond to the rays which are in the
1493 * recession cone of C, i.e. the rays for which we (possibly) can compute a negative steplength */
1494 for( i = 0; i < nrays ; ++i )
1495 {
1496 SCIP_Real rho;
1497 SCIP_Real cutcoef;
1498 int lppos;
1499
1500 if( !SCIPisInfinity(scip, interpoints[i]) )
1501 continue;
1502
1503 /* compute the smallest rho */
1504 SCIP_CALL( findRho(scip, rays, nrays, i, interpoints, vars, &rho, usebounds, ad, success) );
1505
1506 if( ! *success )
1507 continue;
1508
1509 /* compute cut coef */
1510 cutcoef = SCIPisInfinity(scip, -rho) ? 0.0 : 1.0 / rho;
1511
1512 /* add var to cut: if variable is nonbasic at upper we have to flip sign of cutcoef */
1513 lppos = rayslppos[i];
1514 if( lppos < 0 )
1515 {
1516 lppos = -lppos - 1;
1517
1518 assert(SCIProwGetBasisStatus(rows[lppos]) == SCIP_BASESTAT_LOWER || SCIProwGetBasisStatus(rows[lppos]) ==
1520
1521 SCIP_CALL( addRowToCut(scip, rowprep, SCIProwGetBasisStatus(rows[lppos]) == SCIP_BASESTAT_UPPER ? cutcoef :
1522 -cutcoef, rows[lppos], success) ); /* rows have flipped base status! */
1523
1524 if( ! *success )
1525 return SCIP_OKAY;
1526 }
1527 else
1528 {
1529 assert(SCIPcolGetBasisStatus(cols[lppos]) == SCIP_BASESTAT_UPPER || SCIPcolGetBasisStatus(cols[lppos]) ==
1531 SCIP_CALL( addColToCut(scip, rowprep, SCIPcolGetBasisStatus(cols[lppos]) == SCIP_BASESTAT_UPPER ? -cutcoef :
1532 cutcoef, cols[lppos]) );
1533 }
1534 }
1535
1536 return SCIP_OKAY;
1537}
1538
1539/** separates cuts for stored principal minors */
1540static
1542 SCIP* scip, /**< SCIP data structure */
1543 SCIP_SEPA* sepa, /**< separator */
1544 SCIP_SEPADATA* sepadata, /**< separator data */
1545 SCIP_VAR* xik, /**< variable X_ik = x_i * x_k */
1546 SCIP_VAR* xil, /**< variable X_il = x_i * x_l */
1547 SCIP_VAR* xjk, /**< variable X_jk = x_j * x_k */
1548 SCIP_VAR* xjl, /**< variable X_jl = x_j * x_l */
1549 SCIP_Bool* isxikdiag, /**< is X_ik diagonal? (i.e. i = k) */
1550 SCIP_Bool* isxildiag, /**< is X_il diagonal? (i.e. i = l) */
1551 SCIP_Bool* isxjkdiag, /**< is X_jk diagonal? (i.e. j = k) */
1552 SCIP_Bool* isxjldiag, /**< is X_jl diagonal? (i.e. j = l) */
1553 int* basicvarpos2tableaurow,/**< map from basic var to its tableau row */
1554 SCIP_HASHMAP* tableau, /**< map from var to its tableau row */
1555 SCIP_RESULT* result /**< pointer to store the result of the separation call */
1556 )
1557{
1558 SCIP_ROWPREP* rowprep;
1559 SCIP_VAR* vars[4] = {xik, xjl, xil, xjk};
1560 SCIP_Real* tableaurows[4];
1561 SCIP_Real* interpoints;
1562 SCIP_Real* rays;
1563 int nrays;
1564 int* rayslppos;
1565 int ncols;
1566 int nrows;
1567 SCIP_Bool success;
1568 SCIP_Real ad[4] = {0.0, 0.0, 0.0, 0.0};
1569 SCIP_Real solxik;
1570 SCIP_Real solxil;
1571 SCIP_Real solxjk;
1572 SCIP_Real solxjl;
1573 SCIP_Real viol;
1574
1575 ncols = SCIPgetNLPCols(scip);
1576 nrows = SCIPgetNLPRows(scip);
1577
1578 /* allocate memory for intersection points */
1579 SCIP_CALL( SCIPallocBufferArray(scip, &interpoints, ncols + nrows) );
1580
1581 /* allocate memory for rays */
1582 SCIP_CALL( SCIPallocBufferArray(scip, &rays, 4 * (ncols + nrows)) );
1583 SCIP_CALL( SCIPallocBufferArray(scip, &rayslppos, ncols + nrows) );
1584
1585 /* cut (in the nonbasic space) is of the form alpha^T x >= 1 */
1587 SCIProwprepAddSide(rowprep, 1.0);
1588
1589 /* check if we have the tableau row of the variable and if not compute it */
1590 SCIP_CALL( getTableauRows(scip, vars, basicvarpos2tableaurow, tableau, tableaurows, &success) );
1591
1592 if( ! success )
1593 goto CLEANUP;
1594
1595 /* if we want to enforce bounds, set the right a and d to enforce aTx + dTy <= 0 */
1596 if( sepadata->usebounds )
1597 {
1598 solxik = SCIPvarGetLPSol(xik);
1599 solxil = SCIPvarGetLPSol(xil);
1600 solxjk = SCIPvarGetLPSol(xjk);
1601 solxjl = SCIPvarGetLPSol(xjl);
1602
1603 if( isxikdiag && SCIPisFeasNegative(scip, solxik) )
1604 {
1605 ad[0] = -1.0;
1606 ad[2] = 1.0;
1607 }
1608 else if( isxjldiag && SCIPisFeasNegative(scip, solxjl) )
1609 {
1610 ad[0] = -1.0;
1611 ad[2] = -1.0;
1612 }
1613 else if( isxildiag && SCIPisFeasNegative(scip, solxil) )
1614 {
1615 ad[1] = 1.0;
1616 ad[3] = -1.0;
1617 }
1618 else if( isxjkdiag && SCIPisFeasNegative(scip, solxjk) )
1619 {
1620 ad[1] = -1.0;
1621 ad[3] = -1.0;
1622 }
1623 }
1624
1625 nrays = 0;
1626 /* loop over each non-basic var; get the ray; compute cut coefficient */
1627 SCIP_CALL( addCols(scip, vars, tableaurows, rowprep, rays, &nrays, rayslppos, interpoints, sepadata->usebounds, ad, &success) );
1628
1629 if( ! success )
1630 goto CLEANUP;
1631
1632 /* loop over non-basic slack variables */
1633 SCIP_CALL( addRows(scip, vars, tableaurows, rowprep, rays, &nrays, rayslppos, interpoints, sepadata->usebounds, ad, &success) );
1634
1635 if( ! success )
1636 goto CLEANUP;
1637
1638 /* do strengthening */
1639 if( sepadata->usestrengthening )
1640 {
1641 SCIP_CALL( computeNegCutcoefs(scip, vars, rays, nrays, rayslppos, interpoints, rowprep, sepadata->usebounds, ad, &success) );
1642
1643 if( ! success )
1644 goto CLEANUP;
1645 }
1646
1647 /* merge coefficients that belong to same variable */
1648 SCIPmergeRowprepTerms(scip, rowprep);
1649
1650 SCIP_CALL( SCIPcleanupRowprep2(scip, rowprep, NULL, SCIPgetHugeValue(scip), &success) );
1651
1652 if( !success )
1653 goto CLEANUP;
1654
1655 viol = SCIPgetRowprepViolation(scip, rowprep, NULL, &success);
1656
1657 /* if cut is violated, create row out of rowprep and add it */
1658 if( success && viol >= sepadata->mincutviol )
1659 {
1660 SCIP_ROW* row;
1661 SCIP_Bool infeasible;
1662
1663 /* create row */
1664 SCIP_CALL( SCIPgetRowprepRowSepa(scip, &row, rowprep, sepa) );
1665
1666 assert(SCIPgetCutEfficacy(scip, NULL, row) > 0.0);
1667
1668 /* add row */
1669 SCIP_CALL( SCIPaddRow(scip, row, FALSE, &infeasible) );
1670
1671 if( infeasible )
1672 *result = SCIP_CUTOFF;
1673 else
1674 *result = SCIP_SEPARATED;
1675
1676 SCIP_CALL( SCIPreleaseRow(scip, &row) );
1677 }
1678
1679CLEANUP:
1680 SCIPfreeRowprep(scip, &rowprep);
1681 SCIPfreeBuffer(scip, &rayslppos);
1682 SCIPfreeBuffer(scip, &rays);
1683 SCIPfreeBuffer(scip, &interpoints);
1684
1685 return SCIP_OKAY;
1686}
1687
1688
1689/** separates cuts for stored principal minors */
1690static
1692 SCIP* scip, /**< SCIP data structure */
1693 SCIP_SEPA* sepa, /**< separator */
1694 SCIP_RESULT* result /**< pointer to store the result of the separation call */
1695 )
1696{
1697 SCIP_SEPADATA* sepadata;
1698 SCIP_HASHMAP* tableau = NULL;
1699 int* basicvarpos2tableaurow = NULL; /* map between basic var and its tableau row */
1700 int i;
1701
1702 assert(sepa != NULL);
1703 assert(result != NULL);
1704
1705 *result = SCIP_DIDNOTRUN;
1706
1707 sepadata = SCIPsepaGetData(sepa);
1708 assert(sepadata != NULL);
1709
1710 /* check whether there are some minors available */
1711 if( sepadata->nminors == 0 )
1712 return SCIP_OKAY;
1713
1714 *result = SCIP_DIDNOTFIND;
1715
1716 /* loop over the minors and if they are violated build cut */
1717 for( i = 0; i < sepadata->nminors && (*result != SCIP_CUTOFF); ++i )
1718 {
1719 SCIP_VAR* auxvarxik;
1720 SCIP_VAR* auxvarxil;
1721 SCIP_VAR* auxvarxjk;
1722 SCIP_VAR* auxvarxjl;
1723 SCIP_Bool isauxvarxikdiag;
1724 SCIP_Bool isauxvarxildiag;
1725 SCIP_Bool isauxvarxjkdiag;
1726 SCIP_Bool isauxvarxjldiag;
1727 SCIP_Real solxik;
1728 SCIP_Real solxil;
1729 SCIP_Real solxjk;
1730 SCIP_Real solxjl;
1731 SCIP_Real det;
1732
1733 /* get variables of the i-th minor */
1734 SCIP_CALL( getMinorVars(sepadata, i, &auxvarxik, &auxvarxil, &auxvarxjk, &auxvarxjl, &isauxvarxikdiag,
1735 &isauxvarxildiag, &isauxvarxjkdiag, &isauxvarxjldiag) );
1736
1737 /* get current solution values */
1738 solxik = SCIPvarGetLPSol(auxvarxik);
1739 solxil = SCIPvarGetLPSol(auxvarxil);
1740 solxjk = SCIPvarGetLPSol(auxvarxjk);
1741 solxjl = SCIPvarGetLPSol(auxvarxjl);
1742
1743 det = solxik * solxjl - solxil * solxjk;
1744
1745 if( SCIPisFeasZero(scip, det) )
1746 continue;
1747
1748 if( basicvarpos2tableaurow == NULL )
1749 {
1750 /* allocate memory */
1751 SCIP_CALL( SCIPallocBufferArray(scip, &basicvarpos2tableaurow, SCIPgetNLPCols(scip)) );
1753
1754 /* construct basicvar to tableau row map */
1755 SCIP_CALL( constructBasicVars2TableauRowMap(scip, basicvarpos2tableaurow) );
1756 }
1757 assert(tableau != NULL);
1758
1759 if( SCIPisFeasPositive(scip, det) )
1760 {
1761 SCIP_CALL( separateDeterminant(scip, sepa, sepadata, auxvarxik, auxvarxil, auxvarxjk, auxvarxjl, &isauxvarxikdiag,
1762 &isauxvarxildiag, &isauxvarxjkdiag, &isauxvarxjldiag, basicvarpos2tableaurow, tableau, result) );
1763 }
1764 else
1765 {
1766 assert(SCIPisFeasNegative(scip, det));
1767 SCIP_CALL( separateDeterminant(scip, sepa, sepadata, auxvarxil, auxvarxik, auxvarxjl, auxvarxjk, &isauxvarxildiag,
1768 &isauxvarxikdiag, &isauxvarxjldiag, &isauxvarxjkdiag, basicvarpos2tableaurow, tableau, result) );
1769 }
1770 }
1771
1772 /* all minors were feasible, so no memory to free */
1773 if( basicvarpos2tableaurow == NULL )
1774 return SCIP_OKAY;
1775
1776 /* free memory */
1777 for( i = 0; i < SCIPhashmapGetNEntries(tableau); ++i )
1778 {
1779 SCIP_HASHMAPENTRY* entry;
1780
1781 entry = SCIPhashmapGetEntry(tableau, i);
1782
1783 if( entry != NULL )
1784 {
1785 SCIP_Real* tableaurow;
1786
1787 tableaurow = (SCIP_Real *) SCIPhashmapEntryGetImage(entry);
1788
1789 SCIPfreeBufferArrayNull(scip, &tableaurow);
1790 }
1791 }
1792 SCIPhashmapFree(&tableau);
1793 SCIPfreeBufferArray(scip, &basicvarpos2tableaurow);
1794
1795 return SCIP_OKAY;
1796}
1797
1798/*
1799 * Callback methods of separator
1800 */
1801
1802/** copy method for separator plugins (called when SCIP copies plugins) */
1803static
1805{ /*lint --e{715}*/
1806 assert(scip != NULL);
1807 assert(sepa != NULL);
1808 assert(strcmp(SCIPsepaGetName(sepa), SEPA_NAME) == 0);
1809
1810 /* call inclusion method of constraint handler */
1812
1813 return SCIP_OKAY;
1814}
1815
1816
1817/** destructor of separator to free user data (called when SCIP is exiting) */
1818static
1820{ /*lint --e{715}*/
1821 SCIP_SEPADATA* sepadata;
1822
1823 sepadata = SCIPsepaGetData(sepa);
1824 assert(sepadata != NULL);
1825 assert(sepadata->minors == NULL);
1826 assert(sepadata->nminors == 0);
1827 assert(sepadata->minorssize == 0);
1828
1829 /* free separator data */
1830 SCIPfreeBlockMemory(scip, &sepadata);
1831 SCIPsepaSetData(sepa, NULL);
1832
1833 return SCIP_OKAY;
1834}
1835
1836
1837/** initialization method of separator (called after problem was transformed) */
1838static
1840{ /*lint --e{715}*/
1841 SCIP_SEPADATA* sepadata;
1842
1843 /* get separator data */
1844 sepadata = SCIPsepaGetData(sepa);
1845 assert(sepadata != NULL);
1846 assert(sepadata->randnumgen == NULL);
1847
1848 /* create random number generator */
1849 SCIP_CALL( SCIPcreateRandom(scip, &sepadata->randnumgen, DEFAULT_RANDSEED, TRUE) );
1850
1851 return SCIP_OKAY;
1852}
1853
1854
1855/** deinitialization method of separator (called before transformed problem is freed) */
1856static
1858{ /*lint --e{715}*/
1859 SCIP_SEPADATA* sepadata;
1860
1861 /* get separator data */
1862 sepadata = SCIPsepaGetData(sepa);
1863 assert(sepadata != NULL);
1864 assert(sepadata->randnumgen != NULL);
1865
1866 /* free random number generator */
1867 SCIPfreeRandom(scip, &sepadata->randnumgen);
1868
1869 return SCIP_OKAY;
1870}
1871
1872
1873/** solving process initialization method of separator (called when branch and bound process is about to begin) */
1874static
1875SCIP_DECL_SEPAINITSOL(sepaInitsolMinor)
1876{ /*lint --e{715}*/
1877 return SCIP_OKAY;
1878}
1879
1880
1881/** solving process deinitialization method of separator (called before branch and bound process data is freed) */
1882static
1883SCIP_DECL_SEPAEXITSOL(sepaExitsolMinor)
1884{ /*lint --e{715}*/
1885 SCIP_SEPADATA* sepadata;
1886
1887 sepadata = SCIPsepaGetData(sepa);
1888 assert(sepadata != NULL);
1889
1890 /* clear separation data */
1891 SCIP_CALL( sepadataClear(scip, sepadata) );
1892
1893 return SCIP_OKAY;
1894}
1895
1896
1897/** LP solution separation method of separator */
1898static
1899SCIP_DECL_SEPAEXECLP(sepaExeclpMinor)
1900{ /*lint --e{715}*/
1901 SCIP_SEPADATA* sepadata;
1902 int ncalls;
1903 int currentdepth;
1904
1905 /* need routine to compute eigenvalues/eigenvectors */
1907 return SCIP_OKAY;
1908
1909 sepadata = SCIPsepaGetData(sepa);
1910 assert(sepadata != NULL);
1911 currentdepth = SCIPgetDepth(scip);
1912 ncalls = SCIPsepaGetNCallsAtNode(sepa);
1913
1914 /* only call the separator a given number of times at each node */
1915 if( (currentdepth == 0 && sepadata->maxroundsroot >= 0 && ncalls >= sepadata->maxroundsroot)
1916 || (currentdepth > 0 && sepadata->maxrounds >= 0 && ncalls >= sepadata->maxrounds) )
1917 {
1918 SCIPdebugMsg(scip, "reached round limit for node\n");
1919 return SCIP_OKAY;
1920 }
1921
1922 /* try to detect minors */
1923 SCIP_CALL( detectMinors(scip, sepadata) );
1924
1925 /* call separation method */
1926 SCIP_CALL( separatePoint(scip, sepa, result) );
1927
1928 return SCIP_OKAY;
1929}
1930
1931
1932/*
1933 * separator specific interface methods
1934 */
1935
1936/** creates the minor separator and includes it in SCIP */
1938 SCIP* scip /**< SCIP data structure */
1939 )
1940{
1941 SCIP_SEPADATA* sepadata = NULL;
1942 SCIP_SEPA* sepa = NULL;
1943
1944 /* create minor separator data */
1945 SCIP_CALL( SCIPallocBlockMemory(scip, &sepadata) );
1946 BMSclearMemory(sepadata);
1947
1948 /* include separator */
1951 sepaExeclpMinor, NULL,
1952 sepadata) );
1953
1954 assert(sepa != NULL);
1955
1956 /* set non fundamental callbacks via setter functions */
1957 SCIP_CALL( SCIPsetSepaCopy(scip, sepa, sepaCopyMinor) );
1958 SCIP_CALL( SCIPsetSepaFree(scip, sepa, sepaFreeMinor) );
1959 SCIP_CALL( SCIPsetSepaInit(scip, sepa, sepaInitMinor) );
1960 SCIP_CALL( SCIPsetSepaExit(scip, sepa, sepaExitMinor) );
1961 SCIP_CALL( SCIPsetSepaInitsol(scip, sepa, sepaInitsolMinor) );
1962 SCIP_CALL( SCIPsetSepaExitsol(scip, sepa, sepaExitsolMinor) );
1963
1964 /* add minor separator parameters */
1966 "separating/" SEPA_NAME "/usestrengthening",
1967 "whether to use strengthened intersection cuts to separate minors",
1968 &sepadata->usestrengthening, FALSE, DEFAULT_USESTRENGTHENING, NULL, NULL) );
1969
1971 "separating/" SEPA_NAME "/usebounds",
1972 "whether to also enforce nonegativity bounds of principle minors",
1973 &sepadata->usebounds, FALSE, DEFAULT_USEBOUNDS, NULL, NULL) );
1974
1976 "separating/" SEPA_NAME "/mincutviol",
1977 "minimum required violation of a cut",
1978 &sepadata->mincutviol, FALSE, DEFAULT_MINCUTVIOL, 0.0, SCIP_REAL_MAX, NULL, NULL) );
1979
1981 "separating/" SEPA_NAME "/maxrounds",
1982 "maximal number of separation rounds per node (-1: unlimited)",
1983 &sepadata->maxrounds, FALSE, DEFAULT_MAXROUNDS, -1, INT_MAX, NULL, NULL) );
1984
1986 "separating/" SEPA_NAME "/maxroundsroot",
1987 "maximal number of separation rounds in the root node (-1: unlimited)",
1988 &sepadata->maxroundsroot, FALSE, DEFAULT_MAXROUNDSROOT, -1, INT_MAX, NULL, NULL) );
1989
1990 return SCIP_OKAY;
1991}
SCIP_VAR * a
Definition: circlepacking.c:66
SCIP_VAR ** b
Definition: circlepacking.c:65
constraint handler for nonlinear constraints specified by algebraic expressions
#define SCIPquadprecSqrtQ(r, a)
Definition: dbldblarith.h:71
#define SCIPquadprecProdDD(r, a, b)
Definition: dbldblarith.h:58
#define SCIPquadprecProdQD(r, a, b)
Definition: dbldblarith.h:63
#define QUAD_SCALE(x, a)
Definition: dbldblarith.h:50
#define SCIPquadprecSumQD(r, a, b)
Definition: dbldblarith.h:62
#define QUAD_ASSIGN(a, constant)
Definition: dbldblarith.h:51
#define QUAD(x)
Definition: dbldblarith.h:47
#define SCIPquadprecSquareD(r, a)
Definition: dbldblarith.h:59
#define SCIPquadprecSumQQ(r, a, b)
Definition: dbldblarith.h:67
#define QUAD_TO_DBL(x)
Definition: dbldblarith.h:49
#define NULL
Definition: def.h:248
#define SCIP_REAL_MAX
Definition: def.h:158
#define SCIP_INTERVAL_INFINITY
Definition: def.h:180
#define SCIP_Bool
Definition: def.h:91
#define SCIP_Real
Definition: def.h:156
#define ABS(x)
Definition: def.h:216
#define SQR(x)
Definition: def.h:199
#define TRUE
Definition: def.h:93
#define FALSE
Definition: def.h:94
#define MAX(x, y)
Definition: def.h:220
#define SCIP_CALL(x)
Definition: def.h:355
private functions to work with algebraic expressions
power and signed power expression handlers
product expression handler
variable expression handler
void SCIPcomputeArraysIntersectionInt(int *array1, int narray1, int *array2, int narray2, int *intersectarray, int *nintersectarray)
Definition: misc.c:10530
SCIP_VAR * SCIPgetExprAuxVarNonlinear(SCIP_EXPR *expr)
SCIP_EXPR * SCIPgetExprNonlinear(SCIP_CONS *cons)
const char * SCIPgetProbName(SCIP *scip)
Definition: scip_prob.c:1242
int SCIPgetNVars(SCIP *scip)
Definition: scip_prob.c:2246
SCIP_VAR ** SCIPgetVars(SCIP *scip)
Definition: scip_prob.c:2201
void SCIPhashmapFree(SCIP_HASHMAP **hashmap)
Definition: misc.c:3095
void * SCIPhashmapEntryGetImage(SCIP_HASHMAPENTRY *entry)
Definition: misc.c:3613
void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin)
Definition: misc.c:3284
SCIP_RETCODE SCIPhashmapInsert(SCIP_HASHMAP *hashmap, void *origin, void *image)
Definition: misc.c:3143
int SCIPhashmapGetNEntries(SCIP_HASHMAP *hashmap)
Definition: misc.c:3584
SCIP_HASHMAPENTRY * SCIPhashmapGetEntry(SCIP_HASHMAP *hashmap, int entryidx)
Definition: misc.c:3592
SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize)
Definition: misc.c:3061
SCIP_Bool SCIPhashmapExists(SCIP_HASHMAP *hashmap, void *origin)
Definition: misc.c:3466
void SCIPinfoMessage(SCIP *scip, FILE *file, const char *formatstr,...)
Definition: scip_message.c:208
#define SCIPdebugMsg
Definition: scip_message.h:78
SCIP_Bool SCIPisIpoptAvailableIpopt(void)
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:83
SCIP_RETCODE SCIPaddRealParam(SCIP *scip, const char *name, const char *desc, SCIP_Real *valueptr, SCIP_Bool isadvanced, SCIP_Real defaultvalue, SCIP_Real minvalue, SCIP_Real maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip_param.c:139
SCIP_RETCODE SCIPaddBoolParam(SCIP *scip, const char *name, const char *desc, SCIP_Bool *valueptr, SCIP_Bool isadvanced, SCIP_Bool defaultvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip_param.c:57
int SCIPcolGetLPPos(SCIP_COL *col)
Definition: lp.c:17487
SCIP_VAR * SCIPcolGetVar(SCIP_COL *col)
Definition: lp.c:17425
SCIP_Real SCIPcolGetPrimsol(SCIP_COL *col)
Definition: lp.c:17379
SCIP_BASESTAT SCIPcolGetBasisStatus(SCIP_COL *col)
Definition: lp.c:17414
int SCIPconshdlrGetNConss(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4778
SCIP_CONSHDLR * SCIPfindConshdlr(SCIP *scip, const char *name)
Definition: scip_cons.c:940
SCIP_CONS ** SCIPconshdlrGetConss(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4735
const char * SCIPconsGetName(SCIP_CONS *cons)
Definition: cons.c:8389
SCIP_Real SCIPgetCutEfficacy(SCIP *scip, SCIP_SOL *sol, SCIP_ROW *cut)
Definition: scip_cut.c:94
SCIP_RETCODE SCIPaddRow(SCIP *scip, SCIP_ROW *row, SCIP_Bool forcecut, SCIP_Bool *infeasible)
Definition: scip_cut.c:225
int SCIPexprGetNChildren(SCIP_EXPR *expr)
Definition: expr.c:3872
SCIP_Real SCIPgetExponentExprPow(SCIP_EXPR *expr)
Definition: expr_pow.c:3448
SCIP_Bool SCIPisExprProduct(SCIP *scip, SCIP_EXPR *expr)
Definition: scip_expr.c:1490
SCIP_Bool SCIPexpriterIsEnd(SCIP_EXPRITER *iterator)
Definition: expriter.c:969
SCIP_EXPR * SCIPexpriterRestartDFS(SCIP_EXPRITER *iterator, SCIP_EXPR *expr)
Definition: expriter.c:630
SCIP_RETCODE SCIPcreateExpriter(SCIP *scip, SCIP_EXPRITER **iterator)
Definition: scip_expr.c:2362
SCIP_Bool SCIPisExprPower(SCIP *scip, SCIP_EXPR *expr)
Definition: scip_expr.c:1501
SCIP_EXPR * SCIPexpriterGetNext(SCIP_EXPRITER *iterator)
Definition: expriter.c:858
SCIP_EXPR ** SCIPexprGetChildren(SCIP_EXPR *expr)
Definition: expr.c:3882
void SCIPfreeExpriter(SCIP_EXPRITER **iterator)
Definition: scip_expr.c:2376
SCIP_RETCODE SCIPexpriterInit(SCIP_EXPRITER *iterator, SCIP_EXPR *expr, SCIP_EXPRITER_TYPE type, SCIP_Bool allowrevisit)
Definition: expriter.c:501
SCIP_Real SCIPintervalGetInf(SCIP_INTERVAL interval)
SCIP_Bool SCIPintervalIsEmpty(SCIP_Real infinity, SCIP_INTERVAL operand)
void SCIPintervalSetBounds(SCIP_INTERVAL *resultant, SCIP_Real inf, SCIP_Real sup)
void SCIPintervalSolveUnivariateQuadExpressionPositiveAllScalar(SCIP_Real infinity, SCIP_INTERVAL *resultant, SCIP_Real sqrcoeff, SCIP_Real lincoeff, SCIP_Real rhs, SCIP_INTERVAL xbnds)
SCIP_RETCODE SCIPgetLPBasisInd(SCIP *scip, int *basisind)
Definition: scip_lp.c:692
SCIP_ROW ** SCIPgetLPRows(SCIP *scip)
Definition: scip_lp.c:611
int SCIPgetNLPRows(SCIP *scip)
Definition: scip_lp.c:632
SCIP_RETCODE SCIPgetLPBInvARow(SCIP *scip, int r, SCIP_Real *binvrow, SCIP_Real *coefs, int *inds, int *ninds)
Definition: scip_lp.c:791
SCIP_COL ** SCIPgetLPCols(SCIP *scip)
Definition: scip_lp.c:512
int SCIPgetNLPCols(SCIP *scip)
Definition: scip_lp.c:533
SCIP_RETCODE SCIPgetLPBInvRow(SCIP *scip, int r, SCIP_Real *coefs, int *inds, int *ninds)
Definition: scip_lp.c:720
#define SCIPfreeBuffer(scip, ptr)
Definition: scip_mem.h:134
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
Definition: scip_mem.c:57
int SCIPcalcMemGrowSize(SCIP *scip, int num)
Definition: scip_mem.c:139
#define SCIPallocBufferArray(scip, ptr, num)
Definition: scip_mem.h:124
#define SCIPreallocBufferArray(scip, ptr, num)
Definition: scip_mem.h:128
#define SCIPfreeBufferArray(scip, ptr)
Definition: scip_mem.h:136
#define SCIPallocBuffer(scip, ptr)
Definition: scip_mem.h:122
#define SCIPreallocBlockMemoryArray(scip, ptr, oldnum, newnum)
Definition: scip_mem.h:99
#define SCIPfreeBlockMemory(scip, ptr)
Definition: scip_mem.h:108
#define SCIPfreeBlockMemoryArrayNull(scip, ptr, num)
Definition: scip_mem.h:111
#define SCIPfreeBufferArrayNull(scip, ptr)
Definition: scip_mem.h:137
#define SCIPallocBlockMemory(scip, ptr)
Definition: scip_mem.h:89
SCIP_Real SCIProwGetLhs(SCIP_ROW *row)
Definition: lp.c:17686
SCIP_COL ** SCIProwGetCols(SCIP_ROW *row)
Definition: lp.c:17632
SCIP_Real SCIProwGetRhs(SCIP_ROW *row)
Definition: lp.c:17696
int SCIProwGetNLPNonz(SCIP_ROW *row)
Definition: lp.c:17621
int SCIProwGetLPPos(SCIP_ROW *row)
Definition: lp.c:17895
SCIP_Real SCIPgetRowActivity(SCIP *scip, SCIP_ROW *row)
Definition: scip_lp.c:2068
SCIP_RETCODE SCIPreleaseRow(SCIP *scip, SCIP_ROW **row)
Definition: scip_lp.c:1508
SCIP_Real SCIProwGetConstant(SCIP_ROW *row)
Definition: lp.c:17652
SCIP_Real * SCIProwGetVals(SCIP_ROW *row)
Definition: lp.c:17642
SCIP_BASESTAT SCIProwGetBasisStatus(SCIP_ROW *row)
Definition: lp.c:17734
SCIP_RETCODE SCIPsetSepaExit(SCIP *scip, SCIP_SEPA *sepa, SCIP_DECL_SEPAEXIT((*sepaexit)))
Definition: scip_sepa.c:205
SCIP_RETCODE SCIPsetSepaInitsol(SCIP *scip, SCIP_SEPA *sepa, SCIP_DECL_SEPAINITSOL((*sepainitsol)))
Definition: scip_sepa.c:221
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:115
const char * SCIPsepaGetName(SCIP_SEPA *sepa)
Definition: sepa.c:746
int SCIPsepaGetNCallsAtNode(SCIP_SEPA *sepa)
Definition: sepa.c:893
SCIP_RETCODE SCIPsetSepaFree(SCIP *scip, SCIP_SEPA *sepa, SCIP_DECL_SEPAFREE((*sepafree)))
Definition: scip_sepa.c:173
SCIP_RETCODE SCIPsetSepaExitsol(SCIP *scip, SCIP_SEPA *sepa, SCIP_DECL_SEPAEXITSOL((*sepaexitsol)))
Definition: scip_sepa.c:237
SCIP_SEPADATA * SCIPsepaGetData(SCIP_SEPA *sepa)
Definition: sepa.c:636
void SCIPsepaSetData(SCIP_SEPA *sepa, SCIP_SEPADATA *sepadata)
Definition: sepa.c:646
SCIP_RETCODE SCIPsetSepaCopy(SCIP *scip, SCIP_SEPA *sepa, SCIP_DECL_SEPACOPY((*sepacopy)))
Definition: scip_sepa.c:157
SCIP_RETCODE SCIPsetSepaInit(SCIP *scip, SCIP_SEPA *sepa, SCIP_DECL_SEPAINIT((*sepainit)))
Definition: scip_sepa.c:189
SCIP_Real SCIPgetTotalTime(SCIP *scip)
Definition: scip_timing.c:351
SCIP_Real SCIPinfinity(SCIP *scip)
SCIP_Bool SCIPisFeasEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisFeasZero(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisHugeValue(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisFeasNegative(SCIP *scip, SCIP_Real val)
SCIP_Real SCIPgetHugeValue(SCIP *scip)
SCIP_Bool SCIPisEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisZero(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisFeasPositive(SCIP *scip, SCIP_Real val)
int SCIPgetDepth(SCIP *scip)
Definition: scip_tree.c:672
SCIP_COL * SCIPvarGetCol(SCIP_VAR *var)
Definition: var.c:23683
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
Definition: var.c:24268
int SCIPvarGetProbindex(SCIP_VAR *var)
Definition: var.c:23662
const char * SCIPvarGetName(SCIP_VAR *var)
Definition: var.c:23267
SCIP_RETCODE SCIPreleaseVar(SCIP *scip, SCIP_VAR **var)
Definition: scip_var.c:1887
SCIP_Real SCIPvarGetLPSol(SCIP_VAR *var)
Definition: var.c:24664
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
Definition: var.c:24234
SCIP_RETCODE SCIPcaptureVar(SCIP *scip, SCIP_VAR *var)
Definition: scip_var.c:1853
void SCIPfreeRandom(SCIP *scip, SCIP_RANDNUMGEN **randnumgen)
SCIP_RETCODE SCIPcreateRandom(SCIP *scip, SCIP_RANDNUMGEN **randnumgen, unsigned int initialseed, SCIP_Bool useglobalseed)
SCIP_RETCODE SCIPcleanupRowprep2(SCIP *scip, SCIP_ROWPREP *rowprep, SCIP_SOL *sol, SCIP_Real maxcoefbound, SCIP_Bool *success)
void SCIPmergeRowprepTerms(SCIP *scip, SCIP_ROWPREP *rowprep)
SCIP_Real SCIPgetRowprepViolation(SCIP *scip, SCIP_ROWPREP *rowprep, SCIP_SOL *sol, SCIP_Bool *reliable)
Definition: misc_rowprep.c:972
void SCIProwprepAddConstant(SCIP_ROWPREP *rowprep, SCIP_Real constant)
Definition: misc_rowprep.c:760
SCIP_RETCODE SCIPgetRowprepRowSepa(SCIP *scip, SCIP_ROW **row, SCIP_ROWPREP *rowprep, SCIP_SEPA *sepa)
SCIP_RETCODE SCIPaddRowprepTerm(SCIP *scip, SCIP_ROWPREP *rowprep, SCIP_VAR *var, SCIP_Real coef)
Definition: misc_rowprep.c:913
SCIP_RETCODE SCIPcreateRowprep(SCIP *scip, SCIP_ROWPREP **rowprep, SCIP_SIDETYPE sidetype, SCIP_Bool local)
Definition: misc_rowprep.c:563
void SCIProwprepAddSide(SCIP_ROWPREP *rowprep, SCIP_Real side)
Definition: misc_rowprep.c:746
void SCIPfreeRowprep(SCIP *scip, SCIP_ROWPREP **rowprep)
Definition: misc_rowprep.c:583
SCIP_RETCODE SCIPincludeSepaInterminor(SCIP *scip)
void SCIPsortInt(int *intarray, int len)
#define BMSclearMemory(ptr)
Definition: memory.h:129
Rational & max(Rational &r1, Rational &r2)
Rational & min(Rational &r1, Rational &r2)
Ipopt NLP interface.
#define SCIPstatisticMessage
Definition: pub_message.h:123
static SCIP_RETCODE insertIndex(SCIP *scip, SCIP_HASHMAP *rowmap, SCIP_VAR *row, SCIP_VAR *col, SCIP_VAR *auxvar, int *rowindices, int *nrows)
#define SEPA_PRIORITY
static SCIP_Real computeIntersectionPoint(SCIP *scip, SCIP_Bool usebounds, SCIP_Real *coefs, SCIP_Real *coefs4b, SCIP_Real *coefscondition)
#define DEFAULT_USEBOUNDS
static SCIP_DECL_SEPAINIT(sepaInitMinor)
#define DEFAULT_USESTRENGTHENING
#define SEPA_DELAY
static SCIP_RETCODE addRows(SCIP *scip, SCIP_VAR **vars, SCIP_Real **tableaurows, SCIP_ROWPREP *rowprep, SCIP_Real *rays, int *nrays, int *rayslppos, SCIP_Real *interpoints, SCIP_Bool usebounds, SCIP_Real *ad, SCIP_Bool *success)
static SCIP_RETCODE getMinorVars(SCIP_SEPADATA *sepadata, int idx, SCIP_VAR **auxvarxik, SCIP_VAR **auxvarxil, SCIP_VAR **auxvarxjk, SCIP_VAR **auxvarxjl, SCIP_Bool *isauxvarxikdiag, SCIP_Bool *isauxvarxildiag, SCIP_Bool *isauxvarxjkdiag, SCIP_Bool *isauxvarxjldiag)
static SCIP_DECL_SEPAEXECLP(sepaExeclpMinor)
static SCIP_RETCODE sepadataClear(SCIP *scip, SCIP_SEPADATA *sepadata)
#define SEPA_DESC
static SCIP_RETCODE findRho(SCIP *scip, SCIP_Real *rays, int nrays, int idx, SCIP_Real *interpoints, SCIP_VAR **vars, SCIP_Real *rho, SCIP_Bool usebounds, SCIP_Real *ad, SCIP_Bool *success)
#define DEFAULT_MAXROUNDSROOT
#define SEPA_USESSUBSCIP
static SCIP_RETCODE getTableauRows(SCIP *scip, SCIP_VAR **vars, int *basicvarpos2tableaurow, SCIP_HASHMAP *tableau, SCIP_Real **tableaurows, SCIP_Bool *success)
static SCIP_DECL_SEPAFREE(sepaFreeMinor)
static SCIP_DECL_SEPACOPY(sepaCopyMinor)
static SCIP_Real isCase4a(SCIP_Real tsol, SCIP_Real *coefs, SCIP_Real *coefscondition)
static SCIP_RETCODE addRowToCut(SCIP *scip, SCIP_ROWPREP *rowprep, SCIP_Real cutcoef, SCIP_ROW *row, SCIP_Bool *success)
static SCIP_RETCODE separateDeterminant(SCIP *scip, SCIP_SEPA *sepa, SCIP_SEPADATA *sepadata, SCIP_VAR *xik, SCIP_VAR *xil, SCIP_VAR *xjk, SCIP_VAR *xjl, SCIP_Bool *isxikdiag, SCIP_Bool *isxildiag, SCIP_Bool *isxjkdiag, SCIP_Bool *isxjldiag, int *basicvarpos2tableaurow, SCIP_HASHMAP *tableau, SCIP_RESULT *result)
static SCIP_DECL_SEPAEXITSOL(sepaExitsolMinor)
static SCIP_Real computeRoot(SCIP *scip, SCIP_Real *coefs)
static SCIP_Real evalPhiAtRay(SCIP *scip, SCIP_Real t, SCIP_Real a, SCIP_Real b, SCIP_Real c, SCIP_Real d, SCIP_Real e)
#define DEFAULT_MINCUTVIOL
static SCIP_RETCODE detectMinors(SCIP *scip, SCIP_SEPADATA *sepadata)
static SCIP_RETCODE sepadataAddMinor(SCIP *scip, SCIP_SEPADATA *sepadata, SCIP_VAR *auxvarxik, SCIP_VAR *auxvarxil, SCIP_VAR *auxvarxjk, SCIP_VAR *auxvarxjl, SCIP_Bool isauxvarxikdiag, SCIP_Bool isauxvarxildiag, SCIP_Bool isauxvarxjkdiag, SCIP_Bool isauxvarxjldiag)
#define SEPA_MAXBOUNDDIST
static SCIP_RETCODE addCols(SCIP *scip, SCIP_VAR **vars, SCIP_Real **tableaurows, SCIP_ROWPREP *rowprep, SCIP_Real *rays, int *nrays, int *rayslppos, SCIP_Real *interpoints, SCIP_Bool usebounds, SCIP_Real *ad, SCIP_Bool *success)
static SCIP_DECL_SEPAEXIT(sepaExitMinor)
#define SEPA_FREQ
#define DEFAULT_RANDSEED
#define SEPA_NAME
static SCIP_DECL_SEPAINITSOL(sepaInitsolMinor)
#define MAXNMINORS
#define BINSEARCH_MAXITERS
#define DEFAULT_MAXROUNDS
static SCIP_RETCODE computeNegCutcoefs(SCIP *scip, SCIP_VAR **vars, SCIP_Real *rays, int nrays, int *rayslppos, SCIP_Real *interpoints, SCIP_ROWPREP *rowprep, SCIP_Bool usebounds, SCIP_Real *ad, SCIP_Bool *success)
static void doBinarySearch(SCIP *scip, SCIP_Real a, SCIP_Real b, SCIP_Real c, SCIP_Real d, SCIP_Real e, SCIP_Real *sol)
static SCIP_RETCODE addColToCut(SCIP *scip, SCIP_ROWPREP *rowprep, SCIP_Real cutcoef, SCIP_COL *col)
static SCIP_RETCODE constructBasicVars2TableauRowMap(SCIP *scip, int *map)
static SCIP_RETCODE computeRestrictionToRay(SCIP *scip, SCIP_Real *ray, SCIP_VAR **vars, SCIP_Real *coefs, SCIP_Real *coefs4b, SCIP_Real *coefscondition, SCIP_Bool usebounds, SCIP_Real *ad, SCIP_Bool *success)
static SCIP_Bool raysAreDependent(SCIP *scip, SCIP_Real *ray1, SCIP_Real *ray2, SCIP_Real *coef)
static SCIP_RETCODE separatePoint(SCIP *scip, SCIP_SEPA *sepa, SCIP_RESULT *result)
int * vals
SCIP_HASHMAP * auxvars
@ SCIP_EXPRITER_DFS
Definition: type_expr.h:718
@ SCIP_SIDETYPE_LEFT
Definition: type_lp.h:65
@ SCIP_BASESTAT_BASIC
Definition: type_lpi.h:92
@ SCIP_BASESTAT_UPPER
Definition: type_lpi.h:93
@ SCIP_BASESTAT_LOWER
Definition: type_lpi.h:91
@ SCIP_BASESTAT_ZERO
Definition: type_lpi.h:94
@ SCIP_DIDNOTRUN
Definition: type_result.h:42
@ SCIP_CUTOFF
Definition: type_result.h:48
@ SCIP_DIDNOTFIND
Definition: type_result.h:44
@ SCIP_SEPARATED
Definition: type_result.h:49
enum SCIP_Result SCIP_RESULT
Definition: type_result.h:61
@ SCIP_OKAY
Definition: type_retcode.h:42
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:63
struct SCIP_SepaData SCIP_SEPADATA
Definition: type_sepa.h:52