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