1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program and library */
4 /* SCIP --- Solving Constraint Integer Programs */
5 /* */
6 /* Copyright (C) 2002-2022 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 scip_lp.c
17 * @ingroup OTHER_CFILES
18 * @brief public methods for the LP relaxation, rows and columns
19 * @author Tobias Achterberg
20 * @author Timo Berthold
21 * @author Gerald Gamrath
22 * @author Leona Gottwald
23 * @author Stefan Heinz
24 * @author Gregor Hendel
25 * @author Thorsten Koch
26 * @author Alexander Martin
27 * @author Marc Pfetsch
28 * @author Michael Winkler
29 * @author Kati Wolter
30 *
31 * @todo check all SCIP_STAGE_* switches, and include the new stages TRANSFORMED and INITSOLVE
32 */
33
34 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
35
36 #include "blockmemshell/memory.h"
37 #include "lpi/lpi.h"
38 #include "scip/conflict.h"
39 #include "scip/debug.h"
40 #include "scip/lp.h"
41 #include "scip/prob.h"
42 #include "scip/pub_lp.h"
43 #include "scip/pub_message.h"
44 #include "scip/pub_tree.h"
45 #include "scip/scip_lp.h"
46 #include "scip/scip_mem.h"
47 #include "scip/scip_numerics.h"
48 #include "scip/scip_sol.h"
49 #include "scip/scip_solvingstats.h"
50 #include "scip/scip_tree.h"
51 #include "scip/scip_var.h"
52 #include "scip/set.h"
53 #include "scip/solve.h"
54 #include "scip/struct_lp.h"
55 #include "scip/struct_mem.h"
56 #include "scip/struct_primal.h"
57 #include "scip/struct_prob.h"
58 #include "scip/struct_scip.h"
59 #include "scip/struct_set.h"
60 #include "scip/struct_stat.h"
61 #include "scip/struct_tree.h"
62 #include "scip/tree.h"
63 #include "scip/var.h"
64
65 /** returns, whether the LP was or is to be solved in the current node
66 *
67 * @return whether the LP was or is to be solved in the current node.
68 *
69 * @pre This method can be called if @p scip is in one of the following stages:
70 * - \ref SCIP_STAGE_SOLVING
71 *
72 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
73 */
74 SCIP_Bool SCIPhasCurrentNodeLP(
75 SCIP* scip /**< SCIP data structure */
76 )
77 {
78 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPhasCurrentNodeLP", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
79
80 return SCIPtreeHasCurrentNodeLP(scip->tree);
81 }
82
83 /** returns, whether the LP of the current node is already constructed
84 *
85 * @return whether the LP of the current node is already constructed.
86 *
87 * @pre This method can be called if @p scip is in one of the following stages:
88 * - \ref SCIP_STAGE_SOLVING
89 *
90 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
91 */
92 SCIP_Bool SCIPisLPConstructed(
93 SCIP* scip /**< SCIP data structure */
94 )
95 {
96 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPisLPConstructed", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
97
98 return SCIPtreeIsFocusNodeLPConstructed(scip->tree);
99 }
100
101 /** makes sure that the LP of the current node is loaded and may be accessed through the LP information methods
102 *
103 * @warning Contructing the LP might change the amount of variables known in the transformed problem and therefore also
104 * the variables array of SCIP (returned by SCIPgetVars() and SCIPgetVarsData()), so it might be necessary to
105 * call one of the later method after this one
106 *
107 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
108 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
109 *
110 * @pre This method can be called if @p scip is in one of the following stages:
111 * - \ref SCIP_STAGE_SOLVING
112 *
113 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
114 */
115 SCIP_RETCODE SCIPconstructLP(
116 SCIP* scip, /**< SCIP data structure */
117 SCIP_Bool* cutoff /**< pointer to store whether the node can be cut off */
118 )
119 {
120 SCIP_CALL( SCIPcheckStage(scip, "SCIPconstructLP", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
121
122 SCIP_CALL( SCIPconstructCurrentLP(scip->mem->probmem, scip->set, scip->stat, scip->transprob, scip->origprob,
123 scip->tree, scip->reopt, scip->lp, scip->pricestore, scip->sepastore, scip->cutpool, scip->branchcand,
124 scip->eventqueue, scip->eventfilter, scip->cliquetable, FALSE, cutoff) );
125
126 return SCIP_OKAY;
127 }
128
129 /** makes sure that the LP of the current node is flushed
130 *
131 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
132 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
133 *
134 * @pre This method can be called if @p scip is in one of the following stages:
135 * - \ref SCIP_STAGE_SOLVING
136 *
137 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
138 */
139 SCIP_RETCODE SCIPflushLP(
140 SCIP* scip /**< SCIP data structure */
141 )
142 {
143 SCIP_CALL( SCIPcheckStage(scip, "SCIPflushLP", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
144
145 SCIP_CALL( SCIPlpFlush(scip->lp, scip->mem->probmem, scip->set, scip->eventqueue) );
146
147 return SCIP_OKAY;
148 }
149
150 /** gets solution status of current LP
151 *
152 * @return the solution status of current LP.
153 *
154 * @pre This method can be called if @p scip is in one of the following stages:
155 * - \ref SCIP_STAGE_SOLVING
156 *
157 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
158 */
159 SCIP_LPSOLSTAT SCIPgetLPSolstat(
160 SCIP* scip /**< SCIP data structure */
161 )
162 {
163 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetLPSolstat", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
164
165 if( SCIPtreeIsFocusNodeLPConstructed(scip->tree) )
166 return SCIPlpGetSolstat(scip->lp);
167 else
168 return SCIP_LPSOLSTAT_NOTSOLVED;
169 }
170
171 /** returns whether the current LP solution passed the primal feasibility check
172 *
173 * @return whether the current LP solution passed the primal feasibility check.
174 *
175 * @pre This method can be called if @p scip is in one of the following stages:
176 * - \ref SCIP_STAGE_SOLVING
177 *
178 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
179 */
180 SCIP_Bool SCIPisLPPrimalReliable(
181 SCIP* scip /**< SCIP data structure */
182 )
183 {
184 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPisLPPrimalReliable", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
185
186 return SCIPlpIsPrimalReliable(scip->lp);
187 }
188
189 /** returns whether the current LP solution passed the dual feasibility check
190 *
191 * @returns whether the current LP solution passed the dual feasibility check.
192 *
193 * @pre This method can be called if @p scip is in one of the following stages:
194 * - \ref SCIP_STAGE_SOLVING
195 *
196 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
197 */
198 SCIP_Bool SCIPisLPDualReliable(
199 SCIP* scip /**< SCIP data structure */
200 )
201 {
202 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPisLPDualReliable", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
203
204 return SCIPlpIsDualReliable(scip->lp);
205 }
206
207 /** returns whether the current lp is a relaxation of the current problem and its optimal objective value is a local lower bound
208 *
209 * @return whether the current lp is a relaxation of the current problem and its optimal objective value is a local lower bound.
210 *
211 * @pre This method can be called if @p scip is in one of the following stages:
212 * - \ref SCIP_STAGE_SOLVING
213 *
214 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
215 */
216 SCIP_Bool SCIPisLPRelax(
217 SCIP* scip /**< SCIP data structure */
218 )
219 {
220 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPisLPRelax", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
221
222 return SCIPlpIsRelax(scip->lp);
223 }
224
225 /** gets objective value of current LP (which is the sum of column and loose objective value)
226 *
227 * @return the objective value of current LP (which is the sum of column and loose objective value).
228 *
229 * @pre This method can be called if @p scip is in one of the following stages:
230 * - \ref SCIP_STAGE_SOLVING
231 *
232 * @note This method returns the objective value of the current LP solution, which might be primal or dual infeasible
233 * if a limit was hit during solving. It must not be used as a dual bound if the LP solution status returned by
234 * SCIPgetLPSolstat() is SCIP_LPSOLSTAT_ITERLIMIT or SCIP_LPSOLSTAT_TIMELIMIT.
235 *
236 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
237 */
238 SCIP_Real SCIPgetLPObjval(
239 SCIP* scip /**< SCIP data structure */
240 )
241 {
242 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetLPObjval", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
243
244 return SCIPlpGetObjval(scip->lp, scip->set, scip->transprob);
245 }
246
247 /** gets part of objective value of current LP that results from COLUMN variables only
248 *
249 * @return the part of objective value of current LP that results from COLUMN variables only.
250 *
251 * @pre This method can be called if @p scip is in one of the following stages:
252 * - \ref SCIP_STAGE_SOLVING
253 *
254 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
255 */
256 SCIP_Real SCIPgetLPColumnObjval(
257 SCIP* scip /**< SCIP data structure */
258 )
259 {
260 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetLPColumnObjval", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
261
262 return SCIPlpGetColumnObjval(scip->lp);
263 }
264
265 /** gets part of objective value of current LP that results from LOOSE variables only
266 *
267 * @return part of objective value of current LP that results from LOOSE variables only.
268 *
269 * @pre This method can be called if @p scip is in one of the following stages:
270 * - \ref SCIP_STAGE_SOLVING
271 *
272 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
273 */
274 SCIP_Real SCIPgetLPLooseObjval(
275 SCIP* scip /**< SCIP data structure */
276 )
277 {
278 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetLPLooseObjval", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
279
280 return SCIPlpGetLooseObjval(scip->lp, scip->set, scip->transprob);
281 }
282
283 /** gets the global pseudo objective value; that is all variables set to their best (w.r.t. the objective
284 * function) global bound
285 *
286 * @return the global pseudo objective value; that is all variables set to their best (w.r.t. the objective
287 * function) global bound.
288 *
289 * @pre This method can be called if @p scip is in one of the following stages:
290 * - \ref SCIP_STAGE_INITPRESOLVE
291 * - \ref SCIP_STAGE_PRESOLVING
292 * - \ref SCIP_STAGE_EXITPRESOLVE
293 * - \ref SCIP_STAGE_PRESOLVED
294 * - \ref SCIP_STAGE_INITSOLVE
295 * - \ref SCIP_STAGE_SOLVING
296 *
297 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
298 */
299 SCIP_Real SCIPgetGlobalPseudoObjval(
300 SCIP* scip /**< SCIP data structure */
301 )
302 {
303 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetGlobalPseudoObjval", FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE) );
304
305 return SCIPlpGetGlobalPseudoObjval(scip->lp, scip->set, scip->transprob);
306 }
307
308 /** gets the pseudo objective value for the current search node; that is all variables set to their best (w.r.t. the
309 * objective function) local bound
310 *
311 * @return the pseudo objective value for the current search node; that is all variables set to their best (w.r.t. the
312 * objective function) local bound.
313 *
314 * @pre This method can be called if @p scip is in one of the following stages:
315 * - \ref SCIP_STAGE_INITPRESOLVE
316 * - \ref SCIP_STAGE_PRESOLVING
317 * - \ref SCIP_STAGE_EXITPRESOLVE
318 * - \ref SCIP_STAGE_PRESOLVED
319 * - \ref SCIP_STAGE_INITSOLVE
320 * - \ref SCIP_STAGE_SOLVING
321 *
322 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
323 */
324 SCIP_Real SCIPgetPseudoObjval(
325 SCIP* scip /**< SCIP data structure */
326 )
327 {
328 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetPseudoObjval", FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE) );
329
330 return SCIPlpGetPseudoObjval(scip->lp, scip->set, scip->transprob);
331 }
332
333 /** returns whether the root lp is a relaxation of the problem and its optimal objective value is a global lower bound
334 *
335 * @return whether the root lp is a relaxation of the problem and its optimal objective value is a global lower bound.
336 *
337 * @pre This method can be called if @p scip is in one of the following stages:
338 * - \ref SCIP_STAGE_SOLVING
339 *
340 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
341 */
342 SCIP_Bool SCIPisRootLPRelax(
343 SCIP* scip /**< SCIP data structure */
344 )
345 {
346 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPisRootLPRelax", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
347
348 return SCIPlpIsRootLPRelax(scip->lp);
349 }
350
351 /** gets the objective value of the root node LP or SCIP_INVALID if the root node LP was not (yet) solved
352 *
353 * @return the objective value of the root node LP or SCIP_INVALID if the root node LP was not (yet) solved.
354 *
355 * @pre This method can be called if @p scip is in one of the following stages:
356 * - \ref SCIP_STAGE_INITPRESOLVE
357 * - \ref SCIP_STAGE_PRESOLVING
358 * - \ref SCIP_STAGE_EXITPRESOLVE
359 * - \ref SCIP_STAGE_SOLVING
360 *
361 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
362 */
363 SCIP_Real SCIPgetLPRootObjval(
364 SCIP* scip /**< SCIP data structure */
365 )
366 {
367 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetLPRootObjval", FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
368
369 return SCIPlpGetRootObjval(scip->lp);
370 }
371
372 /** gets part of the objective value of the root node LP that results from COLUMN variables only;
373 * returns SCIP_INVALID if the root node LP was not (yet) solved
374 *
375 * @return the part of the objective value of the root node LP that results from COLUMN variables only;
376 * or SCIP_INVALID if the root node LP was not (yet) solved.
377 *
378 * @pre This method can be called if @p scip is in one of the following stages:
379 * - \ref SCIP_STAGE_INITPRESOLVE
380 * - \ref SCIP_STAGE_PRESOLVING
381 * - \ref SCIP_STAGE_EXITPRESOLVE
382 * - \ref SCIP_STAGE_SOLVING
383 *
384 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
385 */
386 SCIP_Real SCIPgetLPRootColumnObjval(
387 SCIP* scip /**< SCIP data structure */
388 )
389 {
390 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetLPRootColumnObjval", FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
391
392 return SCIPlpGetRootColumnObjval(scip->lp);
393 }
394
395 /** gets part of the objective value of the root node LP that results from LOOSE variables only;
396 * returns SCIP_INVALID if the root node LP was not (yet) solved
397 *
398 * @return the part of the objective value of the root node LP that results from LOOSE variables only;
399 * or SCIP_INVALID if the root node LP was not (yet) solved.
400 *
401 * @pre This method can be called if @p scip is in one of the following stages:
402 * - \ref SCIP_STAGE_INITPRESOLVE
403 * - \ref SCIP_STAGE_PRESOLVING
404 * - \ref SCIP_STAGE_EXITPRESOLVE
405 * - \ref SCIP_STAGE_SOLVING
406 *
407 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
408 */
409 SCIP_Real SCIPgetLPRootLooseObjval(
410 SCIP* scip /**< SCIP data structure */
411 )
412 {
413 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetLPRootLooseObjval", FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
414
415 return SCIPlpGetRootLooseObjval(scip->lp);
416 }
417
418 /** gets current primal feasibility tolerance of LP */
419 SCIP_Real SCIPgetLPFeastol(
420 SCIP* scip /**< SCIP data structure */
421 )
422 {
423 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetLPFeastol", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
424
425 return SCIPlpGetFeastol(scip->lp);
426 }
427
428 /** sets primal feasibility tolerance of LP */
429 void SCIPsetLPFeastol(
430 SCIP* scip, /**< SCIP data structure */
431 SCIP_Real newfeastol /**< new primal feasibility tolerance for LP */
432 )
433 {
434 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPsetLPFeastol", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
435
436 SCIPlpSetFeastol(scip->lp, scip->set, newfeastol);
437 }
438
439 /** resets primal feasibility tolerance of LP
440 *
441 * Sets primal feasibility tolerance to min of numerics/lpfeastolfactor * numerics/feastol and relaxfeastol.
442 */
443 void SCIPresetLPFeastol(
444 SCIP* scip /**< SCIP data structure */
445 )
446 {
447 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPresetLPFeastol", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
448
449 SCIPlpResetFeastol(scip->lp, scip->set);
450 }
451
452 /** gets current LP columns along with the current number of LP columns
453 *
454 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
455 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
456 *
457 * @pre This method can be called if @p scip is in one of the following stages:
458 * - \ref SCIP_STAGE_SOLVING
459 *
460 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
461 */
462 SCIP_RETCODE SCIPgetLPColsData(
463 SCIP* scip, /**< SCIP data structure */
464 SCIP_COL*** cols, /**< pointer to store the array of LP columns, or NULL */
465 int* ncols /**< pointer to store the number of LP columns, or NULL */
466 )
467 {
468 SCIP_CALL( SCIPcheckStage(scip, "SCIPgetLPColsData", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
469
470 if( SCIPtreeIsFocusNodeLPConstructed(scip->tree) )
471 {
472 if( cols != NULL )
473 *cols = SCIPlpGetCols(scip->lp);
474 if( ncols != NULL )
475 *ncols = SCIPlpGetNCols(scip->lp);
476 }
477 else
478 {
479 if( cols != NULL )
480 *cols = NULL;
481 if( ncols != NULL )
482 *ncols = 0;
483 }
484
485 return SCIP_OKAY;
486 }
487
488 /** gets current LP columns
489 *
490 * @return the current LP columns.
491 *
492 * @pre This method can be called if @p scip is in one of the following stages:
493 * - \ref SCIP_STAGE_SOLVING
494 *
495 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
496 */
497 SCIP_COL** SCIPgetLPCols(
498 SCIP* scip /**< SCIP data structure */
499 )
500 {
501 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetLPCols", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
502
503 if( SCIPtreeIsFocusNodeLPConstructed(scip->tree) )
504 return SCIPlpGetCols(scip->lp);
505 else
506 return NULL;
507 }
508
509 /** gets current number of LP columns
510 *
511 * @return the current number of LP columns.
512 *
513 * @pre This method can be called if @p scip is in one of the following stages:
514 * - \ref SCIP_STAGE_SOLVING
515 *
516 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
517 */
518 int SCIPgetNLPCols(
519 SCIP* scip /**< SCIP data structure */
520 )
521 {
522 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetNLPCols", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
523
524 if( SCIPtreeIsFocusNodeLPConstructed(scip->tree) )
525 return SCIPlpGetNCols(scip->lp);
526 else
527 return 0;
528 }
529
530 /** gets current number of unfixed LP columns
531 *
532 * @return the current number of unfixed LP columns.
533 *
534 * @pre This method can be called if @p scip is in one of the following stages:
535 * - \ref SCIP_STAGE_SOLVING
536 *
537 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
538 */
539 int SCIPgetNUnfixedLPCols(
540 SCIP* scip /**< SCIP data structure */
541 )
542 {
543 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetNUnfixedLPCols", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
544
545 if( SCIPtreeIsFocusNodeLPConstructed(scip->tree) )
546 return SCIPlpGetNUnfixedCols(scip->lp, scip->set->num_epsilon);
547 else
548 return 0;
549 }
550
551 /** gets current LP rows along with the current number of LP rows
552 *
553 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
554 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
555 *
556 * @pre This method can be called if @p scip is in one of the following stages:
557 * - \ref SCIP_STAGE_SOLVING
558 *
559 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
560 */
561 SCIP_RETCODE SCIPgetLPRowsData(
562 SCIP* scip, /**< SCIP data structure */
563 SCIP_ROW*** rows, /**< pointer to store the array of LP rows, or NULL */
564 int* nrows /**< pointer to store the number of LP rows, or NULL */
565 )
566 {
567 SCIP_CALL( SCIPcheckStage(scip, "SCIPgetLPRowsData", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
568
569 if( SCIPtreeIsFocusNodeLPConstructed(scip->tree) )
570 {
571 if( rows != NULL )
572 *rows = SCIPlpGetRows(scip->lp);
573 if( nrows != NULL )
574 *nrows = SCIPlpGetNRows(scip->lp);
575 }
576 else
577 {
578 if( rows != NULL )
579 *rows = NULL;
580 if( nrows != NULL )
581 *nrows = 0;
582 }
583
584 return SCIP_OKAY;
585 }
586
587 /** gets current LP rows
588 *
589 * @return the current LP rows.
590 *
591 * @pre This method can be called if @p scip is in one of the following stages:
592 * - \ref SCIP_STAGE_SOLVING
593 *
594 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
595 */
596 SCIP_ROW** SCIPgetLPRows(
597 SCIP* scip /**< SCIP data structure */
598 )
599 {
600 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetLPRows", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
601
602 if( SCIPtreeIsFocusNodeLPConstructed(scip->tree) )
603 return SCIPlpGetRows(scip->lp);
604 else
605 return NULL;
606 }
607
608 /** gets current number of LP rows
609 *
610 * @return the current number of LP rows.
611 *
612 * @pre This method can be called if @p scip is in one of the following stages:
613 * - \ref SCIP_STAGE_SOLVING
614 *
615 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
616 */
617 int SCIPgetNLPRows(
618 SCIP* scip /**< SCIP data structure */
619 )
620 {
621 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetNLPRows", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
622
623 if( SCIPtreeIsFocusNodeLPConstructed(scip->tree) )
624 return SCIPlpGetNRows(scip->lp);
625 else
626 return 0;
627 }
628
629 /** returns TRUE iff all columns, i.e. every variable with non-empty column w.r.t. all ever created rows, are present
630 * in the LP, and FALSE, if there are additional already existing columns, that may be added to the LP in pricing
631 *
632 * @return TRUE iff all columns, i.e. every variable with non-empty column w.r.t. all ever created rows, are present
633 * in the LP, and FALSE, if there are additional already existing columns, that may be added to the LP in pricing.
634 *
635 * @pre This method can be called if @p scip is in one of the following stages:
636 * - \ref SCIP_STAGE_SOLVING
637 *
638 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
639 */
640 SCIP_Bool SCIPallColsInLP(
641 SCIP* scip /**< SCIP data structure */
642 )
643 {
644 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPallColsInLP", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
645
646 return SCIPprobAllColsInLP(scip->transprob, scip->set, scip->lp);
647 }
648
649 /** returns whether the current LP solution is basic, i.e. is defined by a valid simplex basis
650 *
651 * @return whether the current LP solution is basic, i.e. is defined by a valid simplex basis.
652 *
653 * @pre This method can be called if @p scip is in one of the following stages:
654 * - \ref SCIP_STAGE_SOLVING
655 *
656 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
657 */
658 SCIP_Bool SCIPisLPSolBasic(
659 SCIP* scip /**< SCIP data structure */
660 )
661 {
662 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPisLPSolBasic", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
663
664 return SCIPlpIsSolBasic(scip->lp);
665 }
666
667 /** gets all indices of basic columns and rows: index i >= 0 corresponds to column i, index i < 0 to row -i-1
668 *
669 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
670 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
671 *
672 * @pre This method can be called if @p scip is in one of the following stages:
673 * - \ref SCIP_STAGE_SOLVING
674 *
675 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
676 */
677 SCIP_RETCODE SCIPgetLPBasisInd(
678 SCIP* scip, /**< SCIP data structure */
679 int* basisind /**< pointer to store basis indices ready to keep number of rows entries */
680 )
681 {
682 SCIP_CALL( SCIPcheckStage(scip, "SCIPgetLPBasisInd", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
683
684 if( !SCIPlpIsSolBasic(scip->lp) )
685 {
686 SCIPerrorMessage("current LP solution is not basic\n");
687 return SCIP_INVALIDCALL;
688 }
689
690 SCIP_CALL( SCIPlpGetBasisInd(scip->lp, basisind) );
691
692 return SCIP_OKAY;
693 }
694
695 /** gets a row from the inverse basis matrix B^-1
696 *
697 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
698 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
699 *
700 * @pre This method can be called if @p scip is in one of the following stages:
701 * - \ref SCIP_STAGE_SOLVING
702 *
703 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
704 */
705 SCIP_RETCODE SCIPgetLPBInvRow(
706 SCIP* scip, /**< SCIP data structure */
707 int r, /**< row number */
708 SCIP_Real* coefs, /**< array to store the coefficients of the row */
709 int* inds, /**< array to store the non-zero indices, or NULL */
710 int* ninds /**< pointer to store the number of non-zero indices, or NULL
711 * (-1: if we do not store sparsity informations) */
712 )
713 {
714 SCIP_CALL( SCIPcheckStage(scip, "SCIPgetLPBInvRow", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
715
716 if( !SCIPlpIsSolBasic(scip->lp) )
717 {
718 SCIPerrorMessage("current LP solution is not basic\n");
719 return SCIP_INVALIDCALL;
720 }
721
722 SCIP_CALL( SCIPlpGetBInvRow(scip->lp, r, coefs, inds, ninds) );
723
724 /* debug check if the coef is the r-th line of the inverse matrix B^-1 */
725 SCIP_CALL( SCIPdebugCheckBInvRow(scip, r, coefs) ); /*lint !e506 !e774*/
726
727 return SCIP_OKAY;
728 }
729
730 /** gets a column from the inverse basis matrix B^-1
731 *
732 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
733 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
734 *
735 * @pre This method can be called if @p scip is in one of the following stages:
736 * - \ref SCIP_STAGE_SOLVING
737 *
738 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
739 */
740 SCIP_RETCODE SCIPgetLPBInvCol(
741 SCIP* scip, /**< SCIP data structure */
742 int c, /**< column number of B^-1; this is NOT the number of the column in the LP
743 * returned by SCIPcolGetLPPos(); you have to call SCIPgetBasisInd()
744 * to get the array which links the B^-1 column numbers to the row and
745 * column numbers of the LP! c must be between 0 and nrows-1, since the
746 * basis has the size nrows * nrows */
747 SCIP_Real* coefs, /**< array to store the coefficients of the column */
748 int* inds, /**< array to store the non-zero indices, or NULL */
749 int* ninds /**< pointer to store the number of non-zero indices, or NULL
750 * (-1: if we do not store sparsity informations) */
751 )
752 {
753 SCIP_CALL( SCIPcheckStage(scip, "SCIPgetLPBInvCol", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
754
755 if( !SCIPlpIsSolBasic(scip->lp) )
756 {
757 SCIPerrorMessage("current LP solution is not basic\n");
758 return SCIP_INVALIDCALL;
759 }
760
761 SCIP_CALL( SCIPlpGetBInvCol(scip->lp, c, coefs, inds, ninds) );
762
763 return SCIP_OKAY;
764 }
765
766 /** gets a row from the product of inverse basis matrix B^-1 and coefficient matrix A (i.e. from B^-1 * A)
767 *
768 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
769 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
770 *
771 * @pre This method can be called if @p scip is in one of the following stages:
772 * - \ref SCIP_STAGE_SOLVING
773 *
774 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
775 */
776 SCIP_RETCODE SCIPgetLPBInvARow(
777 SCIP* scip, /**< SCIP data structure */
778 int r, /**< row number */
779 SCIP_Real* binvrow, /**< row in B^-1 from prior call to SCIPgetLPBInvRow(), or NULL */
780 SCIP_Real* coefs, /**< array to store the coefficients of the row */
781 int* inds, /**< array to store the non-zero indices, or NULL */
782 int* ninds /**< pointer to store the number of non-zero indices, or NULL
783 * (-1: if we do not store sparsity informations) */
784 )
785 {
786 SCIP_CALL( SCIPcheckStage(scip, "SCIPgetLPBInvARow", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
787
788 if( !SCIPlpIsSolBasic(scip->lp) )
789 {
790 SCIPerrorMessage("current LP solution is not basic\n");
791 return SCIP_INVALIDCALL;
792 }
793
794 SCIP_CALL( SCIPlpGetBInvARow(scip->lp, r, binvrow, coefs, inds, ninds) );
795
796 return SCIP_OKAY;
797 }
798
799 /** gets a column from the product of inverse basis matrix B^-1 and coefficient matrix A (i.e. from B^-1 * A),
800 * i.e., it computes B^-1 * A_c with A_c being the c'th column of A
801 *
802 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
803 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
804 *
805 * @pre This method can be called if @p scip is in one of the following stages:
806 * - \ref SCIP_STAGE_SOLVING
807 *
808 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
809 */
810 SCIP_RETCODE SCIPgetLPBInvACol(
811 SCIP* scip, /**< SCIP data structure */
812 int c, /**< column number which can be accessed by SCIPcolGetLPPos() */
813 SCIP_Real* coefs, /**< array to store the coefficients of the column */
814 int* inds, /**< array to store the non-zero indices, or NULL */
815 int* ninds /**< pointer to store the number of non-zero indices, or NULL
816 * (-1: if we do not store sparsity informations) */
817 )
818 {
819 SCIP_CALL( SCIPcheckStage(scip, "SCIPgetLPBInvACol", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
820
821 if( !SCIPlpIsSolBasic(scip->lp) )
822 {
823 SCIPerrorMessage("current LP solution is not basic\n");
824 return SCIP_INVALIDCALL;
825 }
826
827 SCIP_CALL( SCIPlpGetBInvACol(scip->lp, c, coefs, inds, ninds) );
828
829 return SCIP_OKAY;
830 }
831
832 /** calculates a weighted sum of all LP rows; for negative weights, the left and right hand side of the corresponding
833 * LP row are swapped in the summation
834 *
835 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
836 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
837 *
838 * @pre This method can be called if @p scip is in one of the following stages:
839 * - \ref SCIP_STAGE_SOLVING
840 *
841 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
842 */
843 SCIP_RETCODE SCIPsumLPRows(
844 SCIP* scip, /**< SCIP data structure */
845 SCIP_Real* weights, /**< row weights in row summation */
846 SCIP_REALARRAY* sumcoef, /**< array to store sum coefficients indexed by variables' probindex */
847 SCIP_Real* sumlhs, /**< pointer to store the left hand side of the row summation */
848 SCIP_Real* sumrhs /**< pointer to store the right hand side of the row summation */
849 )
850 {
851 SCIP_CALL( SCIPcheckStage(scip, "SCIPsumLPRows", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
852
853 SCIP_CALL( SCIPlpSumRows(scip->lp, scip->set, scip->transprob, weights, sumcoef, sumlhs, sumrhs) );
854
855 return SCIP_OKAY;
856 }
857
858 /** interrupts or disables the interrupt of the currently ongoing lp solve; if the lp is not currently constructed just returns with no effect
859 *
860 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
861 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
862 *
863 * @pre This method can be called in any SCIP stage
864 */
865 SCIP_RETCODE SCIPinterruptLP(
866 SCIP* scip, /**< SCIP data structure */
867 SCIP_Bool interrupt /**< TRUE if interrupt should be set, FALSE if it should be disabled */
868 )
869 {
870 SCIP_CALL( SCIPcheckStage(scip, "SCIPinterruptLP", TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE) );
871
872 if( scip->lp == NULL )
873 return SCIP_OKAY;
874
875 SCIP_CALL( SCIPlpInterrupt(scip->lp, interrupt) );
876 if( interrupt )
877 scip->stat->userinterrupt = TRUE;
878
879 return SCIP_OKAY;
880 }
881
882 /** writes current LP to a file
883 *
884 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
885 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
886 *
887 * @pre This method can be called if @p scip is in one of the following stages:
888 * - \ref SCIP_STAGE_SOLVING
889 *
890 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
891 */
892 SCIP_RETCODE SCIPwriteLP(
893 SCIP* scip, /**< SCIP data structure */
894 const char* filename /**< file name */
895 )
896 {
897 SCIP_Bool cutoff;
898
899 SCIP_CALL( SCIPcheckStage(scip, "SCIPwriteLP", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
900
901 if( !SCIPtreeIsFocusNodeLPConstructed(scip->tree) )
902 {
903 SCIP_CALL( SCIPconstructCurrentLP(scip->mem->probmem, scip->set, scip->stat, scip->transprob, scip->origprob,
904 scip->tree, scip->reopt, scip->lp, scip->pricestore, scip->sepastore, scip->cutpool, scip->branchcand,
905 scip->eventqueue, scip->eventfilter, scip->cliquetable, FALSE, &cutoff) );
906 }
907
908 /* we need a flushed lp to write the current lp */
909 SCIP_CALL( SCIPlpFlush(scip->lp, scip->mem->probmem, scip->set, scip->eventqueue) );
910
911 SCIP_CALL( SCIPlpWrite(scip->lp, filename) );
912
913 return SCIP_OKAY;
914 }
915
916 /** writes MIP relaxation of the current branch-and-bound node to a file
917 *
918 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
919 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
920 *
921 * @pre This method can be called if @p scip is in one of the following stages:
922 * - \ref SCIP_STAGE_SOLVING
923 *
924 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
925 */
926 SCIP_RETCODE SCIPwriteMIP(
927 SCIP* scip, /**< SCIP data structure */
928 const char* filename, /**< file name */
929 SCIP_Bool genericnames, /**< should generic names like x_i and row_j be used in order to avoid
930 * troubles with reserved symbols? */
931 SCIP_Bool origobj, /**< should the original objective function be used? */
932 SCIP_Bool lazyconss /**< output removable rows as lazy constraints? */
933 )
934 {
935 SCIP_CALL( SCIPcheckStage(scip, "SCIPwriteMIP", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
936
937 /* we need a flushed lp to write the current mip */
938 SCIP_CALL( SCIPlpFlush(scip->lp, scip->mem->probmem, scip->set, scip->eventqueue) );
939
940 SCIP_CALL( SCIPlpWriteMip(scip->lp, scip->set, scip->messagehdlr, filename, genericnames,
941 origobj, scip->origprob->objsense, scip->transprob->objscale, scip->transprob->objoffset, lazyconss) );
942
943 return SCIP_OKAY;
944 }
945
946 /** gets the LP interface of SCIP;
947 * with the LPI you can use all of the methods defined in lpi/lpi.h;
948 *
949 * @warning You have to make sure, that the full internal state of the LPI does not change or is recovered completely
950 * after the end of the method that uses the LPI. In particular, if you manipulate the LP or its solution
951 * (e.g. by calling one of the SCIPlpiAdd...() or one of the SCIPlpiSolve...() methods), you have to check in
952 * advance with SCIPlpiWasSolved() whether the LP is currently solved. If this is the case, you have to make
953 * sure, the internal solution status is recovered completely at the end of your method. This can be achieved
954 * by getting the LPI state before applying any LPI manipulations with SCIPlpiGetState() and restoring it
955 * afterwards with SCIPlpiSetState() and SCIPlpiFreeState(). Additionally you have to resolve the LP with the
956 * appropriate SCIPlpiSolve...() call in order to reinstall the internal solution status.
957 *
958 * @warning Make also sure, that all parameter values that you have changed are set back to their original values.
959 *
960 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
961 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
962 *
963 * @pre This method can be called if @p scip is in one of the following stages:
964 * - \ref SCIP_STAGE_TRANSFORMED
965 * - \ref SCIP_STAGE_INITPRESOLVE
966 * - \ref SCIP_STAGE_PRESOLVING
967 * - \ref SCIP_STAGE_EXITPRESOLVE
968 * - \ref SCIP_STAGE_PRESOLVED
969 * - \ref SCIP_STAGE_INITSOLVE
970 * - \ref SCIP_STAGE_SOLVING
971 * - \ref SCIP_STAGE_SOLVED
972 * - \ref SCIP_STAGE_EXITSOLVE
973 *
974 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
975 */
976 SCIP_RETCODE SCIPgetLPI(
977 SCIP* scip, /**< SCIP data structure */
978 SCIP_LPI** lpi /**< pointer to store the LP interface */
979 )
980 {
981 assert(lpi != NULL);
982
983 SCIP_CALL( SCIPcheckStage(scip, "SCIPgetLPI", FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE) );
984
985 *lpi = SCIPlpGetLPI(scip->lp);
986
987 return SCIP_OKAY;
988 }
989
990 /** displays quality information about the current LP solution. An LP solution need to be available; information printed
991 * is subject to what the LP solver supports
992 *
993 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
994 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
995 *
996 * @pre This method can be called if @p scip is in one of the following stages:
997 * - \ref SCIP_STAGE_INIT
998 * - \ref SCIP_STAGE_PROBLEM
999 * - \ref SCIP_STAGE_TRANSFORMED
1000 * - \ref SCIP_STAGE_INITPRESOLVE
1001 * - \ref SCIP_STAGE_PRESOLVING
1002 * - \ref SCIP_STAGE_EXITPRESOLVE
1003 * - \ref SCIP_STAGE_PRESOLVED
1004 * - \ref SCIP_STAGE_SOLVING
1005 * - \ref SCIP_STAGE_SOLVED
1006 * - \ref SCIP_STAGE_FREE
1007 *
1008 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
1009 *
1010 * @note The printing process is done via the message handler system.
1011 */
1012 SCIP_RETCODE SCIPprintLPSolutionQuality(
1013 SCIP* scip, /**< SCIP data structure */
1014 FILE* file /**< output file (or NULL for standard output) */
1015 )
1016 {
1017 SCIP_LPI* lpi;
1018 SCIP_Real quality;
1019
1020 SCIP_CALL( SCIPcheckStage(scip, "SCIPprintLPSolutionQuality", TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE) );
1021
1022 switch( scip->set->stage )
1023 {
1024 case SCIP_STAGE_INIT:
1025 case SCIP_STAGE_PROBLEM:
1026 case SCIP_STAGE_TRANSFORMED:
1027 case SCIP_STAGE_INITPRESOLVE:
1028 case SCIP_STAGE_PRESOLVING:
1029 case SCIP_STAGE_EXITPRESOLVE:
1030 case SCIP_STAGE_PRESOLVED:
1031 SCIPmessageFPrintInfo(scip->messagehdlr, file, "Problem not solving yet, no LP available.\n");
1032 return SCIP_OKAY;
1033
1034 case SCIP_STAGE_SOLVING:
1035 case SCIP_STAGE_SOLVED:
1036 break;
1037
1038 default:
1039 SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
1040 return SCIP_INVALIDCALL;
1041 } /*lint !e788*/
1042
1043 /* note that after diving mode, the LPI may only have the basis information, but SCIPlpiWasSolved() can be false; in
1044 * this case, we will (depending on the LP solver) probably not obtain the quality measure; one solution would be to
1045 * store the results of SCIPlpiGetRealSolQuality() within the SCIP_LP after each LP solve; this would have the added
1046 * advantage, that we reduce direct access to the LPI, but it sounds potentially expensive
1047 */
1048 lpi = SCIPlpGetLPI(scip->lp);
1049 assert(lpi != NULL);
1050
1051 SCIP_CALL( SCIPlpiGetRealSolQuality(lpi, SCIP_LPSOLQUALITY_ESTIMCONDITION, &quality) );
1052 SCIPmessageFPrintInfo(scip->messagehdlr, file, "Basis matrix condition (estimated): ");
1053 if( quality != SCIP_INVALID ) /*lint !e777*/
1054 SCIPmessageFPrintInfo(scip->messagehdlr, file, "%.6e\n", quality);
1055 else
1056 SCIPmessageFPrintInfo(scip->messagehdlr, file, "not available\n");
1057
1058 SCIP_CALL( SCIPlpiGetRealSolQuality(lpi, SCIP_LPSOLQUALITY_EXACTCONDITION, &quality) );
1059 SCIPmessageFPrintInfo(scip->messagehdlr, file, "Basis matrix condition (exact): ");
1060 if( quality != SCIP_INVALID ) /*lint !e777*/
1061 SCIPmessageFPrintInfo(scip->messagehdlr, file, "%.6e\n", quality);
1062 else
1063 SCIPmessageFPrintInfo(scip->messagehdlr, file, "not available\n");
1064
1065 return SCIP_OKAY;
1066 }
1067
1068 /** compute relative interior point to current LP
1069 * @see SCIPlpComputeRelIntPoint
1070 *
1071 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1072 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1073 *
1074 * @pre This method can be called if @p scip is in one of the following stages:
1075 * - \ref SCIP_STAGE_TRANSFORMED
1076 * - \ref SCIP_STAGE_INITPRESOLVE
1077 * - \ref SCIP_STAGE_PRESOLVING
1078 * - \ref SCIP_STAGE_EXITPRESOLVE
1079 * - \ref SCIP_STAGE_PRESOLVED
1080 * - \ref SCIP_STAGE_SOLVING
1081 * - \ref SCIP_STAGE_SOLVED
1082 *
1083 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
1084 */
1085 SCIP_RETCODE SCIPcomputeLPRelIntPoint(
1086 SCIP* scip, /**< SCIP data structure */
1087 SCIP_Bool relaxrows, /**< should the rows be relaxed */
1088 SCIP_Bool inclobjcutoff, /**< should a row for the objective cutoff be included */
1089 SCIP_Real timelimit, /**< time limit for LP solver */
1090 int iterlimit, /**< iteration limit for LP solver */
1091 SCIP_SOL** point /**< relative interior point on exit */
1092 )
1093 {
1094 SCIP_Real* pointvals;
1095 SCIP_Bool success;
1096
1097 SCIP_CALL( SCIPcheckStage(scip, "SCIPcomputeLPRelIntPoint", FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE) );
1098
1099 assert(scip != NULL);
1100 assert(scip->lp != NULL);
1101 assert(point != NULL);
1102
1103 *point = NULL;
1104
1105 SCIP_CALL( SCIPallocBufferArray(scip, &pointvals, SCIPlpGetNCols(scip->lp)) );
1106
1107 SCIP_CALL( SCIPlpComputeRelIntPoint(scip->set, scip->messagehdlr, scip->lp, scip->transprob,
1108 relaxrows, inclobjcutoff, timelimit, iterlimit, pointvals, &success) );
1109
1110 /* if successful, create new solution with point values */
1111 if( success )
1112 {
1113 int i;
1114
1115 SCIP_CALL( SCIPcreateSol(scip, point, NULL) );
1116
1117 for( i = 0; i < SCIPlpGetNCols(scip->lp); ++i )
1118 {
1119 SCIP_CALL( SCIPsetSolVal(scip, *point, SCIPcolGetVar(SCIPlpGetCols(scip->lp)[i]), pointvals[i]) );
1120 }
1121 }
1122
1123 SCIPfreeBufferArray(scip, &pointvals);
1124
1125 return SCIP_OKAY;
1126 }
1127
1128 /*
1129 * LP column methods
1130 */
1131
1132 /** returns the reduced costs of a column in the last (feasible) LP
1133 *
1134 * @return the reduced costs of a column in the last (feasible) LP
1135 *
1136 * @pre this method can be called in one of the following stages of the SCIP solving process:
1137 * - \ref SCIP_STAGE_SOLVING
1138 * - \ref SCIP_STAGE_SOLVED
1139 *
1140 * @note calling this method in SCIP_STAGE_SOLVED is only recommended to experienced users and should only be called
1141 * for pure LP instances (without presolving)
1142 *
1143 * @note The return value of this method should be used carefully if the dual feasibility check was explictely disabled.
1144 */
1145 SCIP_Real SCIPgetColRedcost(
1146 SCIP* scip, /**< SCIP data structure */
1147 SCIP_COL* col /**< LP column */
1148 )
1149 {
1150 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetColRedcost", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE) );
1151
1152 if( !SCIPtreeHasCurrentNodeLP(scip->tree) )
1153 {
1154 SCIPerrorMessage("cannot get reduced costs, because node LP is not processed\n");
1155 SCIPABORT();
1156 return 0.0; /*lint !e527*/
1157 }
1158
1159 return SCIPcolGetRedcost(col, scip->stat, scip->lp);
1160 }
1161
1162
1163 /** returns the Farkas coefficient of a column in the last (infeasible) LP
1164 *
1165 * @return the Farkas coefficient of a column in the last (infeasible) LP
1166 *
1167 * @pre this method can be called in one of the following stages of the SCIP solving process:
1168 * - \ref SCIP_STAGE_SOLVING
1169 * - \ref SCIP_STAGE_SOLVED
1170 */
1171 SCIP_Real SCIPgetColFarkasCoef(
1172 SCIP* scip, /**< SCIP data structure */
1173 SCIP_COL* col /**< LP column */
1174 )
1175 {
1176 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetColFarkasCoef", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE) );
1177
1178 if( !SCIPtreeHasCurrentNodeLP(scip->tree) )
1179 {
1180 SCIPerrorMessage("cannot get Farkas coeff, because node LP is not processed\n");
1181 SCIPABORT();
1182 return 0.0; /*lint !e527*/
1183 }
1184
1185 return SCIPcolGetFarkasCoef(col, scip->stat, scip->lp);
1186 }
1187
1188 /** marks a column to be not removable from the LP in the current node
1189 *
1190 * @pre this method can be called in the following stage of the SCIP solving process:
1191 * - \ref SCIP_STAGE_SOLVING
1192 */
1193 void SCIPmarkColNotRemovableLocal(
1194 SCIP* scip, /**< SCIP data structure */
1195 SCIP_COL* col /**< LP column */
1196 )
1197 {
1198 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPmarkColNotRemovableLocal", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1199
1200 SCIPcolMarkNotRemovableLocal(col, scip->stat);
1201 }
1202
1203 /*
1204 * LP row methods
1205 */
1206
1207 /** creates and captures an LP row from a constraint handler
1208 *
1209 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1210 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1211 *
1212 * @pre this method can be called in one of the following stages of the SCIP solving process:
1213 * - \ref SCIP_STAGE_INITSOLVE
1214 * - \ref SCIP_STAGE_SOLVING
1215 */
1216 SCIP_RETCODE SCIPcreateRowConshdlr(
1217 SCIP* scip, /**< SCIP data structure */
1218 SCIP_ROW** row, /**< pointer to row */
1219 SCIP_CONSHDLR* conshdlr, /**< constraint handler that creates the row */
1220 const char* name, /**< name of row */
1221 int len, /**< number of nonzeros in the row */
1222 SCIP_COL** cols, /**< array with columns of row entries */
1223 SCIP_Real* vals, /**< array with coefficients of row entries */
1224 SCIP_Real lhs, /**< left hand side of row */
1225 SCIP_Real rhs, /**< right hand side of row */
1226 SCIP_Bool local, /**< is row only valid locally? */
1227 SCIP_Bool modifiable, /**< is row modifiable during node processing (subject to column generation)? */
1228 SCIP_Bool removable /**< should the row be removed from the LP due to aging or cleanup? */
1229 )
1230 {
1231 assert(conshdlr != NULL);
1232
1233 SCIP_CALL( SCIPcheckStage(scip, "SCIPcreateRowConshdlr", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1234
1235 SCIP_CALL( SCIProwCreate(row, scip->mem->probmem, scip->set, scip->stat,
1236 name, len, cols, vals, lhs, rhs, SCIP_ROWORIGINTYPE_CONSHDLR, (void*) conshdlr, local, modifiable, removable) );
1237
1238 return SCIP_OKAY;
1239 }
1240
1241 /** creates and captures an LP row from a constraint
1242 *
1243 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1244 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1245 *
1246 * @pre this method can be called in one of the following stages of the SCIP solving process:
1247 * - \ref SCIP_STAGE_INITSOLVE
1248 * - \ref SCIP_STAGE_SOLVING
1249 */
1250 SCIP_RETCODE SCIPcreateRowCons(
1251 SCIP* scip, /**< SCIP data structure */
1252 SCIP_ROW** row, /**< pointer to row */
1253 SCIP_CONS* cons, /**< constraint that creates the row */
1254 const char* name, /**< name of row */
1255 int len, /**< number of nonzeros in the row */
1256 SCIP_COL** cols, /**< array with columns of row entries */
1257 SCIP_Real* vals, /**< array with coefficients of row entries */
1258 SCIP_Real lhs, /**< left hand side of row */
1259 SCIP_Real rhs, /**< right hand side of row */
1260 SCIP_Bool local, /**< is row only valid locally? */
1261 SCIP_Bool modifiable, /**< is row modifiable during node processing (subject to column generation)? */
1262 SCIP_Bool removable /**< should the row be removed from the LP due to aging or cleanup? */
1263 )
1264 {
1265 assert(cons != NULL);
1266
1267 SCIP_CALL( SCIPcheckStage(scip, "SCIPcreateRowCons", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1268
1269 SCIP_CALL( SCIProwCreate(row, scip->mem->probmem, scip->set, scip->stat,
1270 name, len, cols, vals, lhs, rhs, SCIP_ROWORIGINTYPE_CONS, (void*) cons, local, modifiable, removable) );
1271
1272 return SCIP_OKAY;
1273 }
1274
1275 /** creates and captures an LP row from a separator
1276 *
1277 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1278 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1279 *
1280 * @pre this method can be called in one of the following stages of the SCIP solving process:
1281 * - \ref SCIP_STAGE_INITSOLVE
1282 * - \ref SCIP_STAGE_SOLVING
1283 */
1284 SCIP_RETCODE SCIPcreateRowSepa(
1285 SCIP* scip, /**< SCIP data structure */
1286 SCIP_ROW** row, /**< pointer to row */
1287 SCIP_SEPA* sepa, /**< separator that creates the row */
1288 const char* name, /**< name of row */
1289 int len, /**< number of nonzeros in the row */
1290 SCIP_COL** cols, /**< array with columns of row entries */
1291 SCIP_Real* vals, /**< array with coefficients of row entries */
1292 SCIP_Real lhs, /**< left hand side of row */
1293 SCIP_Real rhs, /**< right hand side of row */
1294 SCIP_Bool local, /**< is row only valid locally? */
1295 SCIP_Bool modifiable, /**< is row modifiable during node processing (subject to column generation)? */
1296 SCIP_Bool removable /**< should the row be removed from the LP due to aging or cleanup? */
1297 )
1298 {
1299 assert(sepa != NULL);
1300
1301 SCIP_CALL( SCIPcheckStage(scip, "SCIPcreateRowSepa", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1302
1303 SCIP_CALL( SCIProwCreate(row, scip->mem->probmem, scip->set, scip->stat,
1304 name, len, cols, vals, lhs, rhs, SCIP_ROWORIGINTYPE_SEPA, (void*) sepa, local, modifiable, removable) );
1305
1306 return SCIP_OKAY;
1307 }
1308
1309 /** creates and captures an LP row from an unspecified source
1310 *
1311 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1312 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1313 *
1314 * @pre this method can be called in one of the following stages of the SCIP solving process:
1315 * - \ref SCIP_STAGE_INITSOLVE
1316 * - \ref SCIP_STAGE_SOLVING
1317 */
1318 SCIP_RETCODE SCIPcreateRowUnspec(
1319 SCIP* scip, /**< SCIP data structure */
1320 SCIP_ROW** row, /**< pointer to row */
1321 const char* name, /**< name of row */
1322 int len, /**< number of nonzeros in the row */
1323 SCIP_COL** cols, /**< array with columns of row entries */
1324 SCIP_Real* vals, /**< array with coefficients of row entries */
1325 SCIP_Real lhs, /**< left hand side of row */
1326 SCIP_Real rhs, /**< right hand side of row */
1327 SCIP_Bool local, /**< is row only valid locally? */
1328 SCIP_Bool modifiable, /**< is row modifiable during node processing (subject to column generation)? */
1329 SCIP_Bool removable /**< should the row be removed from the LP due to aging or cleanup? */
1330 )
1331 {
1332 SCIP_CALL( SCIPcheckStage(scip, "SCIPcreateRowUnspec", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1333
1334 SCIP_CALL( SCIProwCreate(row, scip->mem->probmem, scip->set, scip->stat,
1335 name, len, cols, vals, lhs, rhs, SCIP_ROWORIGINTYPE_UNSPEC, NULL, local, modifiable, removable) );
1336
1337 return SCIP_OKAY;
1338 }
1339
1340 /** creates and captures an LP row
1341 *
1342 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1343 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1344 *
1345 * @pre this method can be called in one of the following stages of the SCIP solving process:
1346 * - \ref SCIP_STAGE_INITSOLVE
1347 * - \ref SCIP_STAGE_SOLVING
1348 *
1349 * @deprecated Please use SCIPcreateRowConshdlr() or SCIPcreateRowSepa() when calling from a constraint handler or separator in order
1350 * to facilitate correct statistics. If the call is from neither a constraint handler or separator, use SCIPcreateRowUnspec().
1351 */
1352 SCIP_RETCODE SCIPcreateRow(
1353 SCIP* scip, /**< SCIP data structure */
1354 SCIP_ROW** row, /**< pointer to row */
1355 const char* name, /**< name of row */
1356 int len, /**< number of nonzeros in the row */
1357 SCIP_COL** cols, /**< array with columns of row entries */
1358 SCIP_Real* vals, /**< array with coefficients of row entries */
1359 SCIP_Real lhs, /**< left hand side of row */
1360 SCIP_Real rhs, /**< right hand side of row */
1361 SCIP_Bool local, /**< is row only valid locally? */
1362 SCIP_Bool modifiable, /**< is row modifiable during node processing (subject to column generation)? */
1363 SCIP_Bool removable /**< should the row be removed from the LP due to aging or cleanup? */
1364 )
1365 {
1366 SCIP_CALL( SCIPcheckStage(scip, "SCIPcreateRow", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1367
1368 SCIP_CALL( SCIPcreateRowUnspec(scip, row, name, len, cols, vals, lhs, rhs, local, modifiable, removable) );
1369
1370 return SCIP_OKAY;
1371 }
1372
1373 /** creates and captures an LP row without any coefficients from a constraint handler
1374 *
1375 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1376 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1377 *
1378 * @pre this method can be called in one of the following stages of the SCIP solving process:
1379 * - \ref SCIP_STAGE_INITSOLVE
1380 * - \ref SCIP_STAGE_SOLVING
1381 */
1382 SCIP_RETCODE SCIPcreateEmptyRowConshdlr(
1383 SCIP* scip, /**< SCIP data structure */
1384 SCIP_ROW** row, /**< pointer to row */
1385 SCIP_CONSHDLR* conshdlr, /**< constraint handler that creates the row */
1386 const char* name, /**< name of row */
1387 SCIP_Real lhs, /**< left hand side of row */
1388 SCIP_Real rhs, /**< right hand side of row */
1389 SCIP_Bool local, /**< is row only valid locally? */
1390 SCIP_Bool modifiable, /**< is row modifiable during node processing (subject to column generation)? */
1391 SCIP_Bool removable /**< should the row be removed from the LP due to aging or cleanup? */
1392 )
1393 {
1394 assert(conshdlr != NULL);
1395
1396 SCIP_CALL( SCIPcheckStage(scip, "SCIPcreateEmptyRowConshdlr", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1397
1398 SCIP_CALL( SCIProwCreate(row, scip->mem->probmem, scip->set, scip->stat,
1399 name, 0, NULL, NULL, lhs, rhs, SCIP_ROWORIGINTYPE_CONSHDLR, (void*) conshdlr, local, modifiable, removable) );
1400
1401 return SCIP_OKAY;
1402 }
1403
1404 /** creates and captures an LP row without any coefficients from a constraint
1405 *
1406 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1407 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1408 *
1409 * @pre this method can be called in one of the following stages of the SCIP solving process:
1410 * - \ref SCIP_STAGE_INITSOLVE
1411 * - \ref SCIP_STAGE_SOLVING
1412 */
1413 SCIP_RETCODE SCIPcreateEmptyRowCons(
1414 SCIP* scip, /**< SCIP data structure */
1415 SCIP_ROW** row, /**< pointer to row */
1416 SCIP_CONS* cons, /**< constraint that creates the row */
1417 const char* name, /**< name of row */
1418 SCIP_Real lhs, /**< left hand side of row */
1419 SCIP_Real rhs, /**< right hand side of row */
1420 SCIP_Bool local, /**< is row only valid locally? */
1421 SCIP_Bool modifiable, /**< is row modifiable during node processing (subject to column generation)? */
1422 SCIP_Bool removable /**< should the row be removed from the LP due to aging or cleanup? */
1423 )
1424 {
1425 assert(cons != NULL);
1426
1427 SCIP_CALL( SCIPcheckStage(scip, "SCIPcreateEmptyRowCons", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1428
1429 SCIP_CALL( SCIProwCreate(row, scip->mem->probmem, scip->set, scip->stat,
1430 name, 0, NULL, NULL, lhs, rhs, SCIP_ROWORIGINTYPE_CONS, (void*) cons, local, modifiable, removable) );
1431
1432 return SCIP_OKAY;
1433 }
1434
1435 /** creates and captures an LP row without any coefficients from a separator
1436 *
1437 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1438 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1439 *
1440 * @pre this method can be called in one of the following stages of the SCIP solving process:
1441 * - \ref SCIP_STAGE_INITSOLVE
1442 * - \ref SCIP_STAGE_SOLVING
1443 */
1444 SCIP_RETCODE SCIPcreateEmptyRowSepa(
1445 SCIP* scip, /**< SCIP data structure */
1446 SCIP_ROW** row, /**< pointer to row */
1447 SCIP_SEPA* sepa, /**< separator that creates the row */
1448 const char* name, /**< name of row */
1449 SCIP_Real lhs, /**< left hand side of row */
1450 SCIP_Real rhs, /**< right hand side of row */
1451 SCIP_Bool local, /**< is row only valid locally? */
1452 SCIP_Bool modifiable, /**< is row modifiable during node processing (subject to column generation)? */
1453 SCIP_Bool removable /**< should the row be removed from the LP due to aging or cleanup? */
1454 )
1455 {
1456 SCIP_CALL( SCIPcheckStage(scip, "SCIPcreateEmptyRowSepa", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1457
1458 SCIP_CALL( SCIProwCreate(row, scip->mem->probmem, scip->set, scip->stat,
1459 name, 0, NULL, NULL, lhs, rhs, SCIP_ROWORIGINTYPE_SEPA, (void*) sepa, local, modifiable, removable) );
1460
1461 return SCIP_OKAY;
1462 }
1463
1464 /** creates and captures an LP row without any coefficients from an unspecified source
1465 *
1466 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1467 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1468 *
1469 * @pre this method can be called in one of the following stages of the SCIP solving process:
1470 * - \ref SCIP_STAGE_INITSOLVE
1471 * - \ref SCIP_STAGE_SOLVING
1472 */
1473 SCIP_RETCODE SCIPcreateEmptyRowUnspec(
1474 SCIP* scip, /**< SCIP data structure */
1475 SCIP_ROW** row, /**< pointer to row */
1476 const char* name, /**< name of row */
1477 SCIP_Real lhs, /**< left hand side of row */
1478 SCIP_Real rhs, /**< right hand side of row */
1479 SCIP_Bool local, /**< is row only valid locally? */
1480 SCIP_Bool modifiable, /**< is row modifiable during node processing (subject to column generation)? */
1481 SCIP_Bool removable /**< should the row be removed from the LP due to aging or cleanup? */
1482 )
1483 {
1484 SCIP_CALL( SCIPcheckStage(scip, "SCIPcreateEmptyRowUnspec", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1485
1486 SCIP_CALL( SCIProwCreate(row, scip->mem->probmem, scip->set, scip->stat,
1487 name, 0, NULL, NULL, lhs, rhs, SCIP_ROWORIGINTYPE_UNSPEC, NULL, local, modifiable, removable) );
1488
1489 return SCIP_OKAY;
1490 }
1491
1492 /** creates and captures an LP row without any coefficients
1493 *
1494 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1495 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1496 *
1497 * @pre this method can be called in one of the following stages of the SCIP solving process:
1498 * - \ref SCIP_STAGE_INITSOLVE
1499 * - \ref SCIP_STAGE_SOLVING
1500 *
1501 * @deprecated Please use SCIPcreateEmptyRowConshdlr() or SCIPcreateEmptyRowSepa() when calling from a constraint handler or separator in order
1502 * to facilitate correct statistics. If the call is from neither a constraint handler or separator, use SCIPcreateEmptyRowUnspec().
1503 */
1504 SCIP_RETCODE SCIPcreateEmptyRow(
1505 SCIP* scip, /**< SCIP data structure */
1506 SCIP_ROW** row, /**< pointer to row */
1507 const char* name, /**< name of row */
1508 SCIP_Real lhs, /**< left hand side of row */
1509 SCIP_Real rhs, /**< right hand side of row */
1510 SCIP_Bool local, /**< is row only valid locally? */
1511 SCIP_Bool modifiable, /**< is row modifiable during node processing (subject to column generation)? */
1512 SCIP_Bool removable /**< should the row be removed from the LP due to aging or cleanup? */
1513 )
1514 {
1515 SCIP_CALL( SCIPcheckStage(scip, "SCIPcreateEmptyRow", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1516
1517 SCIP_CALL( SCIPcreateEmptyRowUnspec(scip, row, name, lhs, rhs, local, modifiable, removable) );
1518
1519 return SCIP_OKAY;
1520 }
1521
1522 /** increases usage counter of LP row
1523 *
1524 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1525 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1526 *
1527 * @pre this method can be called in one of the following stages of the SCIP solving process:
1528 * - \ref SCIP_STAGE_INITSOLVE
1529 * - \ref SCIP_STAGE_SOLVING
1530 */
1531 SCIP_RETCODE SCIPcaptureRow(
1532 SCIP* scip, /**< SCIP data structure */
1533 SCIP_ROW* row /**< row to capture */
1534 )
1535 {
1536 SCIP_CALL( SCIPcheckStage(scip, "SCIPcaptureRow", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1537
1538 SCIProwCapture(row);
1539
1540 return SCIP_OKAY;
1541 }
1542
1543 /** decreases usage counter of LP row, and frees memory if necessary
1544 *
1545 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1546 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1547 *
1548 * @pre this method can be called in one of the following stages of the SCIP solving process:
1549 * - \ref SCIP_STAGE_INITSOLVE
1550 * - \ref SCIP_STAGE_SOLVING
1551 * - \ref SCIP_STAGE_EXITSOLVE
1552 */
1553 SCIP_RETCODE SCIPreleaseRow(
1554 SCIP* scip, /**< SCIP data structure */
1555 SCIP_ROW** row /**< pointer to LP row */
1556 )
1557 {
1558 SCIP_CALL( SCIPcheckStage(scip, "SCIPreleaseRow", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE) );
1559
1560 SCIP_CALL( SCIProwRelease(row, scip->mem->probmem, scip->set, scip->lp) );
1561
1562 return SCIP_OKAY;
1563 }
1564
1565 /** changes left hand side of LP row
1566 *
1567 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1568 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1569 *
1570 * @pre this method can be called in one of the following stages of the SCIP solving process:
1571 * - \ref SCIP_STAGE_INITSOLVE
1572 * - \ref SCIP_STAGE_SOLVING
1573 */
1574 SCIP_RETCODE SCIPchgRowLhs(
1575 SCIP* scip, /**< SCIP data structure */
1576 SCIP_ROW* row, /**< LP row */
1577 SCIP_Real lhs /**< new left hand side */
1578 )
1579 {
1580 SCIP_CALL( SCIPcheckStage(scip, "SCIPchgRowLhs", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1581
1582 assert(!SCIPlpDiving(scip->lp) || (row->lppos == -1));
1583
1584 SCIP_CALL( SCIProwChgLhs(row, scip->mem->probmem, scip->set, scip->eventqueue, scip->lp, lhs) );
1585
1586 return SCIP_OKAY;
1587 }
1588
1589 /** changes right hand side of LP row
1590 *
1591 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1592 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1593 *
1594 * @pre this method can be called in one of the following stages of the SCIP solving process:
1595 * - \ref SCIP_STAGE_INITSOLVE
1596 * - \ref SCIP_STAGE_SOLVING
1597 */
1598 SCIP_RETCODE SCIPchgRowRhs(
1599 SCIP* scip, /**< SCIP data structure */
1600 SCIP_ROW* row, /**< LP row */
1601 SCIP_Real rhs /**< new right hand side */
1602 )
1603 {
1604 SCIP_CALL( SCIPcheckStage(scip, "SCIPchgRowRhs", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1605
1606 assert(!SCIPlpDiving(scip->lp) || (row->lppos == -1));
1607
1608 SCIP_CALL( SCIProwChgRhs(row, scip->mem->probmem, scip->set, scip->eventqueue, scip->lp, rhs) );
1609
1610 return SCIP_OKAY;
1611 }
1612
1613 /** informs row, that all subsequent additions of variables to the row should be cached and not directly applied;
1614 * after all additions were applied, SCIPflushRowExtensions() must be called;
1615 * while the caching of row extensions is activated, information methods of the row give invalid results;
1616 * caching should be used, if a row is build with SCIPaddVarToRow() calls variable by variable to increase
1617 * the performance
1618 *
1619 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1620 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1621 *
1622 * @pre this method can be called in one of the following stages of the SCIP solving process:
1623 * - \ref SCIP_STAGE_INITSOLVE
1624 * - \ref SCIP_STAGE_SOLVING
1625 */
1626 SCIP_RETCODE SCIPcacheRowExtensions(
1627 SCIP* scip, /**< SCIP data structure */
1628 SCIP_ROW* row /**< LP row */
1629 )
1630 {
1631 SCIP_CALL( SCIPcheckStage(scip, "SCIPcacheRowExtensions", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1632
1633 /* delay the row sorting */
1634 SCIProwDelaySort(row);
1635
1636 return SCIP_OKAY;
1637 }
1638
1639 /** flushes all cached row extensions after a call of SCIPcacheRowExtensions() and merges coefficients with
1640 * equal columns into a single coefficient
1641 *
1642 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1643 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1644 *
1645 * @pre this method can be called in one of the following stages of the SCIP solving process:
1646 * - \ref SCIP_STAGE_INITSOLVE
1647 * - \ref SCIP_STAGE_SOLVING
1648 */
1649 SCIP_RETCODE SCIPflushRowExtensions(
1650 SCIP* scip, /**< SCIP data structure */
1651 SCIP_ROW* row /**< LP row */
1652 )
1653 {
1654 SCIP_CALL( SCIPcheckStage(scip, "SCIPflushRowExtensions", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1655
1656 /* force the row sorting, and merge equal column entries */
1657 SCIProwForceSort(row, scip->set);
1658
1659 return SCIP_OKAY;
1660 }
1661
1662 /** resolves variable to columns and adds them with the coefficient to the row
1663 *
1664 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1665 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1666 *
1667 * @attention If the absolute value of val is below the SCIP epsilon tolerance, the variable will not added.
1668 *
1669 * @pre this method can be called in one of the following stages of the SCIP solving process:
1670 * - \ref SCIP_STAGE_INITSOLVE
1671 * - \ref SCIP_STAGE_SOLVING
1672 *
1673 * @note In case calling this method in the enforcement process of an lp solution, it might be that some variables,
1674 * that were not yet in the LP (e.g. dynamic columns) will change their lp solution value returned by SCIP.
1675 * For example, a variable, which has a negative objective value, that has no column in the lp yet, is in the lp solution
1676 * on its upper bound (variables with status SCIP_VARSTATUS_LOOSE are in an lp solution on it's best bound), but
1677 * creating the column, changes the solution value (variable than has status SCIP_VARSTATUS_COLUMN, and the
1678 * initialization sets the lp solution value) to 0.0. (This leads to the conclusion that, if a constraint was
1679 * violated, the linear relaxation might not be violated anymore.)
1680 *
1681 * @note If the variable being added is FIXED (as given by the status SCIP_VARSTATUS_FIXED), then the variable is not
1682 * added to the row, but the corresponding constant is added. Similarly, if the input variable is aggregated (as
1683 * given by the status SCIP_VARSTATUS_AGGREGATED), then the input variable is substituted with its aggregation.
1684 * For other cases, and to better understand the function behavior, please check the code of SCIPvarAddToRow.
1685 */
1686 SCIP_RETCODE SCIPaddVarToRow(
1687 SCIP* scip, /**< SCIP data structure */
1688 SCIP_ROW* row, /**< LP row */
1689 SCIP_VAR* var, /**< problem variable */
1690 SCIP_Real val /**< value of coefficient */
1691 )
1692 {
|
(1) Event cond_false: |
Condition "(_restat_ = SCIP_OKAY) != SCIP_OKAY", taking false branch. |
|
(2) Event if_end: |
End of if statement. |
1693 SCIP_CALL( SCIPcheckStage(scip, "SCIPaddVarToRow", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1694
|
(3) Event deref_parm_in_call: |
Function "SCIPvarAddToRow" dereferences "var". [details] |
1695 SCIP_CALL( SCIPvarAddToRow(var, scip->mem->probmem, scip->set, scip->stat, scip->eventqueue, scip->transprob, scip->lp, row, val) );
1696
1697 return SCIP_OKAY;
1698 }
1699
1700 /** resolves variables to columns and adds them with the coefficients to the row;
1701 * this method caches the row extensions and flushes them afterwards to gain better performance
1702 *
1703 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1704 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1705 *
1706 * @attention If a coefficients absolute value is below the SCIP epsilon tolerance, the variable with its value is not added.
1707 *
1708 * @pre this method can be called in one of the following stages of the SCIP solving process:
1709 * - \ref SCIP_STAGE_INITSOLVE
1710 * - \ref SCIP_STAGE_SOLVING
1711 */
1712 SCIP_RETCODE SCIPaddVarsToRow(
1713 SCIP* scip, /**< SCIP data structure */
1714 SCIP_ROW* row, /**< LP row */
1715 int nvars, /**< number of variables to add to the row */
1716 SCIP_VAR** vars, /**< problem variables to add */
1717 SCIP_Real* vals /**< values of coefficients */
1718 )
1719 {
1720 int v;
1721
1722 assert(nvars == 0 || vars != NULL);
1723 assert(nvars == 0 || vals != NULL);
1724
1725 SCIP_CALL( SCIPcheckStage(scip, "SCIPaddVarsToRow", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1726
1727 /* resize the row to be able to store all variables (at least, if they are COLUMN variables) */
1728 SCIP_CALL( SCIProwEnsureSize(row, scip->mem->probmem, scip->set, SCIProwGetNNonz(row) + nvars) );
1729
1730 /* delay the row sorting */
1731 SCIProwDelaySort(row);
1732
1733 /* add the variables to the row */
1734 for( v = 0; v < nvars; ++v )
1735 {
1736 SCIP_CALL( SCIPvarAddToRow(vars[v], scip->mem->probmem, scip->set, scip->stat, scip->eventqueue, scip->transprob, scip->lp,
1737 row, vals[v]) );
1738 }
1739
1740 /* force the row sorting */
1741 SCIProwForceSort(row, scip->set);
1742
1743 return SCIP_OKAY;
1744 }
1745
1746 /** resolves variables to columns and adds them with the same single coefficient to the row;
1747 * this method caches the row extensions and flushes them afterwards to gain better performance
1748 *
1749 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1750 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1751 *
1752 * @attention If the absolute value of val is below the SCIP epsilon tolerance, the variables will not added.
1753 *
1754 * @pre this method can be called in one of the following stages of the SCIP solving process:
1755 * - \ref SCIP_STAGE_INITSOLVE
1756 * - \ref SCIP_STAGE_SOLVING
1757 */
1758 SCIP_RETCODE SCIPaddVarsToRowSameCoef(
1759 SCIP* scip, /**< SCIP data structure */
1760 SCIP_ROW* row, /**< LP row */
1761 int nvars, /**< number of variables to add to the row */
1762 SCIP_VAR** vars, /**< problem variables to add */
1763 SCIP_Real val /**< unique value of all coefficients */
1764 )
1765 {
1766 int v;
1767
1768 assert(nvars == 0 || vars != NULL);
1769
1770 SCIP_CALL( SCIPcheckStage(scip, "SCIPaddVarsToRowSameCoef", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1771
1772 /* resize the row to be able to store all variables (at least, if they are COLUMN variables) */
1773 SCIP_CALL( SCIProwEnsureSize(row, scip->mem->probmem, scip->set, SCIProwGetNNonz(row) + nvars) );
1774
1775 /* delay the row sorting */
1776 SCIProwDelaySort(row);
1777
1778 /* add the variables to the row */
1779 for( v = 0; v < nvars; ++v )
1780 {
1781 SCIP_CALL( SCIPvarAddToRow(vars[v], scip->mem->probmem, scip->set, scip->stat, scip->eventqueue, scip->transprob, scip->lp,
1782 row, val) );
1783 }
1784
1785 /* force the row sorting */
1786 SCIProwForceSort(row, scip->set);
1787
1788 return SCIP_OKAY;
1789 }
1790
1791 /** tries to find a value, such that all row coefficients, if scaled with this value become integral
1792 *
1793 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1794 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1795 *
1796 * @pre this method can be called in one of the following stages of the SCIP solving process:
1797 * - \ref SCIP_STAGE_INITSOLVE
1798 * - \ref SCIP_STAGE_SOLVING
1799 */
1800 SCIP_RETCODE SCIPcalcRowIntegralScalar(
1801 SCIP* scip, /**< SCIP data structure */
1802 SCIP_ROW* row, /**< LP row */
1803 SCIP_Real mindelta, /**< minimal relative allowed difference of scaled coefficient s*c and integral i */
1804 SCIP_Real maxdelta, /**< maximal relative allowed difference of scaled coefficient s*c and integral i */
1805 SCIP_Longint maxdnom, /**< maximal denominator allowed in rational numbers */
1806 SCIP_Real maxscale, /**< maximal allowed scalar */
1807 SCIP_Bool usecontvars, /**< should the coefficients of the continuous variables also be made integral? */
1808 SCIP_Real* intscalar, /**< pointer to store scalar that would make the coefficients integral, or NULL */
1809 SCIP_Bool* success /**< stores whether returned value is valid */
1810 )
1811 {
1812 SCIP_CALL( SCIPcheckStage(scip, "SCIPcalcRowIntegralScalar", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1813
1814 SCIP_CALL( SCIProwCalcIntegralScalar(row, scip->set, mindelta, maxdelta, maxdnom, maxscale,
1815 usecontvars, intscalar, success) );
1816
1817 return SCIP_OKAY;
1818 }
1819
1820 /** tries to scale row, s.t. all coefficients (of integer variables) become integral
1821 *
1822 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1823 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1824 *
1825 * @pre this method can be called in one of the following stages of the SCIP solving process:
1826 * - \ref SCIP_STAGE_INITSOLVE
1827 * - \ref SCIP_STAGE_SOLVING
1828 */
1829 SCIP_RETCODE SCIPmakeRowIntegral(
1830 SCIP* scip, /**< SCIP data structure */
1831 SCIP_ROW* row, /**< LP row */
1832 SCIP_Real mindelta, /**< minimal relative allowed difference of scaled coefficient s*c and integral i */
1833 SCIP_Real maxdelta, /**< maximal relative allowed difference of scaled coefficient s*c and integral i */
1834 SCIP_Longint maxdnom, /**< maximal denominator allowed in rational numbers */
1835 SCIP_Real maxscale, /**< maximal value to scale row with */
1836 SCIP_Bool usecontvars, /**< should the coefficients of the continuous variables also be made integral? */
1837 SCIP_Bool* success /**< stores whether row could be made rational */
1838 )
1839 {
1840 SCIP_CALL( SCIPcheckStage(scip, "SCIPmakeRowIntegral", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1841
1842 SCIP_CALL( SCIProwMakeIntegral(row, scip->mem->probmem, scip->set, scip->eventqueue, scip->stat, scip->lp, mindelta, maxdelta, maxdnom, maxscale,
1843 usecontvars, success) );
1844
1845 return SCIP_OKAY;
1846 }
1847
1848 /** marks a row to be not removable from the LP in the current node
1849 *
1850 * @pre this method can be called in the following stage of the SCIP solving process:
1851 * - \ref SCIP_STAGE_SOLVING
1852 */
1853 void SCIPmarkRowNotRemovableLocal(
1854 SCIP* scip, /**< SCIP data structure */
1855 SCIP_ROW* row /**< LP row */
1856 )
1857 {
1858 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPmarkRowNotRemovableLocal", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1859
1860 SCIProwMarkNotRemovableLocal(row, scip->stat);
1861 }
1862
1863 /** returns number of integral columns in the row
1864 *
1865 * @return number of integral columns in the row
1866 *
1867 * @pre this method can be called in one of the following stages of the SCIP solving process:
1868 * - \ref SCIP_STAGE_INITSOLVE
1869 * - \ref SCIP_STAGE_SOLVING
1870 */
1871 int SCIPgetRowNumIntCols(
1872 SCIP* scip, /**< SCIP data structure */
1873 SCIP_ROW* row /**< LP row */
1874 )
1875 {
1876 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetRowNumIntCols", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1877
1878 return SCIProwGetNumIntCols(row, scip->set);
1879 }
1880
1881 /** returns minimal absolute value of row vector's non-zero coefficients
1882 *
1883 * @return minimal absolute value of row vector's non-zero coefficients
1884 *
1885 * @pre this method can be called in one of the following stages of the SCIP solving process:
1886 * - \ref SCIP_STAGE_INITSOLVE
1887 * - \ref SCIP_STAGE_SOLVING
1888 */
1889 SCIP_Real SCIPgetRowMinCoef(
1890 SCIP* scip, /**< SCIP data structure */
1891 SCIP_ROW* row /**< LP row */
1892 )
1893 {
1894 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetRowMinCoef", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1895
1896 return SCIProwGetMinval(row, scip->set);
1897 }
1898
1899 /** returns maximal absolute value of row vector's non-zero coefficients
1900 *
1901 * @return maximal absolute value of row vector's non-zero coefficients
1902 *
1903 * @pre this method can be called in one of the following stages of the SCIP solving process:
1904 * - \ref SCIP_STAGE_INITSOLVE
1905 * - \ref SCIP_STAGE_SOLVING
1906 */
1907 SCIP_Real SCIPgetRowMaxCoef(
1908 SCIP* scip, /**< SCIP data structure */
1909 SCIP_ROW* row /**< LP row */
1910 )
1911 {
1912 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetRowMaxCoef", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1913
1914 return SCIProwGetMaxval(row, scip->set);
1915 }
1916
1917 /** returns the minimal activity of a row w.r.t. the column's bounds
1918 *
1919 * @return the minimal activity of a row w.r.t. the column's bounds
1920 *
1921 * @pre this method can be called in one of the following stages of the SCIP solving process:
1922 * - \ref SCIP_STAGE_SOLVING
1923 */
1924 SCIP_Real SCIPgetRowMinActivity(
1925 SCIP* scip, /**< SCIP data structure */
1926 SCIP_ROW* row /**< LP row */
1927 )
1928 {
1929 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetRowMinActivity", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1930
1931 return SCIProwGetMinActivity(row, scip->set, scip->stat);
1932 }
1933
1934 /** returns the maximal activity of a row w.r.t. the column's bounds
1935 *
1936 * @return the maximal activity of a row w.r.t. the column's bounds
1937 *
1938 * @pre this method can be called in one of the following stages of the SCIP solving process:
1939 * - \ref SCIP_STAGE_SOLVING
1940 */
1941 SCIP_Real SCIPgetRowMaxActivity(
1942 SCIP* scip, /**< SCIP data structure */
1943 SCIP_ROW* row /**< LP row */
1944 )
1945 {
1946 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetRowMaxActivity", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1947
1948 return SCIProwGetMaxActivity(row, scip->set, scip->stat);
1949 }
1950
1951 /** recalculates the activity of a row in the last LP solution
1952 *
1953 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1954 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1955 *
1956 * @pre this method can be called in one of the following stages of the SCIP solving process:
1957 * - \ref SCIP_STAGE_SOLVING
1958 */
1959 SCIP_RETCODE SCIPrecalcRowLPActivity(
1960 SCIP* scip, /**< SCIP data structure */
1961 SCIP_ROW* row /**< LP row */
1962 )
1963 {
1964 SCIP_CALL( SCIPcheckStage(scip, "SCIPrecalcRowLPActivity", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1965
1966 SCIProwRecalcLPActivity(row, scip->stat);
1967
1968 return SCIP_OKAY;
1969 }
1970
1971 /** returns the activity of a row in the last LP solution
1972 *
1973 * @return activity of a row in the last LP solution
1974 *
1975 * @pre this method can be called in one of the following stages of the SCIP solving process:
1976 * - \ref SCIP_STAGE_SOLVING
1977 */
1978 SCIP_Real SCIPgetRowLPActivity(
1979 SCIP* scip, /**< SCIP data structure */
1980 SCIP_ROW* row /**< LP row */
1981 )
1982 {
1983 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetRowLPActivity", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1984
1985 return SCIProwGetLPActivity(row, scip->set, scip->stat, scip->lp);
1986 }
1987
1988 /** returns the feasibility of a row in the last LP solution
1989 *
1990 * @return the feasibility of a row in the last LP solution: negative value means infeasibility
1991 *
1992 * @pre this method can be called in one of the following stages of the SCIP solving process:
1993 * - \ref SCIP_STAGE_SOLVING
1994 */
1995 SCIP_Real SCIPgetRowLPFeasibility(
1996 SCIP* scip, /**< SCIP data structure */
1997 SCIP_ROW* row /**< LP row */
1998 )
1999 {
2000 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetRowLPFeasibility", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
2001
2002 return SCIProwGetLPFeasibility(row, scip->set, scip->stat, scip->lp);
2003 }
2004
2005 /** recalculates the activity of a row for the current pseudo solution
2006 *
2007 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2008 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2009 *
2010 * @pre this method can be called in one of the following stages of the SCIP solving process:
2011 * - \ref SCIP_STAGE_SOLVING
2012 */
2013 SCIP_RETCODE SCIPrecalcRowPseudoActivity(
2014 SCIP* scip, /**< SCIP data structure */
2015 SCIP_ROW* row /**< LP row */
2016 )
2017 {
2018 SCIP_CALL( SCIPcheckStage(scip, "SCIPrecalcRowPseudoActivity", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
2019
2020 SCIProwRecalcPseudoActivity(row, scip->stat);
2021
2022 return SCIP_OKAY;
2023 }
2024
2025 /** returns the activity of a row for the current pseudo solution
2026 *
2027 * @return the activity of a row for the current pseudo solution
2028 *
2029 * @pre this method can be called in one of the following stages of the SCIP solving process:
2030 * - \ref SCIP_STAGE_SOLVING
2031 */
2032 SCIP_Real SCIPgetRowPseudoActivity(
2033 SCIP* scip, /**< SCIP data structure */
2034 SCIP_ROW* row /**< LP row */
2035 )
2036 {
2037 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetRowPseudoActivity", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
2038
2039 return SCIProwGetPseudoActivity(row, scip->set, scip->stat);
2040 }
2041
2042 /** returns the feasibility of a row for the current pseudo solution: negative value means infeasibility
2043 *
2044 * @return the feasibility of a row for the current pseudo solution: negative value means infeasibility
2045 *
2046 * @pre this method can be called in one of the following stages of the SCIP solving process:
2047 * - \ref SCIP_STAGE_SOLVING
2048 */
2049 SCIP_Real SCIPgetRowPseudoFeasibility(
2050 SCIP* scip, /**< SCIP data structure */
2051 SCIP_ROW* row /**< LP row */
2052 )
2053 {
2054 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetRowPseudoFeasibility", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
2055
2056 return SCIProwGetPseudoFeasibility(row, scip->set, scip->stat);
2057 }
2058
2059 /** recalculates the activity of a row in the last LP or pseudo solution
2060 *
2061 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2062 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2063 *
2064 * @pre this method can be called in one of the following stages of the SCIP solving process:
2065 * - \ref SCIP_STAGE_SOLVING
2066 */
2067 SCIP_RETCODE SCIPrecalcRowActivity(
2068 SCIP* scip, /**< SCIP data structure */
2069 SCIP_ROW* row /**< LP row */
2070 )
2071 {
2072 SCIP_CALL( SCIPcheckStage(scip, "SCIPrecalcRowActivity", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
2073
2074 if( SCIPtreeHasCurrentNodeLP(scip->tree) )
2075 SCIProwRecalcLPActivity(row, scip->stat);
2076 else
2077 SCIProwRecalcPseudoActivity(row, scip->stat);
2078
2079 return SCIP_OKAY;
2080 }
2081
2082 /** returns the activity of a row in the last LP or pseudo solution
2083 *
2084 * @return the activity of a row in the last LP or pseudo solution
2085 *
2086 * @pre this method can be called in one of the following stages of the SCIP solving process:
2087 * - \ref SCIP_STAGE_SOLVING
2088 */
2089 SCIP_Real SCIPgetRowActivity(
2090 SCIP* scip, /**< SCIP data structure */
2091 SCIP_ROW* row /**< LP row */
2092 )
2093 {
2094 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetRowActivity", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
2095
2096 if( SCIPtreeHasCurrentNodeLP(scip->tree) )
2097 return SCIProwGetLPActivity(row, scip->set, scip->stat, scip->lp);
2098 else
2099 return SCIProwGetPseudoActivity(row, scip->set, scip->stat);
2100 }
2101
2102 /** returns the feasibility of a row in the last LP or pseudo solution
2103 *
2104 * @return the feasibility of a row in the last LP or pseudo solution
2105 *
2106 * @pre this method can be called in one of the following stages of the SCIP solving process:
2107 * - \ref SCIP_STAGE_SOLVING
2108 */
2109 SCIP_Real SCIPgetRowFeasibility(
2110 SCIP* scip, /**< SCIP data structure */
2111 SCIP_ROW* row /**< LP row */
2112 )
2113 {
2114 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetRowFeasibility", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
2115
2116 if( SCIPtreeHasCurrentNodeLP(scip->tree) )
2117 return SCIProwGetLPFeasibility(row, scip->set, scip->stat, scip->lp);
2118 else
2119 return SCIProwGetPseudoFeasibility(row, scip->set, scip->stat);
2120 }
2121
2122 /** returns the activity of a row for the given primal solution
2123 *
2124 * @return the activitiy of a row for the given primal solution
2125 *
2126 * @pre this method can be called in one of the following stages of the SCIP solving process:
2127 * - \ref SCIP_STAGE_SOLVING
2128 */
2129 SCIP_Real SCIPgetRowSolActivity(
2130 SCIP* scip, /**< SCIP data structure */
2131 SCIP_ROW* row, /**< LP row */
2132 SCIP_SOL* sol /**< primal CIP solution */
2133 )
2134 {
2135 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetRowSolActivity", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE) );
2136
2137 if( sol != NULL )
2138 return SCIProwGetSolActivity(row, scip->set, scip->stat, sol);
2139 else if( SCIPtreeHasCurrentNodeLP(scip->tree) )
2140 return SCIProwGetLPActivity(row, scip->set, scip->stat, scip->lp);
2141 else
2142 return SCIProwGetPseudoActivity(row, scip->set, scip->stat);
2143 }
2144
2145 /** returns the feasibility of a row for the given primal solution
2146 *
2147 * @return the feasibility of a row for the given primal solution
2148 *
2149 * @pre this method can be called in one of the following stages of the SCIP solving process:
2150 * - \ref SCIP_STAGE_SOLVING
2151 */
2152 SCIP_Real SCIPgetRowSolFeasibility(
2153 SCIP* scip, /**< SCIP data structure */
2154 SCIP_ROW* row, /**< LP row */
2155 SCIP_SOL* sol /**< primal CIP solution */
2156 )
2157 {
2158 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetRowSolFeasibility", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
2159
2160 if( sol != NULL )
2161 return SCIProwGetSolFeasibility(row, scip->set, scip->stat, sol);
2162 else if( SCIPtreeHasCurrentNodeLP(scip->tree) )
2163 return SCIProwGetLPFeasibility(row, scip->set, scip->stat, scip->lp);
2164 else
2165 return SCIProwGetPseudoFeasibility(row, scip->set, scip->stat);
2166 }
2167
2168 /** returns the parallelism of row with objective function
2169 *
2170 * @return 1 is returned if the row is parallel to the objective function and 0 if it is orthogonal
2171 *
2172 * @pre this method can be called in one of the following stages of the SCIP solving process:
2173 * - \ref SCIP_STAGE_SOLVING
2174 */
2175 SCIP_Real SCIPgetRowObjParallelism(
2176 SCIP* scip, /**< SCIP data structure */
2177 SCIP_ROW* row /**< LP row */
2178 )
2179 {
2180 assert(row != NULL);
2181
2182 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetRowObjParallelism", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
2183
2184 return SCIProwGetObjParallelism(row, scip->set, scip->lp);
2185 }
2186
2187 /** output row to file stream via the message handler system
2188 *
2189 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2190 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2191 *
2192 * @pre this method can be called in one of the following stages of the SCIP solving process:
2193 * - \ref SCIP_STAGE_SOLVING
2194 * - \ref SCIP_STAGE_SOLVED
2195 * - \ref SCIP_STAGE_EXITSOLVE
2196 */
2197 SCIP_RETCODE SCIPprintRow(
2198 SCIP* scip, /**< SCIP data structure */
2199 SCIP_ROW* row, /**< LP row */
2200 FILE* file /**< output file (or NULL for standard output) */
2201 )
2202 {
2203 assert(row != NULL);
2204
2205 SCIP_CALL( SCIPcheckStage(scip, "SCIPprintRow", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE) );
2206
2207 SCIProwPrint(row, scip->messagehdlr, file);
2208
2209 return SCIP_OKAY;
2210 }
2211
2212 /** initiates LP diving, making methods SCIPchgVarObjDive(), SCIPchgVarLbDive(), and SCIPchgVarUbDive() available
2213 *
2214 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2215 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2216 *
2217 * @pre This method can be called if @p scip is in one of the following stages:
2218 * - \ref SCIP_STAGE_SOLVING
2219 *
2220 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
2221 *
2222 * @note diving is allowed even if the current LP is not flushed, not solved, or not solved to optimality; be aware
2223 * that solving the (first) diving LP may take longer than expect and that the latter two cases could stem from
2224 * numerical troubles during the last LP solve; because of this, most users will want to call this method only if
2225 * SCIPgetLPSolstat(scip) == SCIP_LPSOLSTAT_OPTIMAL
2226 */
2227 SCIP_RETCODE SCIPstartDive(
2228 SCIP* scip /**< SCIP data structure */
2229 )
2230 {
2231 assert(scip != NULL);
2232
2233 SCIP_CALL( SCIPcheckStage(scip, "SCIPstartDive", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
2234 assert(SCIPnodeGetType(SCIPgetCurrentNode(scip)) == SCIP_NODETYPE_FOCUSNODE);
2235
2236 if( SCIPlpDiving(scip->lp) )
2237 {
2238 SCIPerrorMessage("already in diving mode\n");
2239 return SCIP_INVALIDCALL;
2240 }
2241
2242 if( SCIPtreeProbing(scip->tree) )
2243 {
2244 SCIPerrorMessage("cannot start diving while being in probing mode\n");
2245 return SCIP_INVALIDCALL;
2246 }
2247
2248 if( !SCIPtreeIsFocusNodeLPConstructed(scip->tree) )
2249 {
2250 SCIPerrorMessage("cannot start diving if LP has not been constructed\n");
2251 return SCIP_INVALIDCALL;
2252 }
2253 assert(SCIPtreeHasCurrentNodeLP(scip->tree));
2254
2255 SCIP_CALL( SCIPlpStartDive(scip->lp, scip->mem->probmem, scip->set, scip->stat) );
2256
2257 /* remember the relaxation solution to reset it later */
2258 if( SCIPisRelaxSolValid(scip) )
2259 {
2260 SCIP_CALL( SCIPtreeStoreRelaxSol(scip->tree, scip->set, scip->relaxation, scip->transprob) );
2261 }
2262
2263 return SCIP_OKAY;
2264 }
2265
2266 /** quits LP diving and resets bounds and objective values of columns to the current node's values
2267 *
2268 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2269 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2270 *
2271 * @pre This method can be called if @p scip is in one of the following stages:
2272 * - \ref SCIP_STAGE_SOLVING
2273 *
2274 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
2275 */
2276 SCIP_RETCODE SCIPendDive(
2277 SCIP* scip /**< SCIP data structure */
2278 )
2279 {
2280 assert(scip != NULL);
2281
2282 SCIP_CALL( SCIPcheckStage(scip, "SCIPendDive", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
2283
2284 if( !SCIPlpDiving(scip->lp) )
2285 {
2286 SCIPerrorMessage("not in diving mode\n");
2287 return SCIP_INVALIDCALL;
2288 }
2289
2290 /* unmark the diving flag in the LP and reset all variables' objective and bound values */
2291 SCIP_CALL( SCIPlpEndDive(scip->lp, scip->mem->probmem, scip->set, scip->messagehdlr, scip->stat, scip->eventqueue, scip->eventfilter,
2292 scip->transprob, scip->transprob->vars, scip->transprob->nvars) );
2293
2294 /* the lower bound may have changed slightly due to LP resolve in SCIPlpEndDive() */
2295 if( !scip->lp->resolvelperror && scip->tree->focusnode != NULL && SCIPlpIsRelax(scip->lp) && SCIPlpIsSolved(scip->lp) )
2296 {
2297 assert(SCIPtreeIsFocusNodeLPConstructed(scip->tree));
2298 SCIP_CALL( SCIPnodeUpdateLowerboundLP(scip->tree->focusnode, scip->set, scip->stat, scip->tree, scip->transprob,
2299 scip->origprob, scip->lp) );
2300 }
2301 /* reset the probably changed LP's cutoff bound */
2302 SCIP_CALL( SCIPlpSetCutoffbound(scip->lp, scip->set, scip->transprob, scip->primal->cutoffbound) );
2303 assert(scip->lp->cutoffbound == scip->primal->cutoffbound); /*lint !e777*/
2304
2305 /* if a new best solution was created, the cutoff of the tree was delayed due to diving;
2306 * the cutoff has to be done now.
2307 */
2308 if( scip->tree->cutoffdelayed )
2309 {
2310 SCIP_CALL( SCIPtreeCutoff(scip->tree, scip->reopt, scip->mem->probmem, scip->set, scip->stat, scip->eventfilter,
2311 scip->eventqueue, scip->lp, scip->primal->cutoffbound) );
2312 }
2313
2314 /* if a relaxation was stored before diving, restore it now */
2315 if( scip->tree->probdiverelaxstored )
2316 {
2317 SCIP_CALL( SCIPtreeRestoreRelaxSol(scip->tree, scip->set, scip->relaxation, scip->transprob) );
2318 }
2319
2320 return SCIP_OKAY;
2321 }
2322
2323 /** changes cutoffbound in current dive
2324 *
2325 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2326 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2327 *
2328 * @pre This method can be called if @p scip is in one of the following stages:
2329 * - \ref SCIP_STAGE_SOLVING
2330 *
2331 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
2332 */
2333 SCIP_RETCODE SCIPchgCutoffboundDive(
2334 SCIP* scip, /**< SCIP data structure */
2335 SCIP_Real newcutoffbound /**< new cutoffbound */
2336 )
2337 {
2338 assert(scip != NULL);
2339
2340 SCIP_CALL( SCIPcheckStage(scip, "SCIPchgCutoffboundDive", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
2341
2342 if( !SCIPlpDiving(scip->lp) )
2343 {
2344 SCIPerrorMessage("not in diving mode\n");
2345 return SCIP_INVALIDCALL;
2346 }
2347
2348 SCIP_CALL( SCIPlpSetCutoffbound(scip->lp, scip->set, scip->transprob, newcutoffbound) );
2349
2350 return SCIP_OKAY;
2351 }
2352
2353 /** changes variable's objective value in current dive
2354 *
2355 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2356 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2357 *
2358 * @pre This method can be called if @p scip is in one of the following stages:
2359 * - \ref SCIP_STAGE_SOLVING
2360 *
2361 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
2362 */
2363 SCIP_RETCODE SCIPchgVarObjDive(
2364 SCIP* scip, /**< SCIP data structure */
2365 SCIP_VAR* var, /**< variable to change the objective value for */
2366 SCIP_Real newobj /**< new objective value */
2367 )
2368 {
2369 assert(scip != NULL);
2370 assert(var != NULL);
2371
2372 SCIP_CALL( SCIPcheckStage(scip, "SCIPchgVarObjDive", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
2373
2374 if( !SCIPlpDiving(scip->lp) )
2375 {
2376 SCIPerrorMessage("not in diving mode\n");
2377 return SCIP_INVALIDCALL;
2378 }
2379
2380 /* invalidate the LP's cutoff bound, since this has nothing to do with the current objective value anymore;
2381 * the cutoff bound is reset in SCIPendDive()
2382 */
2383 SCIP_CALL( SCIPlpSetCutoffbound(scip->lp, scip->set, scip->transprob, SCIPsetInfinity(scip->set)) );
2384
2385 /* mark the LP's objective function invalid */
2386 SCIPlpMarkDivingObjChanged(scip->lp);
2387
2388 /* change the objective value of the variable in the diving LP */
2389 SCIP_CALL( SCIPvarChgObjDive(var, scip->set, scip->lp, newobj) );
2390
2391 return SCIP_OKAY;
2392 }
2393
2394 /** changes variable's lower bound in current dive
2395 *
2396 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2397 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2398 *
2399 * @pre This method can be called if @p scip is in one of the following stages:
2400 * - \ref SCIP_STAGE_SOLVING
2401 *
2402 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
2403 */
2404 SCIP_RETCODE SCIPchgVarLbDive(
2405 SCIP* scip, /**< SCIP data structure */
2406 SCIP_VAR* var, /**< variable to change the bound for */
2407 SCIP_Real newbound /**< new value for bound */
2408 )
2409 {
2410 assert(scip != NULL);
2411 assert(var != NULL);
2412
2413 SCIP_CALL( SCIPcheckStage(scip, "SCIPchgVarLbDive", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
2414
2415 if( !SCIPlpDiving(scip->lp) )
2416 {
2417 SCIPerrorMessage("not in diving mode\n");
2418 return SCIP_INVALIDCALL;
2419 }
2420
2421 SCIP_CALL( SCIPvarChgLbDive(var, scip->set, scip->lp, newbound) );
2422
2423 return SCIP_OKAY;
2424 }
2425
2426 /** changes variable's upper bound in current dive
2427 *
2428 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2429 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2430 *
2431 * @pre This method can be called if @p scip is in one of the following stages:
2432 * - \ref SCIP_STAGE_SOLVING
2433 *
2434 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
2435 */
2436 SCIP_RETCODE SCIPchgVarUbDive(
2437 SCIP* scip, /**< SCIP data structure */
2438 SCIP_VAR* var, /**< variable to change the bound for */
2439 SCIP_Real newbound /**< new value for bound */
2440 )
2441 {
2442 assert(scip != NULL);
2443 assert(var != NULL);
2444
2445 SCIP_CALL( SCIPcheckStage(scip, "SCIPchgVarUbDive", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
2446
2447 if( !SCIPlpDiving(scip->lp) )
2448 {
2449 SCIPerrorMessage("not in diving mode\n");
2450 return SCIP_INVALIDCALL;
2451 }
2452
2453 SCIP_CALL( SCIPvarChgUbDive(var, scip->set, scip->lp, newbound) );
2454
2455 return SCIP_OKAY;
2456 }
2457
2458 /** adds a row to the LP in current dive
2459 *
2460 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2461 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2462 *
2463 * @pre This method can be called if @p scip is in one of the following stages:
2464 * - \ref SCIP_STAGE_SOLVING
2465 *
2466 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
2467 */
2468 SCIP_RETCODE SCIPaddRowDive(
2469 SCIP* scip, /**< SCIP data structure */
2470 SCIP_ROW* row /**< row to be added */
2471 )
2472 {
2473 SCIP_NODE* node;
2474 int depth;
2475
2476 assert(scip != NULL);
2477 assert(row != NULL);
2478
2479 SCIP_CALL( SCIPcheckStage(scip, "SCIPaddRowDive", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
2480
2481 if( !SCIPlpDiving(scip->lp) )
2482 {
2483 SCIPerrorMessage("not in diving mode\n");
2484 return SCIP_INVALIDCALL;
2485 }
2486
2487 /* get depth of current node */
2488 node = SCIPtreeGetCurrentNode(scip->tree);
2489 assert(node != NULL);
2490 depth = SCIPnodeGetDepth(node);
2491
2492 SCIP_CALL( SCIPlpAddRow(scip->lp, scip->mem->probmem, scip->set, scip->eventqueue, scip->eventfilter, row, depth) );
2493
2494 return SCIP_OKAY;
2495 }
2496
2497 /** changes row lhs in current dive, change will be undone after diving ends, for permanent changes use SCIPchgRowLhs()
2498 *
2499 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2500 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2501 *
2502 * @pre This method can be called if @p scip is in one of the following stages:
2503 * - \ref SCIP_STAGE_SOLVING
2504 *
2505 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
2506 */
2507 SCIP_RETCODE SCIPchgRowLhsDive(
2508 SCIP* scip, /**< SCIP data structure */
2509 SCIP_ROW* row, /**< row to change the lhs for */
2510 SCIP_Real newlhs /**< new value for lhs */
2511 )
2512 {
2513 assert(scip != NULL);
2514 assert(row != NULL);
2515
2516 SCIP_CALL( SCIPcheckStage(scip, "SCIPchgRowLhsDive", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
2517
2518 if( !SCIPlpDiving(scip->lp) )
2519 {
2520 SCIPerrorMessage("not in diving mode\n");
2521 return SCIP_INVALIDCALL;
2522 }
2523
2524 SCIP_CALL( SCIPlpRecordOldRowSideDive(scip->lp, row, SCIP_SIDETYPE_LEFT) );
2525 SCIP_CALL( SCIProwChgLhs(row, scip->mem->probmem, scip->set, scip->eventqueue, scip->lp, newlhs) );
2526
2527 return SCIP_OKAY;
2528 }
2529
2530 /** changes row rhs in current dive, change will be undone after diving ends, for permanent changes use SCIPchgRowRhs()
2531 *
2532 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2533 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2534 *
2535 * @pre This method can be called if @p scip is in one of the following stages:
2536 * - \ref SCIP_STAGE_SOLVING
2537 *
2538 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
2539 */
2540 SCIP_RETCODE SCIPchgRowRhsDive(
2541 SCIP* scip, /**< SCIP data structure */
2542 SCIP_ROW* row, /**< row to change the lhs for */
2543 SCIP_Real newrhs /**< new value for rhs */
2544 )
2545 {
2546 assert(scip != NULL);
2547 assert(row != NULL);
2548
2549 SCIP_CALL( SCIPcheckStage(scip, "SCIPchgRowRhsDive", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
2550
2551 if( !SCIPlpDiving(scip->lp) )
2552 {
2553 SCIPerrorMessage("not in diving mode\n");
2554 return SCIP_INVALIDCALL;
2555 }
2556
2557 SCIP_CALL( SCIPlpRecordOldRowSideDive(scip->lp, row, SCIP_SIDETYPE_RIGHT) );
2558 SCIP_CALL( SCIProwChgRhs(row, scip->mem->probmem, scip->set, scip->eventqueue, scip->lp, newrhs) );
2559
2560 return SCIP_OKAY;
2561 }
2562
2563 /** gets variable's objective value in current dive
2564 *
2565 * @return the variable's objective value in current dive.
2566 *
2567 * @pre This method can be called if @p scip is in one of the following stages:
2568 * - \ref SCIP_STAGE_SOLVING
2569 *
2570 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
2571 */
2572 SCIP_Real SCIPgetVarObjDive(
2573 SCIP* scip, /**< SCIP data structure */
2574 SCIP_VAR* var /**< variable to get the bound for */
2575 )
2576 {
2577 assert(scip != NULL);
2578 assert(var != NULL);
2579
2580 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetVarObjDive", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
2581
2582 if( !SCIPlpDiving(scip->lp) )
2583 {
2584 SCIPerrorMessage("not in diving mode\n");
2585 SCIPABORT();
2586 return SCIP_INVALID; /*lint !e527*/
2587 }
2588
2589 return SCIPvarGetObjLP(var);
2590 }
2591
2592 /** gets variable's lower bound in current dive
2593 *
2594 * @return the variable's lower bound in current dive.
2595 *
2596 * @pre This method can be called if @p scip is in one of the following stages:
2597 * - \ref SCIP_STAGE_SOLVING
2598 *
2599 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
2600 */
2601 SCIP_Real SCIPgetVarLbDive(
2602 SCIP* scip, /**< SCIP data structure */
2603 SCIP_VAR* var /**< variable to get the bound for */
2604 )
2605 {
2606 assert(scip != NULL);
2607 assert(var != NULL);
2608
2609 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetVarLbDive", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
2610
2611 if( !SCIPlpDiving(scip->lp) )
2612 {
2613 SCIPerrorMessage("not in diving mode\n");
2614 SCIPABORT();
2615 return SCIP_INVALID; /*lint !e527*/
2616 }
2617
2618 return SCIPvarGetLbLP(var, scip->set);
2619 }
2620
2621 /** gets variable's upper bound in current dive
2622 *
2623 * @return the variable's upper bound in current dive.
2624 *
2625 * @pre This method can be called if @p scip is in one of the following stages:
2626 * - \ref SCIP_STAGE_SOLVING
2627 *
2628 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
2629 */
2630 SCIP_Real SCIPgetVarUbDive(
2631 SCIP* scip, /**< SCIP data structure */
2632 SCIP_VAR* var /**< variable to get the bound for */
2633 )
2634 {
2635 assert(scip != NULL);
2636 assert(var != NULL);
2637
2638 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetVarUbDive", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
2639
2640 if( !SCIPlpDiving(scip->lp) )
2641 {
2642 SCIPerrorMessage("not in diving mode\n");
2643 SCIPABORT();
2644 return SCIP_INVALID; /*lint !e527*/
2645 }
2646
2647 return SCIPvarGetUbLP(var, scip->set);
2648 }
2649
2650 /** solves the LP of the current dive; no separation or pricing is applied
2651 *
2652 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2653 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2654 *
2655 * @pre This method can be called if @p scip is in one of the following stages:
2656 * - \ref SCIP_STAGE_SOLVING
2657 *
2658 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
2659 *
2660 * @note be aware that the LP solve may take longer than expected if SCIPgetLPSolstat(scip) != SCIP_LPSOLSTAT_OPTIMAL,
2661 * compare the explanation of SCIPstartDive()
2662 */
2663 SCIP_RETCODE SCIPsolveDiveLP(
2664 SCIP* scip, /**< SCIP data structure */
2665 int itlim, /**< maximal number of LP iterations to perform, or -1 for no limit */
2666 SCIP_Bool* lperror, /**< pointer to store whether an unresolved LP error occurred */
2667 SCIP_Bool* cutoff /**< pointer to store whether the diving LP was infeasible or the objective
2668 * limit was reached (or NULL, if not needed) */
2669 )
2670 {
2671 assert(scip != NULL);
2672
2673 SCIP_CALL( SCIPcheckStage(scip, "SCIPsolveDiveLP", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
2674
2675 if( !SCIPlpDiving(scip->lp) )
2676 {
2677 SCIPerrorMessage("not in diving mode\n");
2678 return SCIP_INVALIDCALL;
2679 }
2680
2681 if( cutoff != NULL )
2682 *cutoff = FALSE;
2683
2684 /* solve diving LP */
2685 SCIP_CALL( SCIPlpSolveAndEval(scip->lp, scip->set, scip->messagehdlr, scip->mem->probmem, scip->stat,
2686 scip->eventqueue, scip->eventfilter, scip->transprob, (SCIP_Longint)itlim, FALSE, FALSE, FALSE, lperror) );
2687
2688 /* the LP is infeasible or the objective limit was reached */
2689 if( SCIPlpGetSolstat(scip->lp) == SCIP_LPSOLSTAT_INFEASIBLE || SCIPlpGetSolstat(scip->lp) == SCIP_LPSOLSTAT_OBJLIMIT
2690 || (SCIPlpGetSolstat(scip->lp) == SCIP_LPSOLSTAT_OPTIMAL &&
2691 SCIPisGE(scip, SCIPgetLPObjval(scip), SCIPgetCutoffbound(scip))) )
2692 {
2693 /* analyze the infeasible LP (only if the objective was not changed, all columns are in the LP, and no external
2694 * pricers exist) */
2695 if( !scip->set->misc_exactsolve && !(SCIPlpDivingObjChanged(scip->lp) || SCIPlpDivingRowsChanged(scip->lp))
2696 && SCIPprobAllColsInLP(scip->transprob, scip->set, scip->lp) )
2697 {
2698 SCIP_CALL( SCIPconflictAnalyzeLP(scip->conflict, scip->conflictstore, scip->mem->probmem, scip->set, scip->stat, scip->transprob,
2699 scip->origprob, scip->tree, scip->reopt, scip->lp, scip->branchcand, scip->eventqueue, scip->cliquetable, NULL) );
2700 }
2701
2702 if( cutoff != NULL )
2703 *cutoff = TRUE;
2704 }
2705
2706 return SCIP_OKAY;
2707 }
2708
2709 /** returns the number of the node in the current branch and bound run, where the last LP was solved in diving
2710 * or probing mode
2711 *
2712 * @return the number of the node in the current branch and bound run, where the last LP was solved in diving
2713 * or probing mode.
2714 *
2715 * @pre This method can be called if @p scip is in one of the following stages:
2716 * - \ref SCIP_STAGE_TRANSFORMING
2717 * - \ref SCIP_STAGE_TRANSFORMED
2718 * - \ref SCIP_STAGE_INITPRESOLVE
2719 * - \ref SCIP_STAGE_PRESOLVING
2720 * - \ref SCIP_STAGE_EXITPRESOLVE
2721 * - \ref SCIP_STAGE_PRESOLVED
2722 * - \ref SCIP_STAGE_INITSOLVE
2723 * - \ref SCIP_STAGE_SOLVING
2724 * - \ref SCIP_STAGE_SOLVED
2725 * - \ref SCIP_STAGE_EXITSOLVE
2726 * - \ref SCIP_STAGE_FREETRANS
2727 *
2728 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
2729 */
2730 SCIP_Longint SCIPgetLastDivenode(
2731 SCIP* scip /**< SCIP data structure */
2732 )
2733 {
2734 assert(scip != NULL);
2735
2736 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetLastDivenode", FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
2737
2738 return scip->stat->lastdivenode;
2739 }
2740
2741 /** returns whether we are in diving mode
2742 *
2743 * @return whether we are in diving mode.
2744 *
2745 * @pre This method can be called if @p scip is in one of the following stages:
2746 * - \ref SCIP_STAGE_TRANSFORMING
2747 * - \ref SCIP_STAGE_TRANSFORMED
2748 * - \ref SCIP_STAGE_INITPRESOLVE
2749 * - \ref SCIP_STAGE_PRESOLVING
2750 * - \ref SCIP_STAGE_EXITPRESOLVE
2751 * - \ref SCIP_STAGE_PRESOLVED
2752 * - \ref SCIP_STAGE_INITSOLVE
2753 * - \ref SCIP_STAGE_SOLVING
2754 * - \ref SCIP_STAGE_SOLVED
2755 * - \ref SCIP_STAGE_EXITSOLVE
2756 * - \ref SCIP_STAGE_FREETRANS
2757 *
2758 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
2759 */
2760 SCIP_Bool SCIPinDive(
2761 SCIP* scip /**< SCIP data structure */
2762 )
2763 {
2764 assert(scip != NULL);
2765
2766 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPinDive", FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
2767
2768 return SCIPlpDiving(scip->lp);
2769 }
2770
2771 /** computes two measures for dual degeneracy (dual degeneracy rate and variable-constraint ratio)
2772 * based on the changes applied when reducing the problem to the optimal face
2773 *
2774 * returns the dual degeneracy rate, i.e., the share of nonbasic variables with reduced cost 0
2775 * and the variable-constraint ratio, i.e., the number of unfixed variables in relation to the basis size
2776 */
2777 SCIP_RETCODE SCIPgetLPDualDegeneracy(
2778 SCIP* scip, /**< SCIP data structure */
2779 SCIP_Real* degeneracy, /**< pointer to store the dual degeneracy rate */
2780 SCIP_Real* varconsratio /**< pointer to store the variable-constraint ratio */
2781 )
2782 {
2783 assert(scip != NULL);
2784 assert(degeneracy != NULL);
2785 assert(varconsratio != NULL);
2786
2787 SCIP_CALL( SCIPcheckStage(scip, "SCIPgetLPDualDegeneracy", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
2788
2789 SCIP_CALL( SCIPlpGetDualDegeneracy(scip->lp, scip->set, scip->stat, degeneracy, varconsratio) );
2790
2791 return SCIP_OKAY;
2792 }
2793