Scippy

SCIP

Solving Constraint Integer Programs

scip_sol.c
Go to the documentation of this file.
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2/* */
3/* This file is part of the program and library */
4/* SCIP --- Solving Constraint Integer Programs */
5/* */
6/* Copyright (c) 2002-2025 Zuse Institute Berlin (ZIB) */
7/* */
8/* Licensed under the Apache License, Version 2.0 (the "License"); */
9/* you may not use this file except in compliance with the License. */
10/* You may obtain a copy of the License at */
11/* */
12/* http://www.apache.org/licenses/LICENSE-2.0 */
13/* */
14/* Unless required by applicable law or agreed to in writing, software */
15/* distributed under the License is distributed on an "AS IS" BASIS, */
16/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
17/* See the License for the specific language governing permissions and */
18/* limitations under the License. */
19/* */
20/* You should have received a copy of the Apache-2.0 license */
21/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */
22/* */
23/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24
25/**@file scip_sol.c
26 * @ingroup OTHER_CFILES
27 * @brief public methods for solutions
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 <string.h>
46
48#include "scip/cons.h"
49#include "scip/cons_linear.h"
50#include "scip/debug.h"
51#include "scip/lp.h"
52#include "scip/lpexact.h"
53#include "scip/nlp.h"
54#include "scip/primal.h"
55#include "scip/prob.h"
56#include "scip/pub_cons.h"
57#include "scip/pub_fileio.h"
58#include "scip/pub_message.h"
59#include "scip/pub_misc.h"
60#include "scip/pub_sol.h"
61#include "scip/pub_var.h"
62#include "scip/relax.h"
63#include "scip/scip_cons.h"
64#include "scip/scip_copy.h"
65#include "scip/scip_exact.h"
66#include "scip/scip_general.h"
67#include "scip/scip_lpexact.h"
68#include "scip/scip_mem.h"
69#include "scip/scip_message.h"
70#include "scip/scip_nlp.h"
71#include "scip/scip_numerics.h"
72#include "scip/scip_param.h"
73#include "scip/scip_prob.h"
74#include "scip/scip_sol.h"
75#include "scip/scip_solve.h"
77#include "scip/scip_var.h"
78#include "scip/set.h"
79#include "scip/sol.h"
80#include "scip/struct_lp.h"
81#include "scip/struct_mem.h"
82#include "scip/struct_primal.h"
83#include "scip/struct_prob.h"
84#include "scip/struct_scip.h"
85#include "scip/struct_set.h"
86#include "scip/struct_sol.h"
87#include "scip/struct_stat.h"
88#include "scip/struct_var.h"
89#include "scip/tree.h"
90#include "xml/xml.h"
91
92/** checks solution for feasibility in original problem without adding it to the solution store; to improve the
93 * performance we use the following order when checking for violations:
94 *
95 * 1. variable bounds
96 * 2. constraint handlers with positive or zero priority that don't need constraints (e.g. integral constraint handler)
97 * 3. original constraints
98 * 4. constraint handlers with negative priority that don't need constraints (e.g. Benders' decomposition constraint handler)
99 */
100static
102 SCIP* scip, /**< SCIP data structure */
103 SCIP_SOL* sol, /**< primal CIP solution */
104 SCIP_Bool* feasible, /**< stores whether given solution is feasible */
105 SCIP_Bool printreason, /**< Should the reason for the violation be printed? */
106 SCIP_Bool completely, /**< Should all violations be checked if printreason is true? */
107 SCIP_Bool checkbounds, /**< Should the bounds of the variables be checked? */
108 SCIP_Bool checkintegrality, /**< Has integrality to be checked? */
109 SCIP_Bool checklprows, /**< Do constraints represented by rows in the current LP have to be checked? */
110 SCIP_Bool checkmodifiable /**< have modifiable constraint to be checked? */
111 )
112{
113 SCIP_RESULT result;
114 int v;
115 int c;
116 int h;
117
118 assert(scip != NULL);
119 assert(sol != NULL);
120 assert(sol->scip == scip);
121 assert(feasible != NULL);
122
124
125 *feasible = TRUE;
126
128
129 if( !printreason )
130 completely = FALSE;
131
132 if( SCIPisExact(scip) )
133 {
135 SCIP_CALL( SCIPsolMakeExact(sol, SCIPblkmem(scip), scip->set, scip->stat, scip->origprob) );
136 else
137 SCIP_CALL( SCIPsolMakeExact(sol, SCIPblkmem(scip), scip->set, scip->stat, scip->transprob) );
138 }
139
140 /* check bounds */
141 if( checkbounds )
142 {
143 for( v = 0; v < scip->origprob->nvars; ++v )
144 {
145 SCIP_VAR* var;
146 SCIP_Real solval;
147 SCIP_Real lb;
148 SCIP_Real ub;
149
150 var = scip->origprob->vars[v];
151 solval = SCIPsolGetVal(sol, scip->set, scip->stat, var);
152
153 lb = SCIPvarGetLbOriginal(var);
154 ub = SCIPvarGetUbOriginal(var);
155
156 SCIPupdateSolBoundViolation(scip, sol, lb - solval, SCIPrelDiff(lb, solval));
157 SCIPupdateSolBoundViolation(scip, sol, solval - ub, SCIPrelDiff(solval, ub));
158
159 if( SCIPsetIsFeasLT(scip->set, solval, lb) || SCIPsetIsFeasGT(scip->set, solval, ub) )
160 {
161 *feasible = FALSE;
162
163 if( printreason )
164 {
165 SCIPmessagePrintInfo(scip->messagehdlr, "solution violates original bounds of variable <%s> [%g,%g] solution value <%g>\n",
166 SCIPvarGetName(var), lb, ub, solval);
167 }
168
169 if( !completely )
170 return SCIP_OKAY;
171 }
172 }
173 }
174
175 /* call constraint handlers with positive or zero check priority that don't need constraints */
176 for( h = 0; h < scip->set->nconshdlrs; ++h )
177 {
178 if( SCIPconshdlrGetCheckPriority(scip->set->conshdlrs[h]) >= 0 )
179 {
180 if( !SCIPconshdlrNeedsCons(scip->set->conshdlrs[h]) )
181 {
182 SCIP_CALL( SCIPconshdlrCheck(scip->set->conshdlrs[h], scip->mem->probmem, scip->set, scip->stat, sol,
183 checkintegrality, checklprows, printreason, completely, &result) );
184
185 if( result != SCIP_FEASIBLE )
186 {
187 *feasible = FALSE;
188
189 if( !completely )
190 return SCIP_OKAY;
191 }
192 }
193 }
194 /* constraint handlers are sorted by priority, so we can break when reaching the first one with negative priority */
195 else
196 break;
197 }
198
199 /* check original constraints
200 *
201 * in general modifiable constraints can not be checked, because the variables to fulfill them might be missing in
202 * the original problem; however, if the solution comes from a heuristic during presolving modifiable constraints
203 * have to be checked;
204 */
205 for( c = 0; c < scip->origprob->nconss; ++c )
206 {
207 if( SCIPconsIsChecked(scip->origprob->conss[c]) && (checkmodifiable || !SCIPconsIsModifiable(scip->origprob->conss[c])) )
208 {
209 /* check solution */
210 SCIP_CALL( SCIPconsCheck(scip->origprob->conss[c], scip->set, sol,
211 checkintegrality, checklprows, printreason, &result) );
212
213 if( result != SCIP_FEASIBLE )
214 {
215 *feasible = FALSE;
216
217 if( !completely )
218 return SCIP_OKAY;
219 }
220 }
221 }
222
223 /* call constraint handlers with negative check priority that don't need constraints;
224 * continue with the first constraint handler with negative priority which caused us to break in the above loop */
225 for( ; h < scip->set->nconshdlrs; ++h )
226 {
227 assert(SCIPconshdlrGetCheckPriority(scip->set->conshdlrs[h]) < 0);
228 if( !SCIPconshdlrNeedsCons(scip->set->conshdlrs[h]) )
229 {
230 SCIP_CALL( SCIPconshdlrCheck(scip->set->conshdlrs[h], scip->mem->probmem, scip->set, scip->stat, sol,
231 checkintegrality, checklprows, printreason, completely, &result) );
232
233 if( result != SCIP_FEASIBLE )
234 {
235 *feasible = FALSE;
236
237 if( !completely )
238 return SCIP_OKAY;
239 }
240 }
241 }
242
243 return SCIP_OKAY;
244}
245
246/** checks solution (fp or exact) for exact feasibility in original problem without adding it to the solution store;
247 * to improve the performance we use the following order when checking for violations:
248 *
249 * 1. variable bounds
250 * 2. constraint handlers with positive or zero priority that don't need constraints (e.g. integral constraint handler)
251 * 3. original constraints
252 * 4. constraint handlers with negative priority that don't need constraints (e.g. Benders' decomposition constraint handler)
253 */
254static
256 SCIP* scip, /**< SCIP data structure */
257 SCIP_SOL* sol, /**< primal CIP solution */
258 SCIP_Bool* feasible, /**< stores whether given solution is feasible */
259 SCIP_Bool printreason, /**< Should the reason for the violation be printed? */
260 SCIP_Bool completely, /**< Should all violations be checked if printreason is true? */
261 SCIP_Bool checkbounds, /**< Should the bounds of the variables be checked? */
262 SCIP_Bool checkintegrality, /**< Has integrality to be checked? */
263 SCIP_Bool checklprows, /**< Do constraints represented by rows in the current LP have to be checked? */
264 SCIP_Bool checkmodifiable /**< have modifiable constraint to be checked? */
265 )
266{
267 SCIP_RATIONAL* solval;
268 SCIP_RATIONAL* lb;
269 SCIP_RATIONAL* ub;
270 SCIP_RESULT result;
271 int v;
272 int c;
273 int h;
274
275 assert(scip != NULL);
276 assert(sol != NULL);
277 assert(sol->scip == scip);
278 assert(feasible != NULL);
279 assert(SCIPisExact(scip));
280
281 SCIP_CALL( SCIPcheckStage(scip, "checkSolOrigExact", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
282
283 *feasible = TRUE;
284
286
288 SCIP_CALL( SCIPsolMakeExact(sol, SCIPblkmem(scip), scip->set, scip->stat, scip->origprob) );
289 else
290 SCIP_CALL( SCIPsolMakeExact(sol, SCIPblkmem(scip), scip->set, scip->stat, scip->transprob) );
291
292 if( !printreason )
293 completely = FALSE;
294
296
297 /* check bounds */
298 if( checkbounds )
299 {
300 for( v = 0; v < scip->origprob->nvars; ++v )
301 {
302 SCIP_VAR* var;
303
304 var = scip->origprob->vars[v];
305 if( SCIPsolIsExact(sol) )
306 SCIPsolGetValExact(solval, sol, scip->set, scip->stat, var);
307 else
308 SCIPrationalSetReal(solval, SCIPsolGetVal(sol, scip->set, scip->stat, var));
309
312
313 if( SCIPrationalIsLT(solval, lb) || SCIPrationalIsGT(solval, ub) )
314 {
315 *feasible = FALSE;
316
317 if( printreason )
318 {
319 SCIPmessagePrintInfo(scip->messagehdlr, "solution violates original bounds of variable <%s> [%g,%g] solution value <%g>\n",
321 }
322
323 if( !completely )
324 {
326 return SCIP_OKAY;
327 }
328 }
329 }
330 }
331
333
334 /* call constraint handlers with positive or zero check priority that don't need constraints */
335 for( h = 0; h < scip->set->nconshdlrs; ++h )
336 {
337 if( SCIPconshdlrGetCheckPriority(scip->set->conshdlrs[h]) >= 0 )
338 {
339 if( !SCIPconshdlrNeedsCons(scip->set->conshdlrs[h]) )
340 {
341 SCIP_CALL( SCIPconshdlrCheck(scip->set->conshdlrs[h], scip->mem->probmem, scip->set, scip->stat, sol,
342 checkintegrality, checklprows, printreason, completely, &result) );
343
344 if( result != SCIP_FEASIBLE )
345 {
346 *feasible = FALSE;
347
348 if( !completely )
349 return SCIP_OKAY;
350 }
351 }
352 }
353 /* constraint handlers are sorted by priority, so we can break when reaching the first one with negative priority */
354 else
355 break;
356 }
357
358 /* check original constraints
359 *
360 * in general modifiable constraints can not be checked, because the variables to fulfill them might be missing in
361 * the original problem; however, if the solution comes from a heuristic during presolving modifiable constraints
362 * have to be checked;
363 */
364 for( c = 0; c < scip->origprob->nconss; ++c )
365 {
366 if( SCIPconsIsChecked(scip->origprob->conss[c]) && (checkmodifiable || !SCIPconsIsModifiable(scip->origprob->conss[c])) )
367 {
368 /* check solution */
369 SCIP_CALL( SCIPconsCheck(scip->origprob->conss[c], scip->set, sol,
370 checkintegrality, checklprows, printreason, &result) );
371
372 if( result != SCIP_FEASIBLE )
373 {
374 *feasible = FALSE;
375
376 if( !completely )
377 return SCIP_OKAY;
378 }
379 }
380 }
381
382 /* call constraint handlers with negative check priority that don't need constraints;
383 * continue with the first constraint handler with negative priority which caused us to break in the above loop */
384 for( ; h < scip->set->nconshdlrs; ++h )
385 {
386 assert(SCIPconshdlrGetCheckPriority(scip->set->conshdlrs[h]) < 0);
387 if( !SCIPconshdlrNeedsCons(scip->set->conshdlrs[h]) )
388 {
389 SCIP_CALL( SCIPconshdlrCheck(scip->set->conshdlrs[h], scip->mem->probmem, scip->set, scip->stat, sol,
390 checkintegrality, checklprows, printreason, completely, &result) );
391
392 if( result != SCIP_FEASIBLE )
393 {
394 *feasible = FALSE;
395
396 if( !completely )
397 return SCIP_OKAY;
398 }
399 }
400 }
401
402 return SCIP_OKAY;
403}
404
405/** update integrality violation of a solution */
407 SCIP* scip, /**< SCIP data structure */
408 SCIP_SOL* sol, /**< primal CIP solution */
409 SCIP_Real absviol /**< absolute violation */
410 )
411{
412 assert(scip != NULL);
413 assert(sol != NULL);
414 assert(sol->scip == scip);
415
416 if( SCIPprimalUpdateViolations(scip->origprimal) )
418}
419
420/** update bound violation of a solution */
422 SCIP* scip, /**< SCIP data structure */
423 SCIP_SOL* sol, /**< primal CIP solution */
424 SCIP_Real absviol, /**< absolute violation */
425 SCIP_Real relviol /**< relative violation */
426 )
427{
428 assert(scip != NULL);
429 assert(sol != NULL);
430 assert(sol->scip == scip);
431
432 if( SCIPprimalUpdateViolations(scip->origprimal) )
433 SCIPsolUpdateBoundViolation(sol, absviol, relviol);
434}
435
436/** update LP row violation of a solution */
438 SCIP* scip, /**< SCIP data structure */
439 SCIP_SOL* sol, /**< primal CIP solution */
440 SCIP_Real absviol, /**< absolute violation */
441 SCIP_Real relviol /**< relative violation */
442 )
443{
444 assert(scip != NULL);
445 assert(sol != NULL);
446 assert(sol->scip == scip);
447
448 if( SCIPprimalUpdateViolations(scip->origprimal) )
449 SCIPsolUpdateLPRowViolation(sol, absviol, relviol);
450}
451
452/** update constraint violation of a solution */
454 SCIP* scip, /**< SCIP data structure */
455 SCIP_SOL* sol, /**< primal CIP solution */
456 SCIP_Real absviol, /**< absolute violation */
457 SCIP_Real relviol /**< relative violation */
458 )
459{
460 assert(scip != NULL);
461 assert(sol != NULL);
462 assert(sol->scip == scip);
463
464 if( SCIPprimalUpdateViolations(scip->origprimal) )
465 SCIPsolUpdateConsViolation(sol, absviol, relviol);
466}
467
468/** update LP row and constraint violations of a solution */
470 SCIP* scip, /**< SCIP data structure */
471 SCIP_SOL* sol, /**< primal CIP solution */
472 SCIP_Real absviol, /**< absolute violation */
473 SCIP_Real relviol /**< relative violation */
474 )
475{
476 assert(scip != NULL);
477 assert(sol != NULL);
478 assert(sol->scip == scip);
479
480 if( SCIPprimalUpdateViolations(scip->origprimal) )
481 SCIPsolUpdateLPConsViolation(sol, absviol, relviol);
482}
483
484/** allow violation updates */
486 SCIP* scip /**< SCIP data structure */
487 )
488{
490}
491
492/** disallow violation updates */
494 SCIP* scip /**< SCIP data structure */
495 )
496{
498}
499
500/** creates a primal solution, initialized to zero
501 *
502 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
503 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
504 *
505 * @pre This method can be called if SCIP is in one of the following stages:
506 * - \ref SCIP_STAGE_PROBLEM
507 * - \ref SCIP_STAGE_TRANSFORMING
508 * - \ref SCIP_STAGE_TRANSFORMED
509 * - \ref SCIP_STAGE_INITPRESOLVE
510 * - \ref SCIP_STAGE_PRESOLVING
511 * - \ref SCIP_STAGE_EXITPRESOLVE
512 * - \ref SCIP_STAGE_PRESOLVED
513 * - \ref SCIP_STAGE_INITSOLVE
514 * - \ref SCIP_STAGE_SOLVING
515 */
517 SCIP* scip, /**< SCIP data structure */
518 SCIP_SOL** sol, /**< pointer to store the solution */
519 SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
520 )
521{
523
524 switch( scip->set->stage )
525 {
527 SCIP_CALL( SCIPsolCreateOriginal(sol, scip->mem->probmem, scip->set, scip->stat, scip->origprob, scip->origprimal, NULL, heur) );
528 return SCIP_OKAY;
529
538 SCIP_CALL( SCIPsolCreate(sol, scip->mem->probmem, scip->set, scip->stat, scip->primal, scip->tree, heur) );
539 return SCIP_OKAY;
540
544 default:
545 SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
546 return SCIP_INVALIDDATA;
547 } /*lint !e788*/
548}
549
550/** creates an exact primal solution, initialized to zero
551 *
552 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
553 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
554 *
555 * @pre This method can be called if SCIP is in one of the following stages:
556 * - \ref SCIP_STAGE_PROBLEM
557 * - \ref SCIP_STAGE_TRANSFORMING
558 * - \ref SCIP_STAGE_TRANSFORMED
559 * - \ref SCIP_STAGE_INITPRESOLVE
560 * - \ref SCIP_STAGE_PRESOLVING
561 * - \ref SCIP_STAGE_EXITPRESOLVE
562 * - \ref SCIP_STAGE_PRESOLVED
563 * - \ref SCIP_STAGE_INITSOLVE
564 * - \ref SCIP_STAGE_SOLVING
565 */
567 SCIP* scip, /**< SCIP data structure */
568 SCIP_SOL** sol, /**< pointer to store the solution */
569 SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
570 )
571{
572 SCIP_CALL( SCIPcheckStage(scip, "SCIPcreateSolExact", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE) );
573
574 switch( scip->set->stage )
575 {
577 SCIP_CALL( SCIPsolCreateOriginalExact(sol, scip->mem->probmem, scip->set, scip->stat, scip->origprob, scip->origprimal, NULL, heur) );
578 return SCIP_OKAY;
579
588 SCIP_CALL( SCIPsolCreateExact(sol, scip->mem->probmem, scip->set, scip->stat, scip->primal, scip->tree, heur) );
589 return SCIP_OKAY;
590
594 default:
595 SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
596 return SCIP_INVALIDDATA;
597 } /*lint !e788*/
598}
599
600/** creates a primal solution, initialized to the current LP solution
601 *
602 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
603 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
604 *
605 * @pre This method can be called if SCIP is in one of the following stages:
606 * - \ref SCIP_STAGE_SOLVING
607 */
609 SCIP* scip, /**< SCIP data structure */
610 SCIP_SOL** sol, /**< pointer to store the solution */
611 SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
612 )
613{
615
616 if( !SCIPtreeHasCurrentNodeLP(scip->tree) )
617 {
618 SCIPerrorMessage("LP solution does not exist\n");
619 return SCIP_INVALIDCALL;
620 }
621
622 SCIP_CALL( SCIPsolCreateLPSol(sol, scip->mem->probmem, scip->set, scip->stat, scip->transprob, scip->primal,
623 scip->tree, scip->lp, heur) );
624
625 return SCIP_OKAY;
626}
627
628/** creates an exact primal solution, initialized to the current exact LP solution
629 *
630 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
631 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
632 *
633 * @pre This method can be called if SCIP is in one of the following stages:
634 * - \ref SCIP_STAGE_SOLVING
635 */
637 SCIP* scip, /**< SCIP data structure */
638 SCIP_SOL** sol, /**< pointer to store the solution */
639 SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
640 )
641{
642 SCIP_CALL( SCIPcheckStage(scip, "SCIPcreateLPSolExact", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
643
644 if( !SCIPtreeHasCurrentNodeLP(scip->tree) )
645 {
646 SCIPerrorMessage("LP solution does not exist\n");
647 return SCIP_INVALIDCALL;
648 }
649
650 SCIP_CALL( SCIPsolCreateLPSolExact(sol, scip->mem->probmem, scip->set, scip->stat, scip->primal,
651 scip->tree, scip->lpexact, heur) );
652
653 return SCIP_OKAY;
654}
655
656/** creates a primal solution, initialized to the current NLP solution
657 *
658 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
659 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
660 *
661 * @pre This method can be called if SCIP is in one of the following stages:
662 * - \ref SCIP_STAGE_SOLVING
663 */
665 SCIP* scip, /**< SCIP data structure */
666 SCIP_SOL** sol, /**< pointer to store the solution */
667 SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
668 )
669{
671
673 {
674 SCIPerrorMessage("NLP does not exist\n");
675 return SCIP_INVALIDCALL;
676 }
677 assert(scip->nlp != NULL);
678
679 if( !SCIPnlpHasSolution(scip->nlp) )
680 {
681 SCIPerrorMessage("NLP solution does not exist\n");
682 return SCIP_INVALIDCALL;
683 }
684
685 SCIP_CALL( SCIPsolCreateNLPSol(sol, scip->mem->probmem, scip->set, scip->stat, scip->primal, scip->tree, scip->nlp,
686 heur) );
687
688 return SCIP_OKAY;
689}
690
691/** creates a primal solution, initialized to the current relaxation solution
692 *
693 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
694 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
695 *
696 * @pre This method can be called if SCIP is in one of the following stages:
697 * - \ref SCIP_STAGE_SOLVING
698 */
700 SCIP* scip, /**< SCIP data structure */
701 SCIP_SOL** sol, /**< pointer to store the solution */
702 SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
703 )
704{
706
707 if( !SCIPrelaxationIsSolValid(scip->relaxation) )
708 {
709 SCIPerrorMessage("relaxation solution is not valid\n");
710 return SCIP_INVALIDCALL;
711 }
712
713 SCIP_CALL( SCIPsolCreateRelaxSol(sol, scip->mem->probmem, scip->set, scip->stat, scip->primal, scip->tree, scip->relaxation, heur) );
714
715 return SCIP_OKAY;
716}
717
718/** creates a primal solution, initialized to the current pseudo solution
719 *
720 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
721 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
722 *
723 * @pre This method can be called if SCIP is in one of the following stages:
724 * - \ref SCIP_STAGE_SOLVING
725 */
727 SCIP* scip, /**< SCIP data structure */
728 SCIP_SOL** sol, /**< pointer to store the solution */
729 SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
730 )
731{
733
734 SCIP_CALL( SCIPsolCreatePseudoSol(sol, scip->mem->probmem, scip->set, scip->stat, scip->transprob, scip->primal,
735 scip->tree, scip->lp, heur) );
736
737 return SCIP_OKAY;
738}
739
740/** creates a primal solution, initialized to the current LP or pseudo solution, depending on whether the LP was solved
741 * at the current node
742 *
743 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
744 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
745 *
746 * @pre This method can be called if SCIP is in one of the following stages:
747 * - \ref SCIP_STAGE_SOLVING
748 */
750 SCIP* scip, /**< SCIP data structure */
751 SCIP_SOL** sol, /**< pointer to store the solution */
752 SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
753 )
754{
755 SCIP_CALL( SCIPcheckStage(scip, "SCIPcreateCurrentSol", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
756
757 SCIP_CALL( SCIPsolCreateCurrentSol(sol, scip->mem->probmem, scip->set, scip->stat, scip->transprob, scip->primal,
758 scip->tree, scip->lp, heur) );
759
760 return SCIP_OKAY;
761}
762
763/** creates a partial primal solution, initialized to unknown values
764 *
765 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
766 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
767 *
768 * @pre This method can be called if SCIP is in one of the following stages:
769 * - \ref SCIP_STAGE_PROBLEM
770 */
772 SCIP* scip, /**< SCIP data structure */
773 SCIP_SOL** sol, /**< pointer to store the solution */
774 SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
775 )
776{
777 SCIP_CALL( SCIPcheckStage(scip, "SCIPcreatePartialSol", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
778
779 SCIP_CALL( SCIPsolCreatePartial(sol, scip->mem->probmem, scip->set, scip->stat, scip->origprimal, heur) );
780
781 return SCIP_OKAY;
782}
783
784/** creates a primal solution, initialized to unknown values
785 *
786 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
787 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
788 *
789 * @pre This method can be called if SCIP is in one of the following stages:
790 * - \ref SCIP_STAGE_TRANSFORMING
791 * - \ref SCIP_STAGE_TRANSFORMED
792 * - \ref SCIP_STAGE_INITPRESOLVE
793 * - \ref SCIP_STAGE_PRESOLVING
794 * - \ref SCIP_STAGE_EXITPRESOLVE
795 * - \ref SCIP_STAGE_PRESOLVED
796 * - \ref SCIP_STAGE_INITSOLVE
797 * - \ref SCIP_STAGE_SOLVING
798 */
800 SCIP* scip, /**< SCIP data structure */
801 SCIP_SOL** sol, /**< pointer to store the solution */
802 SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
803 )
804{
805 SCIP_CALL( SCIPcheckStage(scip, "SCIPcreateUnknownSol", FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE) );
806
807 SCIP_CALL( SCIPsolCreateUnknown(sol, scip->mem->probmem, scip->set, scip->stat, scip->primal, scip->tree, heur) );
808
809 return SCIP_OKAY;
810}
811
812/** creates a primal solution living in the original problem space, initialized to zero;
813 * a solution in original space allows to set original variables to values that would be invalid in the
814 * transformed problem due to preprocessing fixings or aggregations
815 *
816 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
817 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
818 *
819 * @pre This method can be called if SCIP is in one of the following stages:
820 * - \ref SCIP_STAGE_PROBLEM
821 * - \ref SCIP_STAGE_TRANSFORMING
822 * - \ref SCIP_STAGE_TRANSFORMED
823 * - \ref SCIP_STAGE_INITPRESOLVE
824 * - \ref SCIP_STAGE_PRESOLVING
825 * - \ref SCIP_STAGE_EXITPRESOLVE
826 * - \ref SCIP_STAGE_PRESOLVED
827 * - \ref SCIP_STAGE_INITSOLVE
828 * - \ref SCIP_STAGE_SOLVING
829 * - \ref SCIP_STAGE_SOLVED
830 */
832 SCIP* scip, /**< SCIP data structure */
833 SCIP_SOL** sol, /**< pointer to store the solution */
834 SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
835 )
836{
837 SCIP_CALL( SCIPcheckStage(scip, "SCIPcreateOrigSol", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
838
839 switch( scip->set->stage )
840 {
842 SCIP_CALL( SCIPsolCreateOriginal(sol, scip->mem->probmem, scip->set, scip->stat, scip->origprob, scip->origprimal, NULL, heur) );
843 return SCIP_OKAY;
844
854 SCIP_CALL( SCIPsolCreateOriginal(sol, scip->mem->probmem, scip->set, scip->stat, scip->origprob, scip->primal, scip->tree, heur) );
855 return SCIP_OKAY;
856
859 default:
860 SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
861 return SCIP_INVALIDCALL;
862 } /*lint !e788*/
863}
864
865/** creates a copy of a primal solution; note that a copy of a linked solution is also linked and needs to be unlinked
866 * if it should stay unaffected from changes in the LP or pseudo solution
867 *
868 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
869 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
870 *
871 * @pre This method can be called if SCIP is in one of the following stages:
872 * - \ref SCIP_STAGE_PROBLEM
873 * - \ref SCIP_STAGE_FREETRANS
874 * - \ref SCIP_STAGE_TRANSFORMING
875 * - \ref SCIP_STAGE_TRANSFORMED
876 * - \ref SCIP_STAGE_INITPRESOLVE
877 * - \ref SCIP_STAGE_PRESOLVING
878 * - \ref SCIP_STAGE_EXITPRESOLVE
879 * - \ref SCIP_STAGE_PRESOLVED
880 * - \ref SCIP_STAGE_INITSOLVE
881 * - \ref SCIP_STAGE_SOLVING
882 * - \ref SCIP_STAGE_SOLVED
883 */
885 SCIP* scip, /**< SCIP data structure */
886 SCIP_SOL** sol, /**< pointer to store the solution */
887 SCIP_SOL* sourcesol /**< primal CIP solution to copy */
888 )
889{
890 SCIP_CALL( SCIPcheckStage(scip, "SCIPcreateSolCopy", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
891
892 /* check if we want to copy the current solution, which is the same as creating a current solution */
893 if( sourcesol == NULL )
894 {
896 }
897 else
898 {
899 SCIP_CALL( SCIPsolCopy(sol, scip->mem->probmem, scip->set, scip->stat, scip->primal, sourcesol) );
900 }
901
902 return SCIP_OKAY;
903}
904
905/** creates a copy of a solution in the original primal solution space
906 *
907 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
908 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
909 *
910 * @pre This method can be called if SCIP is in one of the following stages:
911 * - \ref SCIP_STAGE_PROBLEM
912 * - \ref SCIP_STAGE_TRANSFORMING
913 * - \ref SCIP_STAGE_TRANSFORMED
914 * - \ref SCIP_STAGE_INITPRESOLVE
915 * - \ref SCIP_STAGE_PRESOLVING
916 * - \ref SCIP_STAGE_EXITPRESOLVE
917 * - \ref SCIP_STAGE_PRESOLVED
918 * - \ref SCIP_STAGE_INITSOLVE
919 * - \ref SCIP_STAGE_SOLVING
920 * - \ref SCIP_STAGE_SOLVED
921 * - \ref SCIP_STAGE_EXITSOLVE
922 * - \ref SCIP_STAGE_FREETRANS
923 */
925 SCIP* scip, /**< SCIP data structure */
926 SCIP_SOL** sol, /**< pointer to store the solution */
927 SCIP_SOL* sourcesol /**< primal CIP solution to copy */
928 )
929{
930 SCIP_CALL( SCIPcheckStage(scip, "SCIPcreateSolCopyOrig", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
931
932 /* check if we want to copy the current solution, which is the same as creating a current solution */
933 if( sourcesol == NULL )
934 {
936 }
937 else
938 {
939 switch( scip->set->stage )
940 {
952 SCIP_CALL( SCIPsolCopy(sol, scip->mem->probmem, scip->set, scip->stat, scip->origprimal, sourcesol) );
954 break;
955 default:
956 assert(FALSE); /*lint !e506*/
957 } /*lint !e788*/
958 }
959
960 return SCIP_OKAY;
961}
962
963/** helper method that sets up and solves the sub-SCIP for removing infinite values from solutions */
964static
966 SCIP* scip, /**< SCIP data structure */
967 SCIP* subscip, /**< SCIP data structure of sub-SCIP*/
968 SCIP_VAR** origvars, /**< original problem variables of main SCIP */
969 int norigvars, /**< number of original problem variables of main SCIP */
970 SCIP_Real* solvals, /**< array with solution values of variables; infinite ones are replaced */
971 SCIP_Bool* success /**< pointer to store if removing infinite values was successful */
972 )
973{
974 SCIP_HASHMAP* varmap;
975 SCIP_VAR* varcopy;
976 SCIP_Real fixval;
977 SCIP_Bool valid;
978 SCIP_SOL* bestsol;
979 int v;
980
981 assert(scip != NULL);
982 assert(subscip != NULL);
983 assert(origvars != NULL);
984 assert(solvals != NULL);
985 assert(success != NULL);
986
987 /* copy the original problem to the sub-SCIP */
988 SCIP_CALL( SCIPhashmapCreate(&varmap, SCIPblkmem(scip), norigvars) );
989 SCIP_CALL( SCIPcopyOrig(scip, subscip, varmap, NULL, "removeinffixings", TRUE, FALSE, TRUE, &valid) );
990
991 SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", (int)SCIP_VERBLEVEL_NONE) );
992
993 /* in the sub-SCIP, we try to minimize the absolute values of all variables with infinite values in the solution
994 * and fix all other variables to the value they have in the solution
995 */
996 for( v = 0; v < norigvars; ++v )
997 {
998 varcopy = (SCIP_VAR*) SCIPhashmapGetImage(varmap, (void*)origvars[v]);
999 assert(varcopy != NULL);
1000
1001 fixval = solvals[v];
1002
1003 if( SCIPisInfinity(scip, fixval) || SCIPisInfinity(scip, -fixval) )
1004 {
1005 /* If a variable with a finite finite lower bound was set to +infinity, we just change its objective to 1.0
1006 * to minimize its value; if a variable with a finite finite upper bound was set to -infinity, we just
1007 * change its objective to -1.0 to maximize its value; if a variable is free, we split the variable into
1008 * positive and negative part by creating two new non-negative variables and one constraint linking those
1009 * variables.
1010 */
1011 if( SCIPisInfinity(scip, fixval) && !SCIPisInfinity(scip, -SCIPvarGetLbLocal(varcopy)) )
1012 {
1013 SCIP_CALL( SCIPchgVarObj(subscip, varcopy, 1.0) );
1014 }
1015 else if( SCIPisInfinity(scip, -fixval) && !SCIPisInfinity(scip, SCIPvarGetUbLocal(varcopy)) )
1016 {
1017 SCIP_CALL( SCIPchgVarObj(subscip, varcopy, -1.0) );
1018 }
1019 else
1020 {
1021 char name[SCIP_MAXSTRLEN];
1022 SCIP_VAR* posvar;
1023 SCIP_VAR* negvar;
1024 SCIP_CONS* linkcons;
1025
1026 (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "%s_%s", SCIPvarGetName(varcopy), "run");
1027 SCIP_CALL( SCIPcreateVar(subscip, &posvar, name, 0.0, SCIPinfinity(scip), 1.0,
1029 SCIP_CALL( SCIPaddVar(subscip, posvar) );
1030
1031 (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "%s_%s", SCIPvarGetName(varcopy), "neg");
1032 SCIP_CALL( SCIPcreateVar(subscip, &negvar, name, 0.0, SCIPinfinity(scip), 1.0,
1034 SCIP_CALL( SCIPaddVar(subscip, negvar) );
1035
1036 (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "%s_%s", SCIPvarGetName(varcopy), "linkcons");
1037 SCIP_CALL( SCIPcreateConsBasicLinear(subscip, &linkcons, name, 0, NULL, NULL, 0.0, 0.0 ) );
1038 SCIP_CALL( SCIPaddCoefLinear(subscip, linkcons, varcopy, 1.0) );
1039 SCIP_CALL( SCIPaddCoefLinear(subscip, linkcons, posvar, -1.0) );
1040 SCIP_CALL( SCIPaddCoefLinear(subscip, linkcons, negvar, 1.0) );
1041 SCIP_CALL( SCIPaddCons(subscip, linkcons) );
1042
1043 SCIP_CALL( SCIPreleaseCons(subscip, &linkcons) );
1044 SCIP_CALL( SCIPreleaseVar(subscip, &posvar) );
1045 SCIP_CALL( SCIPreleaseVar(subscip, &negvar) );
1046
1047 SCIP_CALL( SCIPchgVarObj(subscip, varcopy, 0.0) );
1048 }
1049 }
1050 else
1051 {
1052 SCIP_Bool infeasible;
1053 SCIP_Bool fixed;
1054
1055 if( SCIPisFeasLT(scip, solvals[v], SCIPvarGetLbLocal(varcopy)) || SCIPisFeasGT(scip, solvals[v], SCIPvarGetUbLocal(varcopy)) )
1056 {
1057 SCIP_CALL( SCIPchgVarType(subscip, varcopy, SCIP_VARTYPE_CONTINUOUS, &infeasible) );
1058 assert(!infeasible);
1059 }
1060
1061 /* fix variable to its value in the solution */
1062 SCIP_CALL( SCIPfixVar(subscip, varcopy, fixval, &infeasible, &fixed) );
1063 assert(!infeasible);
1064 }
1065 }
1066
1067 SCIP_CALL( SCIPsolve(subscip) );
1068
1069 bestsol = SCIPgetBestSol(subscip);
1070
1071 if( bestsol != NULL )
1072 {
1073 /* change the stored solution values for variables fixed to infinite values */
1074 for( v = 0; v < norigvars; ++v )
1075 {
1076 varcopy = (SCIP_VAR*) SCIPhashmapGetImage(varmap, (void*)origvars[v]);
1077 assert(varcopy != NULL);
1078
1079 if( (SCIPisInfinity(scip, solvals[v]) || SCIPisInfinity(scip, -solvals[v])) )
1080 {
1081 solvals[v] = SCIPgetSolVal(subscip, bestsol, varcopy);
1082 }
1083 }
1084 }
1085 else
1086 {
1087 *success = FALSE;
1088 }
1089
1090 SCIPhashmapFree(&varmap);
1091
1092 return SCIP_OKAY;
1093}
1094
1095
1096/** creates a copy of a primal solution, thereby replacing infinite fixings of variables by finite values;
1097 * the copy is always defined in the original variable space;
1098 * success indicates whether the objective value of the solution was changed by removing infinite values
1099 *
1100 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1101 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1102 *
1103 * @pre This method can be called if SCIP is in one of the following stages:
1104 * - \ref SCIP_STAGE_PROBLEM
1105 * - \ref SCIP_STAGE_TRANSFORMING
1106 * - \ref SCIP_STAGE_TRANSFORMED
1107 * - \ref SCIP_STAGE_INITPRESOLVE
1108 * - \ref SCIP_STAGE_PRESOLVING
1109 * - \ref SCIP_STAGE_EXITPRESOLVE
1110 * - \ref SCIP_STAGE_PRESOLVED
1111 * - \ref SCIP_STAGE_INITSOLVE
1112 * - \ref SCIP_STAGE_SOLVING
1113 * - \ref SCIP_STAGE_SOLVED
1114 * - \ref SCIP_STAGE_EXITSOLVE
1115 */
1117 SCIP* scip, /**< SCIP data structure */
1118 SCIP_SOL** sol, /**< pointer to store the solution */
1119 SCIP_SOL* sourcesol, /**< primal CIP solution to copy */
1120 SCIP_Bool* success /**< does the finite solution have the same objective value? */
1121 )
1122{
1123 SCIP_VAR** fixedvars;
1124 SCIP_VAR** origvars;
1125 SCIP_Real* solvals;
1126 SCIP_VAR* var;
1127 int nfixedvars;
1128 int norigvars;
1129 int v;
1130
1131 SCIP_CALL( SCIPcheckStage(scip, "SCIPcreateFiniteSolCopy", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE) );
1132
1133 assert(scip != NULL);
1134 assert(sol != NULL);
1135 assert(sourcesol != NULL);
1136 assert(success != NULL);
1137
1138 *success = TRUE;
1139 *sol = NULL;
1140
1141 fixedvars = SCIPgetFixedVars(scip);
1142 nfixedvars = SCIPgetNFixedVars(scip);
1143 assert(fixedvars != NULL || nfixedvars == 0);
1144
1145 /* get original variables and their values in the optimal solution */
1146 SCIP_CALL( SCIPgetOrigVarsData(scip, &origvars, &norigvars, NULL, NULL, NULL, NULL) );
1147 SCIP_CALL( SCIPallocBufferArray(scip, &solvals, norigvars) );
1148 SCIP_CALL( SCIPgetSolVals(scip, sourcesol, norigvars, origvars, solvals) );
1149
1150 /* check whether there are variables fixed to an infinite value */
1151 for( v = 0; v < nfixedvars; ++v )
1152 {
1153 var = fixedvars[v]; /*lint !e613*/
1154
1155 /* skip (multi-)aggregated variables */
1157 continue;
1158
1160
1162 {
1163 SCIPdebugMsg(scip, "var <%s> is fixed to infinite value %g\n", SCIPvarGetName(var), SCIPvarGetLbGlobal(var));
1164 break;
1165 }
1166 }
1167
1168 /* there were variables fixed to infinite values */
1169 if( v < nfixedvars )
1170 {
1171 SCIP* subscip;
1172 SCIP_RETCODE retcode;
1173
1174 /* if one of the variables was fixed to infinity in the original problem, we stop here */
1175 for( v = 0; v < norigvars; ++v )
1176 {
1177 var = origvars[v];
1178
1180 {
1182
1183 SCIPdebugMsg(scip, "--> var <%s> is fixed to infinite value %g in the original problem, stop making solution finite\n",
1185
1186 *success = FALSE;
1187
1188 goto TERMINATE;
1189 }
1190 }
1191
1192 /* create sub-SCIP */
1193 SCIP_CALL( SCIPcreate(&subscip) );
1194
1195 retcode = setupAndSolveFiniteSolSubscip(scip, subscip, origvars, norigvars, solvals, success);
1196
1197 /* free sub-SCIP */
1198 SCIP_CALL( SCIPfree(&subscip) );
1199
1200 SCIP_CALL( retcode );
1201 }
1202
1203 /* create original solution and set the solution values */
1204 if( *success )
1205 {
1207 for( v = 0; v < norigvars; ++v )
1208 {
1209 SCIP_CALL( SCIPsetSolVal(scip, *sol, origvars[v], solvals[v]) );
1210 }
1211 }
1212
1213#ifdef SCIP_DEBUG
1214 SCIPdebugMsg(scip, "created finites solution copy:\n");
1215 SCIP_CALL( SCIPprintSol(scip, *sol, NULL, FALSE) );
1216#endif
1217
1218 /* the solution of the sub-SCIP should have the same objective value */
1219 if( *success && !SCIPisEQ(scip, SCIPgetSolOrigObj(scip, *sol), SCIPgetSolOrigObj(scip, sourcesol)) )
1220 {
1221 /* @todo how should we avoid numerical trobles here for large objective values? */
1222 if( (SCIPgetSolOrigObj(scip, *sol) / SCIPepsilon(scip)) < 1e+15 ||
1223 REALABS(SCIPgetSolOrigObj(scip, *sol) - SCIPgetSolOrigObj(scip, sourcesol)) > 1e-12 * SCIPgetSolOrigObj(scip, *sol) )
1224 *success = FALSE;
1225 }
1226
1227 TERMINATE:
1228 SCIPfreeBufferArray(scip, &solvals);
1229
1230 return SCIP_OKAY;
1231}
1232
1233/** frees primal CIP solution
1234 *
1235 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1236 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1237 *
1238 * @pre This method can be called if SCIP is in one of the following stages:
1239 * - \ref SCIP_STAGE_PROBLEM
1240 * - \ref SCIP_STAGE_TRANSFORMING
1241 * - \ref SCIP_STAGE_TRANSFORMED
1242 * - \ref SCIP_STAGE_INITPRESOLVE
1243 * - \ref SCIP_STAGE_PRESOLVING
1244 * - \ref SCIP_STAGE_EXITPRESOLVE
1245 * - \ref SCIP_STAGE_PRESOLVED
1246 * - \ref SCIP_STAGE_INITSOLVE
1247 * - \ref SCIP_STAGE_SOLVING
1248 * - \ref SCIP_STAGE_SOLVED
1249 * - \ref SCIP_STAGE_EXITSOLVE
1250 * - \ref SCIP_STAGE_FREETRANS
1251 */
1253 SCIP* scip, /**< SCIP data structure */
1254 SCIP_SOL** sol /**< pointer to the solution */
1255 )
1256{
1257 assert(sol != NULL);
1258
1260
1261 switch( scip->set->stage )
1262 {
1263 case SCIP_STAGE_PROBLEM:
1264 SCIP_CALL( SCIPsolFree(sol, scip->mem->probmem, scip->origprimal) );
1265 break;
1272 case SCIP_STAGE_SOLVING:
1275 case SCIP_STAGE_SOLVED:
1277 SCIP_CALL( SCIPsolFree(sol, scip->mem->probmem, scip->primal) );
1278 break;
1279 default:
1280 SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
1281 return SCIP_INVALIDCALL;
1282 } /*lint !e788*/
1283
1284 return SCIP_OKAY;
1285}
1286
1287/** links a primal solution to the current LP solution
1288 *
1289 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1290 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1291 *
1292 * @pre This method can be called if SCIP is in one of the following stages:
1293 * - \ref SCIP_STAGE_SOLVING
1294 */
1296 SCIP* scip, /**< SCIP data structure */
1297 SCIP_SOL* sol /**< primal solution */
1298 )
1299{
1300 assert(sol != NULL);
1301 assert(sol->scip == scip);
1302
1304
1305 if( !SCIPlpIsSolved(scip->lp) )
1306 {
1307 SCIPerrorMessage("LP solution does not exist\n");
1308 return SCIP_INVALIDCALL;
1309 }
1310
1311 SCIP_CALL( SCIPsolLinkLPSol(sol, scip->set, scip->stat, scip->transprob, scip->tree, scip->lp) );
1312
1313 return SCIP_OKAY;
1314}
1315
1316/** links a primal solution to the current exact LP solution
1317 *
1318 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1319 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1320 *
1321 * @pre This method can be called if SCIP is in one of the following stages:
1322 * - \ref SCIP_STAGE_SOLVING
1323 */
1325 SCIP* scip, /**< SCIP data structure */
1326 SCIP_SOL* sol /**< primal solution */
1327 )
1328{
1329 assert(sol != NULL);
1330 assert(sol->scip == scip);
1331
1333
1335 {
1336 SCIPerrorMessage("Exact LP solution does not exist\n");
1337 return SCIP_INVALIDCALL;
1338 }
1339
1340 SCIP_CALL( SCIPsolLinkLPSolExact(sol, scip->set, scip->lpexact) );
1341
1342 return SCIP_OKAY;
1343}
1344
1345/** links a primal solution to the current NLP solution
1346 *
1347 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1348 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1349 *
1350 * @pre This method can be called if SCIP is in one of the following stages:
1351 * - \ref SCIP_STAGE_SOLVING
1352 */
1354 SCIP* scip, /**< SCIP data structure */
1355 SCIP_SOL* sol /**< primal solution */
1356 )
1357{
1358 assert(sol != NULL);
1359 assert(sol->scip == scip);
1360
1362
1363 if( scip->nlp == NULL )
1364 {
1365 SCIPerrorMessage("NLP does not exist\n");
1366 return SCIP_INVALIDCALL;
1367 }
1368
1370 {
1371 SCIPerrorMessage("NLP solution does not exist\n");
1372 return SCIP_INVALIDCALL;
1373 }
1374
1375 SCIP_CALL( SCIPsolLinkNLPSol(sol, scip->stat, scip->tree, scip->nlp) );
1376
1377 return SCIP_OKAY;
1378}
1379
1380/** links a primal solution to the current relaxation solution
1381 *
1382 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1383 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1384 *
1385 * @pre This method can be called if SCIP is in one of the following stages:
1386 * - \ref SCIP_STAGE_SOLVING
1387 */
1389 SCIP* scip, /**< SCIP data structure */
1390 SCIP_SOL* sol /**< primal solution */
1391 )
1392{
1393 assert(sol != NULL);
1394 assert(sol->scip == scip);
1395
1397
1398 if( !SCIPrelaxationIsSolValid(scip->relaxation) )
1399 {
1400 SCIPerrorMessage("relaxation solution is not valid\n");
1401 return SCIP_INVALIDCALL;
1402 }
1403
1404 SCIP_CALL( SCIPsolLinkRelaxSol(sol, scip->set, scip->stat, scip->tree, scip->relaxation) );
1405
1406 return SCIP_OKAY;
1407}
1408
1409/** links a primal solution to the current pseudo solution
1410 *
1411 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1412 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1413 *
1414 * @pre This method can be called if SCIP is in one of the following stages:
1415 * - \ref SCIP_STAGE_PRESOLVING
1416 * - \ref SCIP_STAGE_SOLVING
1417 */
1419 SCIP* scip, /**< SCIP data structure */
1420 SCIP_SOL* sol /**< primal solution */
1421 )
1422{
1423 assert(sol != NULL);
1424 assert(sol->scip == scip);
1425
1427
1428 SCIP_CALL( SCIPsolLinkPseudoSol(sol, scip->set, scip->stat, scip->transprob, scip->tree, scip->lp) );
1429
1430 return SCIP_OKAY;
1431}
1432
1433/** links a primal solution to the current LP or pseudo solution
1434 *
1435 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1436 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1437 *
1438 * @pre This method can be called if SCIP is in one of the following stages:
1439 * - \ref SCIP_STAGE_SOLVING
1440 */
1442 SCIP* scip, /**< SCIP data structure */
1443 SCIP_SOL* sol /**< primal solution */
1444 )
1445{
1446 assert(sol != NULL);
1447 assert(sol->scip == scip);
1448
1450
1451 SCIP_CALL( SCIPsolLinkCurrentSol(sol, scip->set, scip->stat, scip->transprob, scip->tree, scip->lp) );
1452
1453 return SCIP_OKAY;
1454}
1455
1456/** clears a primal solution
1457 *
1458 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1459 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1460 *
1461 * @pre This method can be called if SCIP is in one of the following stages:
1462 * - \ref SCIP_STAGE_PROBLEM
1463 * - \ref SCIP_STAGE_TRANSFORMING
1464 * - \ref SCIP_STAGE_TRANSFORMED
1465 * - \ref SCIP_STAGE_INITPRESOLVE
1466 * - \ref SCIP_STAGE_PRESOLVING
1467 * - \ref SCIP_STAGE_EXITPRESOLVE
1468 * - \ref SCIP_STAGE_PRESOLVED
1469 * - \ref SCIP_STAGE_INITSOLVE
1470 * - \ref SCIP_STAGE_SOLVING
1471 * - \ref SCIP_STAGE_SOLVED
1472 * - \ref SCIP_STAGE_EXITSOLVE
1473 * - \ref SCIP_STAGE_FREETRANS
1474 */
1476 SCIP* scip, /**< SCIP data structure */
1477 SCIP_SOL* sol /**< primal solution */
1478 )
1479{
1480 assert(sol != NULL);
1481 assert(sol->scip == scip);
1482
1483 SCIP_CALL( SCIPcheckStage(scip, "SCIPclearSol", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
1484
1485 SCIP_CALL( SCIPsolClear(sol, scip->stat, scip->tree) );
1486
1487 return SCIP_OKAY;
1488}
1489
1490/** stores solution values of variables in solution's own array
1491 *
1492 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1493 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1494 *
1495 * @pre This method can be called if SCIP is in one of the following stages:
1496 * - \ref SCIP_STAGE_TRANSFORMING
1497 * - \ref SCIP_STAGE_TRANSFORMED
1498 * - \ref SCIP_STAGE_PRESOLVING
1499 * - \ref SCIP_STAGE_PRESOLVED
1500 * - \ref SCIP_STAGE_INITSOLVE
1501 * - \ref SCIP_STAGE_SOLVING
1502 * - \ref SCIP_STAGE_SOLVED
1503 * - \ref SCIP_STAGE_EXITSOLVE
1504 * - \ref SCIP_STAGE_FREETRANS
1505 */
1507 SCIP* scip, /**< SCIP data structure */
1508 SCIP_SOL* sol /**< primal solution */
1509 )
1510{
1511 assert(sol != NULL);
1512 assert(sol->scip == scip);
1513
1515
1516 SCIP_CALL( SCIPsolUnlink(sol, scip->set, scip->transprob) );
1517
1518 return SCIP_OKAY;
1519}
1520
1521/** stores exact solution values of variables in solution's own array
1522 *
1523 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1524 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1525 *
1526 * @pre This method can be called if SCIP is in one of the following stages:
1527 * - \ref SCIP_STAGE_TRANSFORMING
1528 * - \ref SCIP_STAGE_TRANSFORMED
1529 * - \ref SCIP_STAGE_PRESOLVING
1530 * - \ref SCIP_STAGE_PRESOLVED
1531 * - \ref SCIP_STAGE_INITSOLVE
1532 * - \ref SCIP_STAGE_SOLVING
1533 * - \ref SCIP_STAGE_SOLVED
1534 * - \ref SCIP_STAGE_EXITSOLVE
1535 * - \ref SCIP_STAGE_FREETRANS
1536 */
1538 SCIP* scip, /**< SCIP data structure */
1539 SCIP_SOL* sol /**< primal solution */
1540 )
1541{
1542 assert(sol != NULL);
1543 assert(sol->scip == scip);
1544
1545 SCIP_CALL( SCIPcheckStage(scip, "SCIPunlinkSolExact", FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
1546
1547 SCIP_CALL( SCIPsolUnlinkExact(sol, scip->set, scip->transprob) );
1548
1549 return SCIP_OKAY;
1550}
1551
1552/** sets value of variable in primal CIP solution
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 if SCIP is in one of the following stages:
1558 * - \ref SCIP_STAGE_PROBLEM
1559 * - \ref SCIP_STAGE_TRANSFORMING
1560 * - \ref SCIP_STAGE_TRANSFORMED
1561 * - \ref SCIP_STAGE_INITPRESOLVE
1562 * - \ref SCIP_STAGE_PRESOLVING
1563 * - \ref SCIP_STAGE_EXITPRESOLVE
1564 * - \ref SCIP_STAGE_PRESOLVED
1565 * - \ref SCIP_STAGE_INITSOLVE
1566 * - \ref SCIP_STAGE_SOLVING
1567 * - \ref SCIP_STAGE_SOLVED
1568 * - \ref SCIP_STAGE_EXITSOLVE
1569 * - \ref SCIP_STAGE_FREETRANS
1570 */
1572 SCIP* scip, /**< SCIP data structure */
1573 SCIP_SOL* sol, /**< primal solution */
1574 SCIP_VAR* var, /**< variable to add to solution */
1575 SCIP_Real val /**< solution value of variable */
1576 )
1577{
1578 SCIP_CALL( SCIPcheckStage(scip, "SCIPsetSolVal", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
1579
1580 assert(var != NULL);
1581 assert(var->scip == scip);
1582 assert(sol != NULL);
1583 assert(sol->scip == scip);
1584
1585 if( SCIPsolIsOriginal(sol) && SCIPvarIsTransformed(var) )
1586 {
1587 SCIPerrorMessage("cannot set value of transformed variable <%s> in original space solution\n",
1588 SCIPvarGetName(var));
1589 return SCIP_INVALIDCALL;
1590 }
1591
1592 SCIP_CALL( SCIPsolSetVal(sol, scip->set, scip->stat, scip->tree, var, val) );
1593
1594 return SCIP_OKAY;
1595}
1596
1597/** sets exact value of variable in primal CIP solution
1598 *
1599 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1600 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1601 *
1602 * @pre This method can be called if SCIP is in one of the following stages:
1603 * - \ref SCIP_STAGE_PROBLEM
1604 * - \ref SCIP_STAGE_TRANSFORMING
1605 * - \ref SCIP_STAGE_TRANSFORMED
1606 * - \ref SCIP_STAGE_INITPRESOLVE
1607 * - \ref SCIP_STAGE_PRESOLVING
1608 * - \ref SCIP_STAGE_EXITPRESOLVE
1609 * - \ref SCIP_STAGE_PRESOLVED
1610 * - \ref SCIP_STAGE_INITSOLVE
1611 * - \ref SCIP_STAGE_SOLVING
1612 * - \ref SCIP_STAGE_SOLVED
1613 * - \ref SCIP_STAGE_EXITSOLVE
1614 * - \ref SCIP_STAGE_FREETRANS
1615 */
1617 SCIP* scip, /**< SCIP data structure */
1618 SCIP_SOL* sol, /**< primal solution */
1619 SCIP_VAR* var, /**< variable to add to solution */
1620 SCIP_RATIONAL* val /**< solution value of variable */
1621 )
1622{
1623 SCIP_CALL( SCIPcheckStage(scip, "SCIPsetSolValExact", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
1624
1625 assert(var != NULL);
1626 assert(var->scip == scip);
1627 assert(sol != NULL);
1628 assert(sol->scip == scip);
1629 assert(SCIPsolIsExact(sol));
1630
1631 if( SCIPsolIsOriginal(sol) && SCIPvarIsTransformed(var) )
1632 {
1633 SCIPerrorMessage("cannot set value of transformed variable <%s> in original space solution\n",
1634 SCIPvarGetName(var));
1635 return SCIP_INVALIDCALL;
1636 }
1637
1638 SCIP_CALL( SCIPsolSetValExact(sol, scip->set, scip->stat, scip->tree, var, val) );
1639
1640 return SCIP_OKAY;
1641}
1642
1643/** sets values of multiple variables in primal CIP solution
1644 *
1645 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1646 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1647 *
1648 * @pre This method can be called if SCIP is in one of the following stages:
1649 * - \ref SCIP_STAGE_PROBLEM
1650 * - \ref SCIP_STAGE_TRANSFORMING
1651 * - \ref SCIP_STAGE_TRANSFORMED
1652 * - \ref SCIP_STAGE_INITPRESOLVE
1653 * - \ref SCIP_STAGE_PRESOLVING
1654 * - \ref SCIP_STAGE_EXITPRESOLVE
1655 * - \ref SCIP_STAGE_PRESOLVED
1656 * - \ref SCIP_STAGE_INITSOLVE
1657 * - \ref SCIP_STAGE_SOLVING
1658 * - \ref SCIP_STAGE_SOLVED
1659 * - \ref SCIP_STAGE_EXITSOLVE
1660 * - \ref SCIP_STAGE_FREETRANS
1661 */
1663 SCIP* scip, /**< SCIP data structure */
1664 SCIP_SOL* sol, /**< primal solution */
1665 int nvars, /**< number of variables to set solution value for */
1666 SCIP_VAR** vars, /**< array with variables to add to solution */
1667 SCIP_Real* vals /**< array with solution values of variables */
1668 )
1669{
1670 int v;
1671
1672 assert(sol != NULL);
1673 assert(sol->scip == scip);
1674 assert(nvars == 0 || vars != NULL);
1675 assert(nvars == 0 || vals != NULL);
1676
1677 SCIP_CALL( SCIPcheckStage(scip, "SCIPsetSolVals", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
1678
1679 if( SCIPsolIsOriginal(sol) )
1680 {
1681 for( v = 0; v < nvars; ++v )
1682 {
1683 if( SCIPvarIsTransformed(vars[v]) )
1684 {
1685 SCIPerrorMessage("cannot set value of transformed variable <%s> in original space solution\n",
1686 SCIPvarGetName(vars[v]));
1687 return SCIP_INVALIDCALL;
1688 }
1689 }
1690 }
1691
1692 for( v = 0; v < nvars; ++v )
1693 {
1694 SCIP_CALL( SCIPsolSetVal(sol, scip->set, scip->stat, scip->tree, vars[v], vals[v]) );
1695 }
1696
1697 return SCIP_OKAY;
1698}
1699
1700/** increases value of variable in primal CIP solution
1701 *
1702 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1703 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1704 *
1705 * @pre This method can be called if SCIP is in one of the following stages:
1706 * - \ref SCIP_STAGE_PROBLEM
1707 * - \ref SCIP_STAGE_TRANSFORMING
1708 * - \ref SCIP_STAGE_TRANSFORMED
1709 * - \ref SCIP_STAGE_INITPRESOLVE
1710 * - \ref SCIP_STAGE_PRESOLVING
1711 * - \ref SCIP_STAGE_EXITPRESOLVE
1712 * - \ref SCIP_STAGE_PRESOLVED
1713 * - \ref SCIP_STAGE_INITSOLVE
1714 * - \ref SCIP_STAGE_SOLVING
1715 * - \ref SCIP_STAGE_SOLVED
1716 * - \ref SCIP_STAGE_EXITSOLVE
1717 * - \ref SCIP_STAGE_FREETRANS
1718 */
1720 SCIP* scip, /**< SCIP data structure */
1721 SCIP_SOL* sol, /**< primal solution */
1722 SCIP_VAR* var, /**< variable to increase solution value for */
1723 SCIP_Real incval /**< increment for solution value of variable */
1724 )
1725{
1726 SCIP_CALL( SCIPcheckStage(scip, "SCIPincSolVal", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
1727
1728 assert(var != NULL);
1729 assert(var->scip == scip);
1730 assert(sol != NULL);
1731 assert(sol->scip == scip);
1732
1733 if( SCIPsolIsOriginal(sol) && SCIPvarIsTransformed(var) )
1734 {
1735 SCIPerrorMessage("cannot increase value of transformed variable <%s> in original space solution\n",
1736 SCIPvarGetName(var));
1737 return SCIP_INVALIDCALL;
1738 }
1739
1740 SCIP_CALL( SCIPsolIncVal(sol, scip->set, scip->stat, scip->tree, var, incval) );
1741
1742 return SCIP_OKAY;
1743}
1744
1745/** returns value of variable in primal CIP solution, or in current LP/pseudo solution
1746 *
1747 * @return value of variable in primal CIP solution, or in current LP/pseudo solution
1748 *
1749 * @pre In case the solution pointer @p sol is @b NULL, that means it is asked for the LP or pseudo solution, this method
1750 * can only be called if @p scip is in the solving stage \ref SCIP_STAGE_SOLVING. In any other case, this method
1751 * can be called if @p scip is in one of the following stages:
1752 * - \ref SCIP_STAGE_PROBLEM
1753 * - \ref SCIP_STAGE_TRANSFORMING
1754 * - \ref SCIP_STAGE_TRANSFORMED
1755 * - \ref SCIP_STAGE_INITPRESOLVE
1756 * - \ref SCIP_STAGE_PRESOLVING
1757 * - \ref SCIP_STAGE_EXITPRESOLVE
1758 * - \ref SCIP_STAGE_PRESOLVED
1759 * - \ref SCIP_STAGE_INITSOLVE
1760 * - \ref SCIP_STAGE_SOLVING
1761 * - \ref SCIP_STAGE_SOLVED
1762 * - \ref SCIP_STAGE_EXITSOLVE
1763 * - \ref SCIP_STAGE_FREETRANS
1764 */
1766 SCIP* scip, /**< SCIP data structure */
1767 SCIP_SOL* sol, /**< primal solution, or NULL for current LP/pseudo solution */
1768 SCIP_VAR* var /**< variable to get value for */
1769 )
1770{
1772
1773 assert(var != NULL);
1774 assert(var->scip == scip);
1775 assert(sol == NULL || sol->scip == scip);
1776
1777 if( sol != NULL )
1778 return SCIPsolGetVal(sol, scip->set, scip->stat, var);
1779
1780 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetSolVal(sol==NULL)", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1781
1782 return SCIPvarGetSol(var, SCIPtreeHasCurrentNodeLP(scip->tree));
1783}
1784
1785/** gets value of variable in exact primal CIP solution, or in current LP/pseudo solution
1786 *
1787 * @pre In case the solution pointer @p sol is @b NULL, that means it is asked for the LP or pseudo solution, this method
1788 * can only be called if @p scip is in the solving stage \ref SCIP_STAGE_SOLVING. In any other case, this method
1789 * can be called if @p scip is in one of the following stages:
1790 * - \ref SCIP_STAGE_PROBLEM
1791 * - \ref SCIP_STAGE_TRANSFORMING
1792 * - \ref SCIP_STAGE_TRANSFORMED
1793 * - \ref SCIP_STAGE_INITPRESOLVE
1794 * - \ref SCIP_STAGE_PRESOLVING
1795 * - \ref SCIP_STAGE_EXITPRESOLVE
1796 * - \ref SCIP_STAGE_PRESOLVED
1797 * - \ref SCIP_STAGE_INITSOLVE
1798 * - \ref SCIP_STAGE_SOLVING
1799 * - \ref SCIP_STAGE_SOLVED
1800 * - \ref SCIP_STAGE_EXITSOLVE
1801 * - \ref SCIP_STAGE_FREETRANS
1802 */
1804 SCIP* scip, /**< SCIP data structure */
1805 SCIP_SOL* sol, /**< primal solution, or NULL for current LP/pseudo solution */
1806 SCIP_VAR* var, /**< variable to get value for */
1807 SCIP_RATIONAL* res /**< resulting rational */
1808 )
1809{
1810 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetSolValExact", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
1811
1812 assert( var->scip == scip );
1813 assert(sol == NULL || sol->scip == scip);
1814
1815 if( sol != NULL )
1816 {
1817 SCIPsolGetValExact(res, sol, scip->set, scip->stat, var);
1818 }
1819 else
1820 {
1821 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetSolValExact(sol==NULL)", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1822
1824 }
1825}
1826
1827/** gets values of multiple variables in primal CIP solution
1828 *
1829 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1830 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1831 *
1832 * @pre This method can be called if SCIP is in one of the following stages:
1833 * - \ref SCIP_STAGE_PROBLEM
1834 * - \ref SCIP_STAGE_TRANSFORMING
1835 * - \ref SCIP_STAGE_TRANSFORMED
1836 * - \ref SCIP_STAGE_INITPRESOLVE
1837 * - \ref SCIP_STAGE_PRESOLVING
1838 * - \ref SCIP_STAGE_EXITPRESOLVE
1839 * - \ref SCIP_STAGE_PRESOLVED
1840 * - \ref SCIP_STAGE_INITSOLVE
1841 * - \ref SCIP_STAGE_SOLVING
1842 * - \ref SCIP_STAGE_SOLVED
1843 * - \ref SCIP_STAGE_EXITSOLVE
1844 * - \ref SCIP_STAGE_FREETRANS
1845 */
1847 SCIP* scip, /**< SCIP data structure */
1848 SCIP_SOL* sol, /**< primal solution, or NULL for current LP/pseudo solution */
1849 int nvars, /**< number of variables to get solution value for */
1850 SCIP_VAR** vars, /**< array with variables to get value for */
1851 SCIP_Real* vals /**< array to store solution values of variables */
1852 )
1853{
1854 assert(nvars == 0 || vars != NULL);
1855 assert(nvars == 0 || vals != NULL);
1856
1857 SCIP_CALL( SCIPcheckStage(scip, "SCIPgetSolVals", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
1858
1859 if( sol != NULL )
1860 {
1861 int v;
1862
1863 for( v = 0; v < nvars; ++v )
1864 vals[v] = SCIPsolGetVal(sol, scip->set, scip->stat, vars[v]);
1865 }
1866 else
1867 {
1868 SCIP_CALL( SCIPgetVarSols(scip, nvars, vars, vals) );
1869 }
1870
1871 return SCIP_OKAY;
1872}
1873
1874/** returns objective value of primal CIP solution w.r.t. original problem, or current LP/pseudo objective value
1875 *
1876 * @return objective value of primal CIP solution w.r.t. original problem, or current LP/pseudo objective value
1877 *
1878 * @pre This method can be called if SCIP is in one of the following stages:
1879 * - \ref SCIP_STAGE_PROBLEM
1880 * - \ref SCIP_STAGE_TRANSFORMING
1881 * - \ref SCIP_STAGE_TRANSFORMED
1882 * - \ref SCIP_STAGE_INITPRESOLVE
1883 * - \ref SCIP_STAGE_PRESOLVING
1884 * - \ref SCIP_STAGE_EXITPRESOLVE
1885 * - \ref SCIP_STAGE_PRESOLVED
1886 * - \ref SCIP_STAGE_INITSOLVE
1887 * - \ref SCIP_STAGE_SOLVING
1888 * - \ref SCIP_STAGE_SOLVED
1889 * - \ref SCIP_STAGE_EXITSOLVE
1890 * - \ref SCIP_STAGE_FREETRANS
1891 */
1893 SCIP* scip, /**< SCIP data structure */
1894 SCIP_SOL* sol /**< primal solution, or NULL for current LP/pseudo objective value */
1895 )
1896{
1897 assert(sol == NULL || sol->scip == scip);
1898
1899 /* for original solutions, an original objective value is already available in SCIP_STAGE_PROBLEM
1900 * for all other solutions, we should be at least in SCIP_STAGE_TRANSFORMING
1901 */
1902 if( sol != NULL && SCIPsolIsOriginal(sol) )
1903 {
1904 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetSolOrigObj", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
1905
1906 return SCIPsolGetOrigObj(sol);
1907 }
1908
1909 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetSolOrigObj", FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
1910
1911 if( sol != NULL )
1912 return SCIPprobExternObjval(scip->transprob, scip->origprob, scip->set, SCIPsolGetObj(sol, scip->set, scip->transprob, scip->origprob));
1913 else
1914 {
1915 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetSolOrigObj(sol==NULL)", \
1917 if( SCIPtreeHasCurrentNodeLP(scip->tree) )
1918 return SCIPprobExternObjval(scip->transprob, scip->origprob, scip->set, SCIPlpGetObjval(scip->lp, scip->set, scip->transprob));
1919 else
1920 return SCIPprobExternObjval(scip->transprob, scip->origprob, scip->set, SCIPlpGetPseudoObjval(scip->lp, scip->set, scip->transprob));
1921 }
1922}
1923
1924/** gets exact objective value of primal CIP solution w.r.t. original problem, or current LP/pseudo objective value
1925 *
1926 * @pre This method can be called if SCIP is in one of the following stages:
1927 * - \ref SCIP_STAGE_PROBLEM
1928 * - \ref SCIP_STAGE_TRANSFORMING
1929 * - \ref SCIP_STAGE_TRANSFORMED
1930 * - \ref SCIP_STAGE_INITPRESOLVE
1931 * - \ref SCIP_STAGE_PRESOLVING
1932 * - \ref SCIP_STAGE_EXITPRESOLVE
1933 * - \ref SCIP_STAGE_PRESOLVED
1934 * - \ref SCIP_STAGE_INITSOLVE
1935 * - \ref SCIP_STAGE_SOLVING
1936 * - \ref SCIP_STAGE_SOLVED
1937 * - \ref SCIP_STAGE_EXITSOLVE
1938 * - \ref SCIP_STAGE_FREETRANS
1939 */
1941 SCIP* scip, /**< SCIP data structure */
1942 SCIP_SOL* sol, /**< primal solution, or NULL for current LP/pseudo objective value */
1943 SCIP_RATIONAL* res /**< result pointer to store rational */
1944 )
1945{
1946 SCIP_RATIONAL* tmp;
1947
1948 assert(sol == NULL || sol->scip == scip);
1949 assert(SCIPsolIsExact(sol));
1950
1951 /* for original solutions, an original objective value is already available in SCIP_STAGE_PROBLEM
1952 * for all other solutions, we should be at least in SCIP_STAGE_TRANSFORMING
1953 */
1954 if( sol != NULL && SCIPsolIsOriginal(sol) )
1955 {
1956 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetSolOrigObjExact", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
1957
1959 return;
1960 }
1961
1962 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetSolOrigObjExact", FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
1963
1965 if( sol != NULL )
1966 {
1967 SCIPsolGetObjExact(sol, scip->set, scip->transprob, scip->origprob, tmp);
1968 SCIPprobExternObjvalExact(scip->transprob, scip->origprob, scip->set, tmp, res);
1969 }
1970 else
1971 {
1972 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetSolOrigObjExact(sol==NULL)", \
1974 if( SCIPtreeHasCurrentNodeLP(scip->tree) )
1975 {
1976 SCIPlpExactGetObjval(scip->lpexact, scip->set, tmp);
1977 SCIPprobExternObjvalExact(scip->transprob, scip->origprob, scip->set, tmp, res);
1978 }
1979 else
1980 {
1981 SCIPlpExactGetPseudoObjval(scip->lpexact, scip->set, tmp);
1982 SCIPprobExternObjvalExact(scip->transprob, scip->origprob, scip->set, tmp, res);
1983 }
1984 }
1986}
1987
1988/** returns transformed objective value of primal CIP solution, or transformed current LP/pseudo objective value
1989 *
1990 * @return transformed objective value of primal CIP solution, or transformed current LP/pseudo objective value
1991 *
1992 * @pre This method can be called if SCIP is in one of the following stages:
1993 * - \ref SCIP_STAGE_TRANSFORMING
1994 * - \ref SCIP_STAGE_TRANSFORMED
1995 * - \ref SCIP_STAGE_INITPRESOLVE
1996 * - \ref SCIP_STAGE_PRESOLVING
1997 * - \ref SCIP_STAGE_EXITPRESOLVE
1998 * - \ref SCIP_STAGE_PRESOLVED
1999 * - \ref SCIP_STAGE_INITSOLVE
2000 * - \ref SCIP_STAGE_SOLVING
2001 * - \ref SCIP_STAGE_SOLVED
2002 * - \ref SCIP_STAGE_EXITSOLVE
2003 * - \ref SCIP_STAGE_FREETRANS
2004 */
2006 SCIP* scip, /**< SCIP data structure */
2007 SCIP_SOL* sol /**< primal solution, or NULL for current LP/pseudo objective value */
2008 )
2009{
2010 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetSolTransObj", FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
2011
2012 assert(sol == NULL || sol->scip == scip);
2013
2014 if( sol != NULL )
2015 return SCIPsolGetObj(sol, scip->set, scip->transprob, scip->origprob);
2016 else
2017 {
2018 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetSolTransObj(sol==NULL)", \
2020 if( SCIPtreeHasCurrentNodeLP(scip->tree) )
2021 return SCIPlpGetObjval(scip->lp, scip->set, scip->transprob);
2022 else
2023 return SCIPlpGetPseudoObjval(scip->lp, scip->set, scip->transprob);
2024 }
2025}
2026
2027/** gets exact transformed objective value of primal CIP solution, or transformed current exact LP/pseudo objective value
2028 *
2029 * @pre This method can be called if SCIP is in one of the following stages:
2030 * - \ref SCIP_STAGE _TRANSFORMING
2031 * - \ref SCIP_STAGE_TRANSFORMED
2032 * - \ref SCIP_STAGE_INITPRESOLVE
2033 * - \ref SCIP_STAGE_PRESOLVING
2034 * - \ref SCIP_STAGE_EXITPRESOLVE
2035 * - \ref SCIP_STAGE_PRESOLVED
2036 * - \ref SCIP_STAGE_INITSOLVE
2037 * - \ref SCIP_STAGE_SOLVING
2038 * - \ref SCIP_STAGE_SOLVED
2039 * - \ref SCIP_STAGE_EXITSOLVE
2040 * - \ref SCIP_STAGE_FREETRANS
2041 */
2043 SCIP* scip, /**< SCIP data structure */
2044 SCIP_SOL* sol, /**< primal solution, or NULL for current LP/pseudo objective value */
2045 SCIP_RATIONAL* res /**< result pointer to store rational */
2046 )
2047{
2048 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetSolTransObjExact", FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
2049
2050 assert(sol == NULL || sol->scip == scip);
2051
2052 if( sol != NULL )
2053 SCIPsolGetObjExact(sol, scip->set, scip->transprob, scip->origprob, res);
2054 else
2055 {
2056 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetSolTransObjExact(sol==NULL)", \
2058 if( SCIPtreeHasCurrentNodeLP(scip->tree) )
2059 SCIPlpExactGetObjval(scip->lpexact, scip->set, res);
2060 else
2061 SCIPlpExactGetPseudoObjval(scip->lpexact, scip->set, res);
2062 }
2063}
2064
2065/** recomputes the objective value of an original solution, e.g., when transferring solutions
2066 * from the solution pool (objective coefficients might have changed in the meantime)
2067 *
2068 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2069 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2070 *
2071 * @pre This method can be called if SCIP is in one of the following stages:
2072 * - \ref SCIP_STAGE_PRESOLVING
2073 * - \ref SCIP_STAGE_SOLVING
2074 *
2075 */
2077 SCIP* scip,
2078 SCIP_SOL* sol
2079 )
2080{
2081 assert(scip != NULL);
2082 assert(sol != NULL);
2083 assert(sol->scip == scip);
2084
2085 SCIP_CALL( SCIPcheckStage(scip, "SCIPrecomputeSolObj", FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
2086
2087 SCIPsolRecomputeObj(sol, scip->set, scip->stat, scip->origprob);
2088
2089 return SCIP_OKAY;
2090}
2091
2092/** maps original space objective value into transformed objective value
2093 *
2094 * @return transformed objective value
2095 *
2096 * @pre This method can be called if SCIP is in one of the following stages:
2097 * - \ref SCIP_STAGE_TRANSFORMING
2098 * - \ref SCIP_STAGE_TRANSFORMED
2099 * - \ref SCIP_STAGE_INITPRESOLVE
2100 * - \ref SCIP_STAGE_PRESOLVING
2101 * - \ref SCIP_STAGE_EXITPRESOLVE
2102 * - \ref SCIP_STAGE_PRESOLVED
2103 * - \ref SCIP_STAGE_INITSOLVE
2104 * - \ref SCIP_STAGE_SOLVING
2105 * - \ref SCIP_STAGE_SOLVED
2106 */
2108 SCIP* scip, /**< SCIP data structure */
2109 SCIP_Real obj /**< original space objective value to transform */
2110 )
2111{
2113
2114 return SCIPprobInternObjval(scip->transprob, scip->origprob, scip->set, obj);
2115}
2116
2117/** maps transformed objective value into original space
2118 *
2119 * @return objective value into original space
2120 *
2121 * @pre This method can be called if SCIP is in one of the following stages:
2122 * - \ref SCIP_STAGE_TRANSFORMING
2123 * - \ref SCIP_STAGE_TRANSFORMED
2124 * - \ref SCIP_STAGE_INITPRESOLVE
2125 * - \ref SCIP_STAGE_PRESOLVING
2126 * - \ref SCIP_STAGE_EXITPRESOLVE
2127 * - \ref SCIP_STAGE_PRESOLVED
2128 * - \ref SCIP_STAGE_INITSOLVE
2129 * - \ref SCIP_STAGE_SOLVING
2130 * - \ref SCIP_STAGE_SOLVED
2131 */
2133 SCIP* scip, /**< SCIP data structure */
2134 SCIP_Real obj /**< transformed objective value to retransform in original space */
2135 )
2136{
2137 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPretransformObj", FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
2138
2139 return SCIPprobExternObjval(scip->transprob, scip->origprob, scip->set, obj);
2140}
2141
2142/** gets clock time, when this solution was found
2143 *
2144 * @return clock time, when this solution was found
2145 *
2146 * @pre This method can be called if SCIP is in one of the following stages:
2147 * - \ref SCIP_STAGE_TRANSFORMING
2148 * - \ref SCIP_STAGE_TRANSFORMED
2149 * - \ref SCIP_STAGE_INITPRESOLVE
2150 * - \ref SCIP_STAGE_PRESOLVING
2151 * - \ref SCIP_STAGE_EXITPRESOLVE
2152 * - \ref SCIP_STAGE_PRESOLVED
2153 * - \ref SCIP_STAGE_INITSOLVE
2154 * - \ref SCIP_STAGE_SOLVING
2155 * - \ref SCIP_STAGE_SOLVED
2156 * - \ref SCIP_STAGE_EXITSOLVE
2157 * - \ref SCIP_STAGE_FREETRANS
2158 */
2160 SCIP* scip, /**< SCIP data structure */
2161 SCIP_SOL* sol /**< primal solution */
2162 )
2163{
2165
2166 assert(sol != NULL);
2167 assert(sol->scip == scip);
2168
2169 return SCIPsolGetTime(sol);
2170}
2171
2172/** gets branch and bound run number, where this solution was found
2173 *
2174 * @return branch and bound run number, where this solution was found
2175 *
2176 * @pre This method can be called if SCIP is in one of the following stages:
2177 * - \ref SCIP_STAGE_TRANSFORMING
2178 * - \ref SCIP_STAGE_TRANSFORMED
2179 * - \ref SCIP_STAGE_INITPRESOLVE
2180 * - \ref SCIP_STAGE_PRESOLVING
2181 * - \ref SCIP_STAGE_EXITPRESOLVE
2182 * - \ref SCIP_STAGE_PRESOLVED
2183 * - \ref SCIP_STAGE_INITSOLVE
2184 * - \ref SCIP_STAGE_SOLVING
2185 * - \ref SCIP_STAGE_SOLVED
2186 * - \ref SCIP_STAGE_EXITSOLVE
2187 * - \ref SCIP_STAGE_FREETRANS
2188 */
2190 SCIP* scip, /**< SCIP data structure */
2191 SCIP_SOL* sol /**< primal solution */
2192 )
2193{
2195
2196 assert(sol != NULL);
2197 assert(sol->scip == scip);
2198
2199 return SCIPsolGetRunnum(sol);
2200}
2201
2202/** gets node number of the specific branch and bound run, where this solution was found
2203 *
2204 * @return node number of the specific branch and bound run, where this solution was found
2205 *
2206 * @pre This method can be called if SCIP is in one of the following stages:
2207 * - \ref SCIP_STAGE_TRANSFORMING
2208 * - \ref SCIP_STAGE_TRANSFORMED
2209 * - \ref SCIP_STAGE_INITPRESOLVE
2210 * - \ref SCIP_STAGE_PRESOLVING
2211 * - \ref SCIP_STAGE_EXITPRESOLVE
2212 * - \ref SCIP_STAGE_PRESOLVED
2213 * - \ref SCIP_STAGE_INITSOLVE
2214 * - \ref SCIP_STAGE_SOLVING
2215 * - \ref SCIP_STAGE_SOLVED
2216 * - \ref SCIP_STAGE_EXITSOLVE
2217 * - \ref SCIP_STAGE_FREETRANS
2218 */
2220 SCIP* scip, /**< SCIP data structure */
2221 SCIP_SOL* sol /**< primal solution */
2222 )
2223{
2224 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetSolNodenum", FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
2225
2226 assert(sol != NULL);
2227 assert(sol->scip == scip);
2228
2229 return SCIPsolGetNodenum(sol);
2230}
2231
2232/** gets heuristic, that found this solution (or NULL if it's from the tree)
2233 *
2234 * @return heuristic, that found this solution (or NULL if it's from the tree)
2235 *
2236 * @pre This method can be called if SCIP is in one of the following stages:
2237 * - \ref SCIP_STAGE_TRANSFORMING
2238 * - \ref SCIP_STAGE_TRANSFORMED
2239 * - \ref SCIP_STAGE_INITPRESOLVE
2240 * - \ref SCIP_STAGE_PRESOLVING
2241 * - \ref SCIP_STAGE_EXITPRESOLVE
2242 * - \ref SCIP_STAGE_PRESOLVED
2243 * - \ref SCIP_STAGE_INITSOLVE
2244 * - \ref SCIP_STAGE_SOLVING
2245 * - \ref SCIP_STAGE_SOLVED
2246 * - \ref SCIP_STAGE_EXITSOLVE
2247 * - \ref SCIP_STAGE_FREETRANS
2248 */
2250 SCIP* scip, /**< SCIP data structure */
2251 SCIP_SOL* sol /**< primal solution */
2252 )
2253{
2255
2256 assert(sol != NULL);
2257 assert(sol->scip == scip);
2258
2259 return SCIPsolGetHeur(sol);
2260}
2261
2262/** returns whether two given solutions are exactly equal
2263 *
2264 * @return returns whether two given solutions are exactly equal
2265 *
2266 * @pre This method can be called if SCIP is in one of the following stages:
2267 * - \ref SCIP_STAGE_PROBLEM
2268 * - \ref SCIP_STAGE_TRANSFORMING
2269 * - \ref SCIP_STAGE_TRANSFORMED
2270 * - \ref SCIP_STAGE_INITPRESOLVE
2271 * - \ref SCIP_STAGE_PRESOLVING
2272 * - \ref SCIP_STAGE_EXITPRESOLVE
2273 * - \ref SCIP_STAGE_PRESOLVED
2274 * - \ref SCIP_STAGE_INITSOLVE
2275 * - \ref SCIP_STAGE_SOLVING
2276 * - \ref SCIP_STAGE_SOLVED
2277 * - \ref SCIP_STAGE_EXITSOLVE
2278 * - \ref SCIP_STAGE_FREETRANS
2279 */
2281 SCIP* scip, /**< SCIP data structure */
2282 SCIP_SOL* sol1, /**< first primal CIP solution */
2283 SCIP_SOL* sol2 /**< second primal CIP solution */
2284 )
2285{
2286 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPareSolsEqual", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
2287
2288 assert(sol1 != NULL);
2289 assert(sol2 != NULL);
2290 assert(sol1->scip == scip);
2291 assert(sol2->scip == scip);
2292
2293 return SCIPsolsAreEqual(sol1, sol2, scip->set, scip->stat, scip->origprob, scip->transprob);
2294}
2295
2296/** adjusts solution values of implied integral variables in handed solution, solution objective value is not
2297 * deteriorated by this method
2298 *
2299 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2300 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2301 *
2302 * @pre This method can be called if SCIP is in one of the following stages:
2303 * - \ref SCIP_STAGE_SOLVING
2304 */
2306 SCIP* scip, /**< SCIP data structure */
2307 SCIP_SOL* sol, /**< primal CIP solution */
2308 SCIP_Bool uselprows /**< should LP row information be considered for none-objective variables */
2309 )
2310{
2311 assert(scip != NULL);
2312 SCIP_CALL( SCIPcheckStage(scip, "SCIPadjustImplicitSolVals", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
2313
2314 assert(sol != NULL);
2315 assert(sol->scip == scip);
2316 SCIP_CALL( SCIPsolAdjustImplicitSolVals(sol, scip->set, scip->stat, scip->transprob, scip->tree, uselprows) );
2317
2318 return SCIP_OKAY;
2319}
2320
2321/** outputs non-zero variables of solution in original problem space to the given file stream
2322 *
2323 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2324 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2325 *
2326 * @pre In case the solution pointer @p sol is NULL (asking for the current LP/pseudo solution), this method can be
2327 * called if @p scip is in one of the following stages:
2328 * - \ref SCIP_STAGE_PRESOLVING
2329 * - \ref SCIP_STAGE_EXITPRESOLVE
2330 * - \ref SCIP_STAGE_PRESOLVED
2331 * - \ref SCIP_STAGE_INITSOLVE
2332 * - \ref SCIP_STAGE_SOLVING
2333 * - \ref SCIP_STAGE_SOLVED
2334 * - \ref SCIP_STAGE_EXITSOLVE
2335 *
2336 * @pre In case the solution pointer @p sol is @b not NULL, this method can be called if @p scip is in one of the
2337 * following stages:
2338 * - \ref SCIP_STAGE_PROBLEM
2339 * - \ref SCIP_STAGE_TRANSFORMED
2340 * - \ref SCIP_STAGE_INITPRESOLVE
2341 * - \ref SCIP_STAGE_PRESOLVING
2342 * - \ref SCIP_STAGE_EXITPRESOLVE
2343 * - \ref SCIP_STAGE_PRESOLVED
2344 * - \ref SCIP_STAGE_INITSOLVE
2345 * - \ref SCIP_STAGE_SOLVING
2346 * - \ref SCIP_STAGE_SOLVED
2347 * - \ref SCIP_STAGE_EXITSOLVE
2348 */
2350 SCIP* scip, /**< SCIP data structure */
2351 SCIP_SOL* sol, /**< primal solution, or NULL for current LP/pseudo solution */
2352 FILE* file, /**< output file (or NULL for standard output) */
2353 SCIP_Bool printzeros /**< should variables set to zero be printed? */
2354 )
2355{
2356 SCIP_Real objval;
2357 SCIP_Bool currentsol;
2358 SCIP_Bool oldquiet = FALSE;
2359
2360 assert(SCIPisTransformed(scip) || sol != NULL);
2361 assert(sol == NULL || sol->scip == scip);
2362
2364
2365 currentsol = (sol == NULL);
2366
2367 if( currentsol ? SCIPisExact(scip) : SCIPsolIsExact(sol) )
2368 {
2369 SCIP_CALL( SCIPprintSolExact(scip, sol, file, printzeros) );
2370 return SCIP_OKAY;
2371 }
2372
2373 if( currentsol )
2374 {
2375 SCIP_CALL( SCIPcheckStage(scip, "SCIPprintSol(sol==NULL)", \
2377
2378 /* create a temporary solution that is linked to the current solution */
2379 SCIP_CALL( SCIPsolCreateCurrentSol(&sol, scip->mem->probmem, scip->set, scip->stat, scip->transprob, scip->primal,
2380 scip->tree, scip->lp, NULL) );
2381 }
2382
2383 if( file != NULL && scip->messagehdlr != NULL )
2384 {
2385 oldquiet = SCIPmessagehdlrIsQuiet(scip->messagehdlr);
2386 SCIPmessagehdlrSetQuiet(scip->messagehdlr, FALSE);
2387 }
2388
2389 SCIPmessageFPrintInfo(scip->messagehdlr, file, "objective value: ");
2390
2391 if( SCIPsolIsPartial(sol) )
2392 {
2393 SCIPmessageFPrintInfo(scip->messagehdlr, file, "unknown\n");
2394 }
2395 else
2396 {
2397 if( SCIPsolIsOriginal(sol) )
2398 objval = SCIPsolGetOrigObj(sol);
2399 else
2400 objval = SCIPprobExternObjval(scip->transprob, scip->origprob, scip->set, SCIPsolGetObj(sol, scip->set, scip->transprob, scip->origprob));
2401
2402 SCIPprintReal(scip, file, objval, 20, 15);
2403 SCIPmessageFPrintInfo(scip->messagehdlr, file, "\n");
2404 }
2405
2406 SCIP_CALL( SCIPsolPrint(sol, scip->set, scip->messagehdlr, scip->stat, scip->origprob, scip->transprob, file, FALSE,
2407 printzeros) );
2408
2409 if( file != NULL && scip->messagehdlr != NULL )
2410 {
2411 SCIPmessagehdlrSetQuiet(scip->messagehdlr, oldquiet);
2412 }
2413
2414 if( currentsol )
2415 {
2416 /* free temporary solution */
2417 SCIP_CALL( SCIPsolFree(&sol, scip->mem->probmem, scip->primal) );
2418 }
2419
2420 return SCIP_OKAY;
2421}
2422
2423/** print an exact solution */
2425 SCIP* scip, /**< SCIP data structure */
2426 SCIP_SOL* sol, /**< primal solution, or NULL for current LP/pseudo solution */
2427 FILE* file, /**< output file (or NULL for standard output) */
2428 SCIP_Bool printzeros /**< should variables set to zero be printed? */
2429 )
2430{
2431 SCIP_RATIONAL* objval;
2432 SCIP_RATIONAL* tmp;
2433 SCIP_Bool currentsol;
2434 SCIP_Bool oldquiet = FALSE;
2435 char* objvalstr;
2436 int objvalsize;
2437
2438 assert(SCIPisTransformed(scip) || sol != NULL);
2439 assert(sol == NULL || sol->scip == scip);
2440
2441 SCIP_CALL( SCIPcheckStage(scip, "SCIPprintSolExact", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE) );
2442
2443 currentsol = (sol == NULL);
2444 if( currentsol )
2445 {
2446 SCIP_CALL( SCIPcheckStage(scip, "SCIPprintSolExact(sol==NULL)", \
2448
2449 /* create a temporary solution that is linked to the current solution */
2450 SCIP_CALL( SCIPsolCreateCurrentSolExact(&sol, scip->mem->probmem, scip->set, scip->stat, scip->primal,
2451 scip->tree, scip->lpexact, NULL) );
2452 }
2453
2454 if( file != NULL && scip->messagehdlr != NULL )
2455 {
2456 oldquiet = SCIPmessagehdlrIsQuiet(scip->messagehdlr);
2457 SCIPmessagehdlrSetQuiet(scip->messagehdlr, FALSE);
2458 }
2459
2460 SCIPmessageFPrintInfo(scip->messagehdlr, file, "objective value: ");
2461
2462 if( SCIPsolIsPartial(sol) )
2463 {
2464 SCIPmessageFPrintInfo(scip->messagehdlr, file, "unknown\n");
2465 }
2466 else
2467 {
2469
2470 if( SCIPsolIsOriginal(sol) )
2472 else
2473 {
2475 SCIPsolGetObjExact(sol, scip->set, scip->transprob, scip->origprob, tmp);
2476 SCIPprobExternObjvalExact(scip->transprob, scip->origprob, scip->set, tmp, objval);
2478 }
2479
2480 objvalsize = SCIPrationalStrLen(objval) + 1;
2481 SCIP_CALL( SCIPallocBufferArray(scip, &objvalstr, objvalsize) );
2482 (void)SCIPrationalToString(objval, objvalstr, objvalsize);
2483 SCIPmessageFPrintInfo(scip->messagehdlr, file, "%20s\n", objvalstr);
2484 SCIPfreeBufferArray(scip, &objvalstr);
2486 }
2487
2488 SCIP_CALL( SCIPsolPrintExact(sol, scip->set, scip->messagehdlr, scip->stat, scip->origprob, scip->transprob, file, FALSE,
2489 printzeros) );
2490
2491 if( file != NULL && scip->messagehdlr != NULL )
2492 {
2493 SCIPmessagehdlrSetQuiet(scip->messagehdlr, oldquiet);
2494 }
2495
2496 if( currentsol )
2497 {
2498 /* free temporary solution */
2499 SCIP_CALL( SCIPsolFree(&sol, scip->mem->probmem, scip->primal) );
2500 }
2501
2502 return SCIP_OKAY;
2503}
2504
2505/** outputs non-zero variables of solution in transformed problem space to file stream
2506 *
2507 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2508 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2509 *
2510 * @pre This method can be called if SCIP is in one of the following stages:
2511 * - \ref SCIP_STAGE_TRANSFORMED
2512 * - \ref SCIP_STAGE_INITPRESOLVE
2513 * - \ref SCIP_STAGE_PRESOLVING
2514 * - \ref SCIP_STAGE_EXITPRESOLVE
2515 * - \ref SCIP_STAGE_PRESOLVED
2516 * - \ref SCIP_STAGE_INITSOLVE
2517 * - \ref SCIP_STAGE_SOLVING
2518 * - \ref SCIP_STAGE_SOLVED
2519 * - \ref SCIP_STAGE_EXITSOLVE
2520 */
2522 SCIP* scip, /**< SCIP data structure */
2523 SCIP_SOL* sol, /**< primal solution, or NULL for current LP/pseudo solution */
2524 FILE* file, /**< output file (or NULL for standard output) */
2525 SCIP_Bool printzeros /**< should variables set to zero be printed? */
2526 )
2527{
2528 SCIP_Bool currentsol;
2529
2530 SCIP_CALL( SCIPcheckStage(scip, "SCIPprintTransSol", FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE) );
2531
2532 assert(sol == NULL || sol->scip == scip);
2533
2534 currentsol = (sol == NULL);
2535 if( currentsol )
2536 {
2537 /* create a temporary solution that is linked to the current solution */
2538 SCIP_CALL( SCIPsolCreateCurrentSol(&sol, scip->mem->probmem, scip->set, scip->stat, scip->transprob, scip->primal,
2539 scip->tree, scip->lp, NULL) );
2540 }
2541
2542 if( SCIPsolIsOriginal(sol) )
2543 {
2544 SCIPerrorMessage("cannot print original space solution as transformed solution\n");
2545 return SCIP_INVALIDCALL;
2546 }
2547
2548 SCIPmessageFPrintInfo(scip->messagehdlr, file, "objective value: ");
2549 SCIPprintReal(scip, file, SCIPsolGetObj(sol, scip->set, scip->transprob, scip->origprob), 20, 9);
2550 SCIPmessageFPrintInfo(scip->messagehdlr, file, "\n");
2551
2552 SCIP_CALL( SCIPsolPrint(sol, scip->set, scip->messagehdlr, scip->stat, scip->transprob, NULL, file, FALSE, printzeros) );
2553
2554 if( currentsol )
2555 {
2556 /* free temporary solution */
2557 SCIP_CALL( SCIPsolFree(&sol, scip->mem->probmem, scip->primal) );
2558 }
2559
2560 return SCIP_OKAY;
2561}
2562
2563/** outputs discrete variables of solution in original problem space to the given file stream
2564 *
2565 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2566 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2567 *
2568 * @pre This method can be called if @p scip is in one of the following stages:
2569 * - \ref SCIP_STAGE_PROBLEM
2570 * - \ref SCIP_STAGE_TRANSFORMED
2571 * - \ref SCIP_STAGE_INITPRESOLVE
2572 * - \ref SCIP_STAGE_PRESOLVING
2573 * - \ref SCIP_STAGE_EXITPRESOLVE
2574 * - \ref SCIP_STAGE_PRESOLVED
2575 * - \ref SCIP_STAGE_INITSOLVE
2576 * - \ref SCIP_STAGE_SOLVING
2577 * - \ref SCIP_STAGE_SOLVED
2578 * - \ref SCIP_STAGE_EXITSOLVE
2579 */
2581 SCIP* scip, /**< SCIP data structure */
2582 SCIP_SOL* sol, /**< primal solution */
2583 FILE* file /**< output file (or NULL for standard output) */
2584 )
2585{
2586 SCIP_Real objval;
2587 SCIP_Bool oldquiet = FALSE;
2588
2589 assert(sol != NULL);
2590 assert(sol->scip == scip);
2591 assert(!SCIPsolIsPartial(sol));
2592
2593 SCIP_CALL( SCIPcheckStage(scip, "SCIPprintMIPStart", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE) );
2594
2595 if( file != NULL && scip->messagehdlr != NULL )
2596 {
2597 oldquiet = SCIPmessagehdlrIsQuiet(scip->messagehdlr);
2598 SCIPmessagehdlrSetQuiet(scip->messagehdlr, FALSE);
2599 }
2600
2601 SCIPmessageFPrintInfo(scip->messagehdlr, file, "objective value: ");
2602
2603 if( SCIPsolIsOriginal(sol) )
2604 objval = SCIPsolGetOrigObj(sol);
2605 else
2606 objval = SCIPprobExternObjval(scip->transprob, scip->origprob, scip->set, SCIPsolGetObj(sol, scip->set, scip->transprob, scip->origprob));
2607
2608 SCIPprintReal(scip, file, objval, 20, 15);
2609 SCIPmessageFPrintInfo(scip->messagehdlr, file, "\n");
2610
2611 SCIP_CALL( SCIPsolPrint(sol, scip->set, scip->messagehdlr, scip->stat, scip->origprob, scip->transprob, file, TRUE,
2612 TRUE) );
2613
2614 if( file != NULL && scip->messagehdlr != NULL )
2615 {
2616 SCIPmessagehdlrSetQuiet(scip->messagehdlr, oldquiet);
2617 }
2618
2619 return SCIP_OKAY;
2620}
2621
2622/** returns dual solution value of a constraint */
2624 SCIP* scip, /**< SCIP data structure */
2625 SCIP_CONS* cons, /**< constraint for which the dual solution should be returned */
2626 SCIP_Real* dualsolval, /**< pointer to store the dual solution value */
2627 SCIP_Bool* boundconstraint /**< pointer to store whether the constraint is a bound constraint (or NULL) */
2628 )
2629{
2630 SCIP_CONS* transcons;
2631 int nvars;
2632 SCIP_Bool success;
2633
2634 assert(scip != NULL);
2635 assert(cons != NULL);
2636 assert(dualsolval != NULL);
2637
2638 assert(SCIPconsGetHdlr(cons) != NULL);
2639 assert(strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(cons)), "linear" ) == 0);
2640
2641 SCIP_CALL( SCIPconsGetNVars(cons, scip->set, &nvars, &success) );
2642 assert(success); /* is always successful, since we only have linear constraints */
2643
2644 if( boundconstraint != NULL )
2645 *boundconstraint = (nvars == 1);
2646
2647 if( SCIPconsIsTransformed(cons) )
2648 transcons = cons;
2649 else
2650 transcons = SCIPconsGetTransformed(cons);
2651
2652 /* it can happen that a transformed constraints gets deleted due to redundancy. by complementary slackness the
2653 * corresponding dual solution value would be zero. however, if the constraint contains exactly one variable we need
2654 * to check the reduced costs of the variable.
2655 */
2656 if( nvars == 0 || (nvars > 1 && transcons == NULL) )
2657 (*dualsolval) = 0.0;
2658 else
2659 {
2660 if( nvars > 1 )
2661 (*dualsolval) = SCIPgetDualsolLinear(scip, transcons);
2662 else
2663 {
2664 /* the constraint is a bound constraint */
2665 SCIP_VAR** vars;
2666 SCIP_Real* vals;
2667 SCIP_Real activity;
2668
2669 vars = SCIPgetVarsLinear(scip, cons);
2670 vals = SCIPgetValsLinear(scip, cons);
2671
2672 activity = SCIPvarGetLPSol(vars[0]) * vals[0];
2673
2674 /* return the reduced cost of the variable if the constraint would be tight */
2675 if( SCIPsetIsEQ(scip->set, activity, SCIPgetRhsLinear(scip, cons))
2676 || SCIPsetIsEQ(scip->set, activity, SCIPgetLhsLinear(scip, cons)) )
2677 (*dualsolval) = SCIPgetVarRedcost(scip, vars[0]);
2678 else
2679 (*dualsolval) = 0.0;
2680 }
2681 }
2682 assert(*dualsolval != SCIP_INVALID); /*lint !e777*/
2683
2684 /* dual values are coming from the LP solver that is always solving a minimization problem */
2686 (*dualsolval) *= -1.0;
2687
2688 return SCIP_OKAY;
2689}
2690
2691/** outputs dual solution from LP solver to file stream */
2692static
2694 SCIP* scip, /**< SCIP data structure */
2695 FILE* file, /**< output file (or NULL for standard output) */
2696 SCIP_Bool printzeros /**< should variables set to zero be printed? */
2697 )
2698{
2699 SCIP_Bool boundconstraint;
2700 int c;
2701
2702 assert(scip->lp != NULL);
2703 assert(scip->lp->solved);
2704 assert(scip->lp->dualfeasible);
2705
2706 /* print dual solution values of all constraints */
2707 for( c = 0; c < scip->origprob->nconss; ++c )
2708 {
2709 SCIP_CONS* cons;
2710 SCIP_Real solval;
2711
2712 cons = scip->origprob->conss[c];
2713 assert(cons != NULL);
2714
2715 SCIP_CALL( SCIPgetDualSolVal(scip, cons, &solval, &boundconstraint) );
2716
2717 if( printzeros || !SCIPisZero(scip, solval) )
2718 {
2719 SCIP_MESSAGEHDLR* messagehdlr = scip->messagehdlr;
2720
2721 SCIPmessageFPrintInfo(messagehdlr, file, "%-32s", SCIPconsGetName(cons));
2722
2723 if( SCIPisInfinity(scip, solval) )
2724 SCIPmessageFPrintInfo(messagehdlr, file, " +infinity\n");
2725 else if( SCIPisInfinity(scip, -solval) )
2726 SCIPmessageFPrintInfo(messagehdlr, file, " -infinity\n");
2727 else
2728 {
2729 if( boundconstraint )
2730 SCIPmessageFPrintInfo(messagehdlr, file, " %20.15g*\n", solval);
2731 else
2732 SCIPmessageFPrintInfo(messagehdlr, file, " %20.15g\n", solval);
2733 }
2734 }
2735 }
2736
2737 return SCIP_OKAY;
2738}
2739
2740/** check whether the dual solution is available
2741 *
2742 * @note This is used when calling \ref SCIPprintDualSol()
2743 *
2744 * @return is dual solution available?
2745 *
2746 * @pre This method can be called if SCIP is in one of the following stages:
2747 * - \ref SCIP_STAGE_SOLVED
2748 */
2750 SCIP* scip, /**< SCIP data structure */
2751 SCIP_Bool printreason /**< print warning message if dualsol is not available? */
2752 )
2753{
2754 int c;
2755
2756 assert(scip != NULL);
2757
2758 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPisDualSolAvailable", TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE) );
2759
2761 {
2762 if( printreason )
2763 SCIPmessageFPrintInfo(scip->messagehdlr, NULL, "No dual solution available.\n");
2764 return FALSE;
2765 }
2766
2767 assert(scip->stat != NULL);
2768 assert(scip->transprob != NULL);
2769
2770 /* dual solution only useful when no presolving was performed */
2771 if( scip->stat->performpresol )
2772 {
2773 if( printreason )
2774 SCIPwarningMessage(scip, "No dual information available when presolving was performed.\n");
2775 return FALSE;
2776 }
2777
2778 /* dual solution is created by LP solver and therefore only available for pure LPs */
2779 if( scip->transprob->nvars != scip->transprob->ncontvars )
2780 {
2781 if( printreason )
2782 SCIPwarningMessage(scip, "Dual information only available for pure LPs (only continuous variables).\n");
2783 return FALSE;
2784 }
2785
2786 /* dual solution is created by LP solver and therefore only available for linear constraints */
2787 for( c = scip->transprob->nconss - 1; c >= 0; --c )
2788 {
2789 SCIP_CONSHDLR* conshdlr;
2790
2791 conshdlr = SCIPconsGetHdlr(scip->transprob->conss[c]);
2792 assert(conshdlr != NULL);
2793
2794 if( strcmp(SCIPconshdlrGetName(conshdlr), "linear" ) != 0 )
2795 {
2796 if( printreason )
2797 SCIPwarningMessage(scip, "Dual information only available for pure LPs (only linear constraints).\n");
2798 return FALSE;
2799 }
2800 }
2801
2802 return TRUE;
2803}
2804
2805/** outputs dual solution from LP solver to file stream
2806 *
2807 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2808 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2809 *
2810 * @pre This method can be called in all stages but only prints dual information when called in \ref SCIP_STAGE_SOLVED
2811 */
2813 SCIP* scip, /**< SCIP data structure */
2814 FILE* file, /**< output file (or NULL for standard output) */
2815 SCIP_Bool printzeros /**< should variables set to zero be printed? */
2816 )
2817{
2819 {
2820 /* print dual solution */
2821 SCIP_CALL( printDualSol(scip, file, printzeros) );
2822 }
2823
2824 return SCIP_OKAY;
2825}
2826
2827
2828/** outputs non-zero variables of solution representing a ray in original problem space to file stream
2829 *
2830 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2831 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2832 *
2833 * @pre This method can be called if SCIP is in one of the following stages:
2834 * - \ref SCIP_STAGE_PROBLEM
2835 * - \ref SCIP_STAGE_TRANSFORMED
2836 * - \ref SCIP_STAGE_INITPRESOLVE
2837 * - \ref SCIP_STAGE_PRESOLVING
2838 * - \ref SCIP_STAGE_EXITPRESOLVE
2839 * - \ref SCIP_STAGE_PRESOLVED
2840 * - \ref SCIP_STAGE_INITSOLVE
2841 * - \ref SCIP_STAGE_SOLVING
2842 * - \ref SCIP_STAGE_SOLVED
2843 * - \ref SCIP_STAGE_EXITSOLVE
2844 */
2846 SCIP* scip, /**< SCIP data structure */
2847 SCIP_SOL* sol, /**< primal solution representing ray */
2848 FILE* file, /**< output file (or NULL for standard output) */
2849 SCIP_Bool printzeros /**< should variables set to zero be printed? */
2850 )
2851{
2852 assert(scip != NULL);
2853 assert(sol != NULL);
2854 assert(sol->scip == scip);
2855
2857
2858 SCIP_CALL( SCIPsolPrintRay(sol, scip->set, scip->messagehdlr, scip->stat, scip->origprob, scip->transprob, file, printzeros) );
2859
2860 return SCIP_OKAY;
2861}
2862
2863/** gets number of feasible primal solutions stored in the solution storage in case the problem is transformed;
2864 * in case the problem stage is SCIP_STAGE_PROBLEM, the number of solution in the original solution candidate
2865 * storage is returned
2866 *
2867 * @return number of feasible primal solutions stored in the solution storage in case the problem is transformed; or
2868 * number of solution in the original solution candidate storage if the problem stage is SCIP_STAGE_PROBLEM
2869 *
2870 * @pre This method can be called if SCIP is in one of the following stages:
2871 * - \ref SCIP_STAGE_PROBLEM
2872 * - \ref SCIP_STAGE_TRANSFORMED
2873 * - \ref SCIP_STAGE_INITPRESOLVE
2874 * - \ref SCIP_STAGE_PRESOLVING
2875 * - \ref SCIP_STAGE_EXITPRESOLVE
2876 * - \ref SCIP_STAGE_PRESOLVED
2877 * - \ref SCIP_STAGE_INITSOLVE
2878 * - \ref SCIP_STAGE_SOLVING
2879 * - \ref SCIP_STAGE_SOLVED
2880 * - \ref SCIP_STAGE_EXITSOLVE
2881 */
2883 SCIP* scip /**< SCIP data structure */
2884 )
2885{
2887
2888 switch( scip->set->stage )
2889 {
2890 case SCIP_STAGE_PROBLEM:
2891 return scip->origprimal->nsols;
2892
2899 case SCIP_STAGE_SOLVING:
2900 case SCIP_STAGE_SOLVED:
2902 return scip->primal->nsols;
2903
2904 case SCIP_STAGE_INIT:
2907 default:
2908 SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
2909 SCIPABORT();
2910 return -1; /*lint !e527*/
2911 } /*lint !e788*/
2912}
2913
2914/** gets array of feasible primal solutions stored in the solution storage in case the problem is transformed; in case
2915 * if the problem stage is in SCIP_STAGE_PROBLEM, it returns the number array of solution candidate stored
2916 *
2917 * @return array of feasible primal solutions
2918 *
2919 * @pre This method can be called if SCIP is in one of the following stages:
2920 * - \ref SCIP_STAGE_PROBLEM
2921 * - \ref SCIP_STAGE_TRANSFORMED
2922 * - \ref SCIP_STAGE_INITPRESOLVE
2923 * - \ref SCIP_STAGE_PRESOLVING
2924 * - \ref SCIP_STAGE_EXITPRESOLVE
2925 * - \ref SCIP_STAGE_PRESOLVED
2926 * - \ref SCIP_STAGE_INITSOLVE
2927 * - \ref SCIP_STAGE_SOLVING
2928 * - \ref SCIP_STAGE_SOLVED
2929 * - \ref SCIP_STAGE_EXITSOLVE
2930 */
2932 SCIP* scip /**< SCIP data structure */
2933 )
2934{
2936
2937 switch( scip->set->stage )
2938 {
2939 case SCIP_STAGE_PROBLEM:
2940 return scip->origprimal->sols;
2941
2948 case SCIP_STAGE_SOLVING:
2949 case SCIP_STAGE_SOLVED:
2951 return scip->primal->sols;
2952
2953 case SCIP_STAGE_INIT:
2956 case SCIP_STAGE_FREE:
2957 default:
2958 SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
2959 return NULL;
2960 } /*lint !e788*/
2961}
2962
2963/** gets best feasible primal solution found so far if the problem is transformed; in case the problem is in
2964 * SCIP_STAGE_PROBLEM it returns the best solution candidate, or NULL if no solution has been found or the candidate
2965 * store is empty;
2966 *
2967 * @return best feasible primal solution so far
2968 *
2969 * @pre This method can be called if SCIP is in one of the following stages:
2970 * - \ref SCIP_STAGE_PROBLEM
2971 * - \ref SCIP_STAGE_TRANSFORMED
2972 * - \ref SCIP_STAGE_INITPRESOLVE
2973 * - \ref SCIP_STAGE_PRESOLVING
2974 * - \ref SCIP_STAGE_EXITPRESOLVE
2975 * - \ref SCIP_STAGE_PRESOLVED
2976 * - \ref SCIP_STAGE_INITSOLVE
2977 * - \ref SCIP_STAGE_SOLVING
2978 * - \ref SCIP_STAGE_SOLVED
2979 * - \ref SCIP_STAGE_EXITSOLVE
2980 */
2982 SCIP* scip /**< SCIP data structure */
2983 )
2984{
2986 switch( scip->set->stage )
2987 {
2988 case SCIP_STAGE_INIT:
2989 return NULL;
2990 case SCIP_STAGE_PROBLEM:
2991 assert(scip->origprimal != NULL);
2992 if( scip->origprimal->nsols > 0 )
2993 {
2994 assert(scip->origprimal->sols != NULL);
2995 assert(scip->origprimal->sols[0] != NULL);
2996 return scip->origprimal->sols[0];
2997 }
2998 break;
2999
3006 case SCIP_STAGE_SOLVING:
3007 case SCIP_STAGE_SOLVED:
3009 assert(scip->primal != NULL);
3010 if( scip->primal->nsols > 0 )
3011 {
3012 assert(scip->primal->sols != NULL);
3013 assert(scip->primal->sols[0] != NULL);
3014 return scip->primal->sols[0];
3015 }
3016 break;
3017
3020 case SCIP_STAGE_FREE:
3021 default:
3022 SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
3023 return NULL;
3024 }
3025
3026 return NULL;
3027}
3028
3029/** outputs best feasible primal solution found so far to file stream
3030 *
3031 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
3032 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
3033 *
3034 * @pre This method can be called if SCIP is in one of the following stages:
3035 * - \ref SCIP_STAGE_INIT
3036 * - \ref SCIP_STAGE_PROBLEM
3037 * - \ref SCIP_STAGE_TRANSFORMED
3038 * - \ref SCIP_STAGE_INITPRESOLVE
3039 * - \ref SCIP_STAGE_PRESOLVING
3040 * - \ref SCIP_STAGE_EXITPRESOLVE
3041 * - \ref SCIP_STAGE_PRESOLVED
3042 * - \ref SCIP_STAGE_INITSOLVE
3043 * - \ref SCIP_STAGE_SOLVING
3044 * - \ref SCIP_STAGE_SOLVED
3045 * - \ref SCIP_STAGE_EXITSOLVE
3046 */
3048 SCIP* scip, /**< SCIP data structure */
3049 FILE* file, /**< output file (or NULL for standard output) */
3050 SCIP_Bool printzeros /**< should variables set to zero be printed? */
3051 )
3052{
3053 SCIP_SOL* sol;
3054
3055 SCIP_CALL( SCIPcheckStage(scip, "SCIPprintBestSol", TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE) );
3056
3057 sol = SCIPgetBestSol(scip);
3058
3059 if( sol == NULL )
3060 SCIPmessageFPrintInfo(scip->messagehdlr, file, "no solution available\n");
3061 else
3062 {
3063 SCIP_CALL( SCIPprintSol(scip, sol, file, printzeros) );
3064 }
3065
3066 return SCIP_OKAY;
3067}
3068
3069/** outputs best feasible primal solution found so far in transformed variables to file stream
3070 *
3071 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
3072 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
3073 *
3074 * @pre This method can be called if SCIP is in one of the following stages:
3075 * - \ref SCIP_STAGE_INIT
3076 * - \ref SCIP_STAGE_PROBLEM
3077 * - \ref SCIP_STAGE_TRANSFORMED
3078 * - \ref SCIP_STAGE_INITPRESOLVE
3079 * - \ref SCIP_STAGE_PRESOLVING
3080 * - \ref SCIP_STAGE_EXITPRESOLVE
3081 * - \ref SCIP_STAGE_PRESOLVED
3082 * - \ref SCIP_STAGE_INITSOLVE
3083 * - \ref SCIP_STAGE_SOLVING
3084 * - \ref SCIP_STAGE_SOLVED
3085 * - \ref SCIP_STAGE_EXITSOLVE
3086 */
3088 SCIP* scip, /**< SCIP data structure */
3089 FILE* file, /**< output file (or NULL for standard output) */
3090 SCIP_Bool printzeros /**< should variables set to zero be printed? */
3091 )
3092{
3093 SCIP_SOL* sol;
3094
3095 SCIP_CALL( SCIPcheckStage(scip, "SCIPprintBestTransSol", TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE) );
3096
3097 sol = SCIPgetBestSol(scip);
3098
3099 if( sol != NULL && SCIPsolIsOriginal(sol) )
3100 {
3101 SCIPerrorMessage("best solution is defined in original space - cannot print it as transformed solution\n");
3102 return SCIP_INVALIDCALL;
3103 }
3104
3105 if( sol == NULL )
3106 SCIPmessageFPrintInfo(scip->messagehdlr, file, "no solution available\n");
3107 else
3108 {
3109 SCIP_CALL( SCIPprintTransSol(scip, sol, file, printzeros) );
3110 }
3111
3112 return SCIP_OKAY;
3113}
3114
3115/** try to round given solution
3116 *
3117 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
3118 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
3119 *
3120 * @pre This method can be called if SCIP is in one of the following stages:
3121 * - \ref SCIP_STAGE_SOLVING
3122 */
3124 SCIP* scip, /**< SCIP data structure */
3125 SCIP_SOL* sol, /**< primal solution */
3126 SCIP_Bool* success /**< pointer to store whether rounding was successful */
3127 )
3128{
3130
3131 assert(sol != NULL);
3132 assert(sol->scip == scip);
3133
3134 if( SCIPsolIsOriginal(sol) )
3135 {
3136 SCIPerrorMessage("cannot round original space solution\n");
3137 return SCIP_INVALIDCALL;
3138 }
3139
3140 SCIP_CALL( SCIPsolRound(sol, scip->set, scip->stat, scip->transprob, scip->tree, success) );
3141
3142 return SCIP_OKAY;
3143}
3144
3145/** copy the fp values to the exact arrays of the solution */
3147 SCIP* scip, /**< SCIP data structure */
3148 SCIP_SOL* sol /**< primal solution */
3149 )
3150{
3151 assert(sol != NULL);
3152 assert(sol->scip == scip);
3153 assert(!SCIPsolIsExact(sol));
3154
3155 SCIP_CALL( SCIPcheckStage(scip, "SCIPmakeSolExact", FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE) );
3156
3158 SCIP_CALL( SCIPsolMakeExact(sol, scip->mem->probmem, scip->set, scip->stat, scip->origprob) );
3159 else
3160 SCIP_CALL( SCIPsolMakeExact(sol, scip->mem->probmem, scip->set, scip->stat, scip->transprob) );
3161
3162 return SCIP_OKAY;
3163}
3164
3165/** retransforms solution to original problem space
3166 *
3167 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
3168 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
3169 *
3170 * @pre This method can be called if SCIP is in one of the following stages:
3171 * - \ref SCIP_STAGE_TRANSFORMED
3172 * - \ref SCIP_STAGE_INITPRESOLVE
3173 * - \ref SCIP_STAGE_PRESOLVING
3174 * - \ref SCIP_STAGE_EXITPRESOLVE
3175 * - \ref SCIP_STAGE_PRESOLVED
3176 * - \ref SCIP_STAGE_INITSOLVE
3177 * - \ref SCIP_STAGE_SOLVING
3178 * - \ref SCIP_STAGE_SOLVED
3179 * - \ref SCIP_STAGE_EXITSOLVE
3180 * - \ref SCIP_STAGE_FREETRANS
3181 */
3183 SCIP* scip, /**< SCIP data structure */
3184 SCIP_SOL* sol /**< primal CIP solution */
3185 )
3186{
3187 assert(sol != NULL);
3188 assert(sol->scip == scip);
3189
3190 SCIP_CALL( SCIPcheckStage(scip, "SCIPretransformSol", FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
3191
3192 switch ( SCIPsolGetOrigin(sol) )
3193 {
3195 /* nothing to do */
3196 return SCIP_OKAY;
3197
3202
3203 /* first unlink solution */
3204 SCIP_CALL( SCIPunlinkSol(scip, sol) );
3205
3206 /*lint -fallthrough*/
3208 {
3209 SCIP_Bool hasinfval;
3210
3211 SCIP_CALL( SCIPsolRetransform(sol, scip->set, scip->stat, scip->origprob, scip->transprob, &hasinfval) );
3212 break;
3213 }
3216 SCIPerrorMessage("unknown solution origin.\n");
3217 return SCIP_INVALIDCALL;
3218
3219 default:
3220 /* note that this is in an internal SCIP error since all solution origins are covert in the switch above */
3221 SCIPerrorMessage("invalid solution origin <%d>\n", SCIPsolGetOrigin(sol));
3222 return SCIP_ERROR;
3223 }
3224
3225 return SCIP_OKAY;
3226}
3227
3228/** retransforms exact solution to original problem space
3229 *
3230 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
3231 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
3232 *
3233 * @pre This method can be called if SCIP is in one of the following stages:
3234 * - \ref SCIP_STAGE_TRANSFORMED
3235 * - \ref SCIP_STAGE_INITPRESOLVE
3236 * - \ref SCIP_STAGE_PRESOLVING
3237 * - \ref SCIP_STAGE_EXITPRESOLVE
3238 * - \ref SCIP_STAGE_PRESOLVED
3239 * - \ref SCIP_STAGE_INITSOLVE
3240 * - \ref SCIP_STAGE_SOLVING
3241 * - \ref SCIP_STAGE_SOLVED
3242 * - \ref SCIP_STAGE_EXITSOLVE
3243 * - \ref SCIP_STAGE_FREETRANS
3244 */
3246 SCIP* scip, /**< SCIP data structure */
3247 SCIP_SOL* sol /**< primal CIP solution */
3248 )
3249{
3250 assert(sol != NULL);
3251 assert(sol->scip == scip);
3252
3253 SCIP_CALL( SCIPcheckStage(scip, "SCIPretransformSolExact", FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
3254
3255 switch( SCIPsolGetOrigin(sol) )
3256 {
3258 /* nothing to do */
3259 return SCIP_OKAY;
3260
3265
3266 /* first unlink solution */
3268
3269 /*lint -fallthrough*/
3271 {
3272 SCIP_Bool hasinfval;
3273
3274 SCIP_CALL( SCIPsolRetransformExact(sol, scip->set, scip->stat, scip->origprob, scip->transprob, &hasinfval) );
3275 break;
3276 }
3279 SCIPerrorMessage("unknown solution origin.\n");
3280 return SCIP_INVALIDCALL;
3281
3282 default:
3283 /* note that this is in an internal SCIP error since all solution origins are covert in the switch above */
3284 SCIPerrorMessage("invalid solution origin <%d>\n", SCIPsolGetOrigin(sol));
3285 return SCIP_ERROR;
3286 }
3287
3288 return SCIP_OKAY;
3289}
3290
3291/** reads a given solution file
3292 *
3293 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
3294 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
3295 *
3296 * @pre This method can be called if SCIP is in one of the following stages:
3297 * - \ref SCIP_STAGE_PROBLEM
3298 * - \ref SCIP_STAGE_TRANSFORMED
3299 * - \ref SCIP_STAGE_INITPRESOLVE
3300 * - \ref SCIP_STAGE_PRESOLVING
3301 * - \ref SCIP_STAGE_EXITPRESOLVE
3302 * - \ref SCIP_STAGE_PRESOLVED
3303 * - \ref SCIP_STAGE_INITSOLVE
3304 * - \ref SCIP_STAGE_SOLVING
3305 */
3307 SCIP* scip, /**< SCIP data structure */
3308 const char* filename /**< name of the input file */
3309 )
3310{
3312
3313 /* we pass the reading of the solution file on to reader_sol via the following call */
3314 SCIP_CALL( SCIPreadProb(scip, filename, "sol") );
3315
3316 return SCIP_OKAY;
3317}
3318
3319/** reads a given solution file and store the solution values in the given solution pointer */
3320static
3322 SCIP* scip, /**< SCIP data structure */
3323 const char* filename, /**< name of the input file */
3324 SCIP_SOL* sol, /**< solution pointer */
3325 SCIP_Bool* partial, /**< pointer to store if the solution is partial (or NULL, if not needed) */
3326 SCIP_Bool* error /**< pointer store if an error occured */
3327 )
3328{
3329 SCIP_HASHSET* unknownvars = NULL;
3330 SCIP_FILE* file;
3331 SCIP_Bool unknownvariablemessage;
3332 SCIP_Bool localpartial;
3333 int lineno;
3334
3335 assert(scip != NULL);
3336 assert(sol != NULL);
3337 assert(error != NULL);
3338
3339 /* open input file */
3340 file = SCIPfopen(filename, "r");
3341 if( file == NULL )
3342 {
3343 SCIPerrorMessage("cannot open file <%s> for reading\n", filename);
3344 SCIPprintSysError(filename);
3345 return SCIP_NOFILE;
3346 }
3347
3348 *error = FALSE;
3349 localpartial = SCIPsolIsPartial(sol);
3350
3351 unknownvariablemessage = FALSE;
3352 lineno = 0;
3353
3354 /* read the file */
3355 while( !SCIPfeof(file) && !(*error) )
3356 {
3357 /**@todo unlimit buffer size */
3358 char buffer[SCIP_MAXSTRLEN];
3359 const char* varname;
3360 const char* valuestring;
3361 char* endptr;
3362 SCIP_VAR* var;
3363 SCIP_RETCODE retcode;
3364
3365 /* get next line */
3366 if( SCIPfgets(buffer, (int)sizeof(buffer), file) == NULL )
3367 {
3368 if( !SCIPfeof(file) )
3369 *error = TRUE;
3370 break;
3371 }
3372 ++lineno;
3373
3374 /* there are some lines which may precede the solution information */
3375 if( SCIPstrncasecmp(buffer, "solution status:", 16) == 0 || SCIPstrncasecmp(buffer, "objective value:", 16) == 0
3376 || buffer[strspn(buffer, " \t\n\v\f\r")] == '\0' || SCIPstrncasecmp(buffer, "Log started", 11) == 0
3377 || SCIPstrncasecmp(buffer, "Variable Name", 13) == 0 || SCIPstrncasecmp(buffer, "All other variables", 19) == 0
3378 || SCIPstrncasecmp(buffer, "NAME", 4) == 0 || SCIPstrncasecmp(buffer, "ENDATA", 6) == 0 /* allow parsing of SOL-format on the MIPLIB 2003 pages */
3379 || SCIPstrncasecmp(buffer, "=obj=", 5) == 0 ) /* avoid "unknown variable" warning when reading MIPLIB SOL files */
3380 continue;
3381
3382 /* tokenize the line */
3383 varname = SCIPstrtok(buffer, " \t\v", &endptr);
3384 valuestring = SCIPstrtok(NULL, " \t\n\v\f\r", &endptr);
3385 if( valuestring == NULL )
3386 {
3387 SCIPerrorMessage("Invalid input line %d in solution file <%s>: <%s>.\n", lineno, filename, buffer);
3388 *error = TRUE;
3389 break;
3390 }
3391
3392 /* find the variable */
3393 var = SCIPfindVar(scip, varname);
3394 if( var == NULL )
3395 {
3396 if( !unknownvariablemessage )
3397 {
3398 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "unknown variable <%s> in line %d of solution file <%s>\n",
3399 varname, lineno, filename);
3400 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, " (further unknown variables are ignored)\n");
3401 unknownvariablemessage = TRUE;
3402 }
3403 continue;
3404 }
3405
3406 /* ignore multi-aggregated variable */
3408 {
3409 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "ignored solution value for multiaggregated variable <%s>\n",
3410 varname);
3411 continue;
3412 }
3413
3414 /* ignore invalid value */
3415 if( SCIPstrncasecmp(valuestring, "inv", 3) == 0 )
3416 {
3417 SCIPdebugMsg(scip, "ignored invalid assignment for variable <%s>\n", varname);
3418 continue;
3419 }
3420
3421 /* read the value */
3422 if( SCIPsolIsExact(sol) )
3423 {
3424 SCIP_RATIONAL* value = NULL;
3425
3426 assert(SCIPisExact(scip));
3427
3428 if( SCIPrationalIsString(valuestring) )
3429 {
3430 SCIP_CALL( SCIPrationalCreateString(SCIPblkmem(scip), &value, valuestring) );
3431 assert(value != NULL);
3432 }
3433 else if( SCIPstrncasecmp(valuestring, "unk", 3) == 0 )
3434 {
3435 /**@todo handle unknown value as null pointer and set up exact partial solution instead */
3436 /* value = NULL; */
3437 if( unknownvars == NULL )
3438 {
3440 }
3441 SCIP_CALL( SCIPhashsetInsert(unknownvars, SCIPblkmem(scip), (void*)var) );
3442 localpartial = TRUE;
3443 continue;
3444 }
3445 else
3446 {
3447 SCIPerrorMessage("Invalid solution value <%s> for variable <%s> in line %d of solution file <%s>.\n",
3448 valuestring, varname, lineno, filename);
3449 *error = TRUE;
3450 break;
3451 }
3452
3453 retcode = SCIPsetSolValExact(scip, sol, var, value);
3454
3456 }
3457 else
3458 {
3459 SCIP_Real value;
3460
3461 if( SCIPstrncasecmp(valuestring, "+inf", 4) == 0 || SCIPstrncasecmp(valuestring, "inf", 3) == 0 )
3462 value = SCIPinfinity(scip);
3463 else if( SCIPstrncasecmp(valuestring, "-inf", 4) == 0 )
3464 value = -SCIPinfinity(scip);
3465 else if( SCIPstrncasecmp(valuestring, "unk", 3) == 0 )
3466 {
3467 value = SCIP_UNKNOWN;
3468 localpartial = TRUE;
3469 }
3470 else if( !SCIPstrToRealValue(valuestring, &value, &endptr) || *endptr != '\0' )
3471 {
3472#ifdef SCIP_WITH_EXACTSOLVE
3473 /* convert exact value */
3474 if( SCIPrationalIsString(valuestring) )
3475 {
3476 SCIP_RATIONAL* valueexact;
3477
3478 SCIP_CALL( SCIPrationalCreateString(SCIPblkmem(scip), &valueexact, valuestring) );
3479
3480 value = SCIPrationalGetReal(valueexact);
3481
3482 SCIPrationalFreeBlock(SCIPblkmem(scip), &valueexact);
3483 }
3484 else
3485#endif
3486 {
3487 SCIPerrorMessage("Invalid solution value <%s> for variable <%s> in line %d of solution file <%s>.\n",
3488 valuestring, varname, lineno, filename);
3489 *error = TRUE;
3490 break;
3491 }
3492 }
3493
3494 retcode = SCIPsetSolVal(scip, sol, var, value);
3495 }
3496
3497 if( retcode == SCIP_INVALIDDATA )
3498 SCIPwarningMessage(scip, "ignored conflicting solution value for fixed variable <%s>\n", varname);
3499 else
3500 {
3501 SCIP_CALL_FINALLY( retcode, SCIPfclose(file) );
3502 }
3503 }
3504
3505 /* close input file */
3506 SCIPfclose(file);
3507
3508 if( localpartial && !SCIPsolIsPartial(sol) )
3509 {
3511 {
3512 if( SCIPsolIsExact(sol) )
3513 {
3515 SCIP_CALL( SCIPsolMakeReal(sol, SCIPblkmem(scip), scip->set, scip->stat, scip->origprob) );
3516 }
3517
3518 SCIP_CALL( SCIPsolMarkPartial(sol, scip->set, scip->stat, scip->origprob->vars, scip->origprob->nvars) );
3519 }
3520 else
3521 *error = TRUE;
3522 }
3523
3524 if( unknownvars != NULL )
3525 {
3526 if( !(*error) )
3527 {
3528 SCIP_VAR** slots = (SCIP_VAR**)SCIPhashsetGetSlots(unknownvars);
3529 int nslots = SCIPhashsetGetNSlots(unknownvars);
3530 int i;
3531
3532 assert(!SCIPsolIsExact(sol));
3533 assert(SCIPsolIsPartial(sol));
3534
3535 for( i = 0; i < nslots; ++i )
3536 {
3537 if( slots[i] != NULL )
3538 {
3539 SCIP_CALL( SCIPsetSolVal(scip, sol, slots[i], SCIP_UNKNOWN) );
3540 }
3541 }
3542 }
3543
3544 SCIPhashsetFree(&unknownvars, SCIPblkmem(scip));
3545 }
3546
3547 if( partial != NULL )
3548 *partial = localpartial;
3549
3550 return SCIP_OKAY;
3551}
3552
3553/** reads a given xml solution file and store the solution values in the given solution pointer */
3554static
3556 SCIP* scip, /**< SCIP data structure */
3557 const char* filename, /**< name of the input file */
3558 SCIP_SOL* sol, /**< solution pointer */
3559 SCIP_Bool* partial, /**< pointer to store if the solution is partial (or NULL if not needed) */
3560 SCIP_Bool* error /**< pointer store if an error occured */
3561 )
3562{
3563 SCIP_HASHSET* unknownvars = NULL;
3564 XML_NODE* start;
3565 const XML_NODE* varsnode;
3566 const XML_NODE* varnode;
3567 const char* tag;
3568 SCIP_Bool unknownvariablemessage;
3569 SCIP_Bool localpartial;
3570
3571 assert(scip != NULL);
3572 assert(sol != NULL);
3573 assert(sol->scip == scip);
3574 assert(error != NULL);
3575
3576 /* read xml file */
3577 start = SCIPxmlProcess(filename);
3578
3579 if( start == NULL )
3580 {
3581 SCIPerrorMessage("Some error occured during parsing the XML solution file.\n");
3582 return SCIP_READERROR;
3583 }
3584
3585 *error = FALSE;
3586 localpartial = SCIPsolIsPartial(sol);
3587
3588 /* find variable sections */
3589 tag = "variables";
3590 varsnode = SCIPxmlFindNodeMaxdepth(start, tag, 0, 3);
3591 if( varsnode == NULL )
3592 {
3593 /* free xml data */
3594 SCIPxmlFreeNode(start);
3595
3596 SCIPerrorMessage("Variable section not found.\n");
3597 return SCIP_READERROR;
3598 }
3599
3600 /* loop through all variables */
3601 unknownvariablemessage = FALSE;
3602 for( varnode = SCIPxmlFirstChild(varsnode); varnode != NULL; varnode = SCIPxmlNextSibl(varnode) )
3603 {
3604 SCIP_VAR* var;
3605 const char* varname;
3606 const char* valuestring;
3607 char* endptr;
3608 SCIP_RETCODE retcode;
3609
3610 /* find variable name */
3611 varname = SCIPxmlGetAttrval(varnode, "name");
3612 if( varname == NULL )
3613 {
3614 SCIPerrorMessage("Attribute \"name\" of variable not found.\n");
3615 *error = TRUE;
3616 break;
3617 }
3618
3619 /* find value of variable */
3620 valuestring = SCIPxmlGetAttrval(varnode, "value");
3621 if( valuestring == NULL )
3622 {
3623 SCIPerrorMessage("Attribute \"value\" of variable not found.\n");
3624 *error = TRUE;
3625 break;
3626 }
3627
3628 /* find the variable */
3629 var = SCIPfindVar(scip, varname);
3630 if( var == NULL )
3631 {
3632 if( !unknownvariablemessage )
3633 {
3634 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "unknown variable <%s> of solution file <%s>\n",
3635 varname, filename);
3636 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, " (further unknown variables are ignored)\n");
3637 unknownvariablemessage = TRUE;
3638 }
3639 continue;
3640 }
3641
3642 /* ignore multi-aggregated variable */
3644 {
3645 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "ignored solution value for multiaggregated variable <%s>\n",
3646 varname);
3647 continue;
3648 }
3649
3650 /* ignore invalid value */
3651 if( SCIPstrncasecmp(valuestring, "inv", 3) == 0 )
3652 {
3653 SCIPdebugMsg(scip, "ignored invalid assignment for variable <%s>\n", varname);
3654 continue;
3655 }
3656
3657 /* read the value */
3658 if( SCIPsolIsExact(sol) )
3659 {
3660 SCIP_RATIONAL* value = NULL;
3661
3662 assert(SCIPisExact(scip));
3663
3664 if( SCIPrationalIsString(valuestring) )
3665 {
3666 SCIP_CALL( SCIPrationalCreateString(SCIPblkmem(scip), &value, valuestring) );
3667 assert(value != NULL);
3668 }
3669 else if( SCIPstrncasecmp(valuestring, "unk", 3) == 0 )
3670 {
3671 /**@todo handle unknown value as null pointer and set up exact partial solution instead */
3672 /* value = NULL; */
3673 if( unknownvars == NULL )
3674 {
3676 }
3677 SCIP_CALL( SCIPhashsetInsert(unknownvars, SCIPblkmem(scip), (void*)var) );
3678 localpartial = TRUE;
3679 continue;
3680 }
3681 else
3682 {
3683 SCIPerrorMessage("Invalid solution value <%s> for variable <%s> in XML solution file <%s>.\n",
3684 valuestring, varname, filename);
3685 *error = TRUE;
3686 break;
3687 }
3688
3689 retcode = SCIPsetSolValExact(scip, sol, var, value);
3690
3692 }
3693 else
3694 {
3695 SCIP_Real value;
3696
3697 if( SCIPstrncasecmp(valuestring, "+inf", 4) == 0 || SCIPstrncasecmp(valuestring, "inf", 3) == 0 )
3698 value = SCIPinfinity(scip);
3699 else if( SCIPstrncasecmp(valuestring, "-inf", 4) == 0 )
3700 value = -SCIPinfinity(scip);
3701 else if( SCIPstrncasecmp(valuestring, "unk", 3) == 0 )
3702 {
3703 value = SCIP_UNKNOWN;
3704 localpartial = TRUE;
3705 }
3706 else if( !SCIPstrToRealValue(valuestring, &value, &endptr) || *endptr != '\0' )
3707 {
3708#ifdef SCIP_WITH_EXACTSOLVE
3709 /* convert exact value */
3710 if( SCIPrationalIsString(valuestring) )
3711 {
3712 SCIP_RATIONAL* valueexact;
3713
3714 SCIP_CALL( SCIPrationalCreateString(SCIPblkmem(scip), &valueexact, valuestring) );
3715
3716 value = SCIPrationalGetReal(valueexact);
3717
3718 SCIPrationalFreeBlock(SCIPblkmem(scip), &valueexact);
3719 }
3720 else
3721#endif
3722 {
3723 SCIPerrorMessage("Invalid solution value <%s> for variable <%s> in XML solution file <%s>.\n",
3724 valuestring, varname, filename);
3725 *error = TRUE;
3726 break;
3727 }
3728 }
3729
3730 retcode = SCIPsetSolVal(scip, sol, var, value);
3731 }
3732
3733 if( retcode == SCIP_INVALIDDATA )
3734 SCIPwarningMessage(scip, "ignored conflicting solution value for fixed variable <%s>\n", varname);
3735 else
3736 {
3737 SCIP_CALL( retcode );
3738 }
3739 }
3740
3741 /* free xml data */
3742 SCIPxmlFreeNode(start);
3743
3744 if( localpartial && !SCIPsolIsPartial(sol) )
3745 {
3747 {
3748 if( SCIPsolIsExact(sol) )
3749 {
3751 SCIP_CALL( SCIPsolMakeReal(sol, SCIPblkmem(scip), scip->set, scip->stat, scip->origprob) );
3752 }
3753
3754 SCIP_CALL( SCIPsolMarkPartial(sol, scip->set, scip->stat, scip->origprob->vars, scip->origprob->nvars) );
3755 }
3756 else
3757 *error = TRUE;
3758 }
3759
3760 if( unknownvars != NULL )
3761 {
3762 if( !(*error) )
3763 {
3764 SCIP_VAR** slots = (SCIP_VAR**)SCIPhashsetGetSlots(unknownvars);
3765 int nslots = SCIPhashsetGetNSlots(unknownvars);
3766 int i;
3767
3768 assert(!SCIPsolIsExact(sol));
3769 assert(SCIPsolIsPartial(sol));
3770
3771 for( i = 0; i < nslots; ++i )
3772 {
3773 if( slots[i] != NULL )
3774 SCIP_CALL( SCIPsetSolVal(scip, sol, slots[i], SCIP_UNKNOWN) );
3775 }
3776 }
3777
3778 SCIPhashsetFree(&unknownvars, SCIPblkmem(scip));
3779 }
3780
3781 if( partial != NULL )
3782 *partial = localpartial;
3783
3784 return SCIP_OKAY;
3785}
3786
3787/** reads a given solution file and store the solution values in the given solution pointer
3788 *
3789 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
3790 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
3791 *
3792 * @pre This method can be called if SCIP is in one of the following stages:
3793 * - \ref SCIP_STAGE_PROBLEM
3794 * - \ref SCIP_STAGE_TRANSFORMED
3795 * - \ref SCIP_STAGE_INITPRESOLVE
3796 * - \ref SCIP_STAGE_PRESOLVING
3797 * - \ref SCIP_STAGE_EXITPRESOLVE
3798 * - \ref SCIP_STAGE_PRESOLVED
3799 * - \ref SCIP_STAGE_INITSOLVE
3800 * - \ref SCIP_STAGE_SOLVING
3801 */
3803 SCIP* scip, /**< SCIP data structure */
3804 const char* filename, /**< name of the input file */
3805 SCIP_SOL* sol, /**< solution pointer */
3806 SCIP_Bool xml, /**< true, iff the given solution in written in XML */
3807 SCIP_Bool* partial, /**< pointer to store if the solution is partial */
3808 SCIP_Bool* error /**< pointer store if an error occured */
3809 )
3810{
3811 SCIP_CALL( SCIPcheckStage(scip, "SCIPreadSolFile", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE) );
3812
3813 if( xml )
3814 {
3815 SCIP_CALL( readXmlSolFile(scip, filename, sol, partial, error) );
3816 }
3817 else
3818 {
3819 SCIP_CALL( readSolFile(scip, filename, sol, partial, error) );
3820 }
3821
3822 return SCIP_OKAY;
3823}
3824
3825/** adds feasible primal solution to solution storage by copying it
3826 *
3827 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
3828 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
3829 *
3830 * @pre This method can be called if SCIP is in one of the following stages:
3831 * - \ref SCIP_STAGE_PROBLEM
3832 * - \ref SCIP_STAGE_TRANSFORMED
3833 * - \ref SCIP_STAGE_INITPRESOLVE
3834 * - \ref SCIP_STAGE_PRESOLVING
3835 * - \ref SCIP_STAGE_EXITPRESOLVE
3836 * - \ref SCIP_STAGE_PRESOLVED
3837 * - \ref SCIP_STAGE_SOLVING
3838 * - \ref SCIP_STAGE_FREETRANS
3839 *
3840 * @note Do not call during propagation, use heur_trysol instead.
3841 */
3843 SCIP* scip, /**< SCIP data structure */
3844 SCIP_SOL* sol, /**< primal CIP solution */
3845 SCIP_Bool* stored /**< stores whether given solution was good enough to keep */
3846 )
3847{
3848 assert(sol != NULL);
3849 assert(sol->scip == scip);
3850
3852
3853 switch( scip->set->stage )
3854 {
3855 case SCIP_STAGE_PROBLEM:
3857 assert(SCIPsolIsOriginal(sol));
3858 SCIP_CALL( SCIPprimalAddOrigSol(scip->origprimal, scip->mem->probmem, scip->set, scip->stat, scip->origprob, sol, stored) );
3859 return SCIP_OKAY;
3860
3866 case SCIP_STAGE_SOLVING:
3867 {
3868 SCIP_SOL* bestsol = SCIPgetBestSol(scip);
3869
3870 SCIP_CALL( SCIPprimalAddSol(scip->primal, scip->mem->probmem, scip->set, scip->messagehdlr, scip->stat,
3871 scip->origprob, scip->transprob, scip->tree, scip->reopt, scip->lp, scip->eventqueue, scip->eventfilter, sol,
3872 stored) );
3873
3874 /* @todo use solution index rather than pointer */
3875 if( *stored && (bestsol != SCIPgetBestSol(scip)) )
3876 {
3878 }
3879
3880 return SCIP_OKAY;
3881 }
3884 case SCIP_STAGE_SOLVED:
3886 default:
3887 SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
3888 return SCIP_INVALIDCALL;
3889 } /*lint !e788*/
3890}
3891
3892/** adds primal solution to solution storage, frees the solution afterwards
3893 *
3894 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
3895 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
3896 *
3897 * @pre This method can be called if SCIP is in one of the following stages:
3898 * - \ref SCIP_STAGE_PROBLEM
3899 * - \ref SCIP_STAGE_TRANSFORMED
3900 * - \ref SCIP_STAGE_INITPRESOLVE
3901 * - \ref SCIP_STAGE_PRESOLVING
3902 * - \ref SCIP_STAGE_EXITPRESOLVE
3903 * - \ref SCIP_STAGE_PRESOLVED
3904 * - \ref SCIP_STAGE_SOLVING
3905 * - \ref SCIP_STAGE_FREETRANS
3906 *
3907 * @note Do not call during propagation, use heur_trysol instead.
3908 */
3910 SCIP* scip, /**< SCIP data structure */
3911 SCIP_SOL** sol, /**< pointer to primal CIP solution; is cleared in function call */
3912 SCIP_Bool* stored /**< stores whether given solution was good enough to keep */
3913 )
3914{
3915 assert(sol != NULL);
3916 assert(*sol != NULL);
3917 assert((*sol)->scip == scip);
3918
3920
3921 switch( scip->set->stage )
3922 {
3923 case SCIP_STAGE_PROBLEM:
3925 assert(SCIPsolIsOriginal(*sol));
3926 SCIP_CALL( SCIPprimalAddOrigSolFree(scip->origprimal, scip->mem->probmem, scip->set, scip->stat, scip->origprob, sol, stored) );
3927 return SCIP_OKAY;
3928
3934 case SCIP_STAGE_SOLVING:
3935 {
3936 SCIP_SOL* bestsol = SCIPgetBestSol(scip);
3937
3938 SCIP_CALL( SCIPprimalAddSolFree(scip->primal, scip->mem->probmem, scip->set, scip->messagehdlr, scip->stat,
3939 scip->origprob, scip->transprob, scip->tree, scip->reopt, scip->lp, scip->eventqueue, scip->eventfilter,
3940 sol, stored) );
3941
3942 if( *stored )
3943 {
3944 if( bestsol != SCIPgetBestSol(scip) )
3945 {
3946 assert(SCIPgetBestSol(scip) != NULL);
3948 }
3949 }
3950
3951 return SCIP_OKAY;
3952 }
3955 case SCIP_STAGE_SOLVED:
3957 default:
3958 SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
3959 return SCIP_INVALIDCALL;
3960 } /*lint !e788*/
3961}
3962
3963/** adds current LP/pseudo solution to solution storage
3964 *
3965 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
3966 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
3967 *
3968 * @pre This method can be called if SCIP is in one of the following stages:
3969 * - \ref SCIP_STAGE_PRESOLVED
3970 * - \ref SCIP_STAGE_SOLVING
3971 */
3973 SCIP* scip, /**< SCIP data structure */
3974 SCIP_HEUR* heur, /**< heuristic that found the solution */
3975 SCIP_Bool* stored /**< stores whether given solution was good enough to keep */
3976 )
3977{
3978 SCIP_SOL* bestsol;
3979
3981
3982 bestsol = SCIPgetBestSol(scip);
3983
3984 SCIP_CALL( SCIPprimalAddCurrentSol(scip->primal, scip->mem->probmem, scip->set, scip->messagehdlr, scip->stat,
3985 scip->origprob, scip->transprob, scip->tree, scip->reopt, scip->lp, scip->eventqueue, scip->eventfilter, heur,
3986 stored) );
3987
3988 if( *stored )
3989 {
3990 if( bestsol != SCIPgetBestSol(scip) )
3992 }
3993
3994 return SCIP_OKAY;
3995}
3996
3997/** checks solution for feasibility; if possible, adds it to storage by copying
3998 *
3999 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
4000 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
4001 *
4002 * @pre This method can be called if SCIP is in one of the following stages:
4003 * - \ref SCIP_STAGE_TRANSFORMED
4004 * - \ref SCIP_STAGE_INITPRESOLVE
4005 * - \ref SCIP_STAGE_PRESOLVING
4006 * - \ref SCIP_STAGE_EXITPRESOLVE
4007 * - \ref SCIP_STAGE_PRESOLVED
4008 * - \ref SCIP_STAGE_SOLVING
4009 *
4010 * @note Do not call during propagation, use heur_trysol instead.
4011 */
4013 SCIP* scip, /**< SCIP data structure */
4014 SCIP_SOL* sol, /**< primal CIP solution */
4015 SCIP_Bool printreason, /**< Should all reasons of violation be printed? */
4016 SCIP_Bool completely, /**< Should all violations be checked if printreason is true? */
4017 SCIP_Bool checkbounds, /**< Should the bounds of the variables be checked? */
4018 SCIP_Bool checkintegrality, /**< Has integrality to be checked? */
4019 SCIP_Bool checklprows, /**< Do constraints represented by rows in the current LP have to be checked? */
4020 SCIP_Bool* stored /**< stores whether given solution was feasible and good enough to keep */
4021 )
4022{
4023 SCIP_SOL* bestsol;
4024
4025 assert(sol != NULL);
4026 assert(sol->scip == scip);
4027 assert(stored != NULL);
4028
4030
4031 bestsol = SCIPgetBestSol(scip);
4032
4033 if( !printreason )
4034 completely = FALSE;
4035
4036 /* we cannot check partial solutions */
4037 if( SCIPsolIsPartial(sol) )
4038 {
4039 SCIPerrorMessage("Cannot check feasibility of partial solutions.\n");
4040 return SCIP_INVALIDDATA;
4041 }
4042
4043 if( SCIPsolIsOriginal(sol) )
4044 {
4045 SCIP_Bool feasible;
4046
4047 /* SCIPprimalTrySol() can only be called on transformed solutions; therefore check solutions in original problem
4048 * including modifiable constraints */
4049 SCIP_CALL( SCIPsolCheckOrig(sol, scip->set, scip->messagehdlr, scip->mem->probmem, scip->stat, scip->origprob, scip->origprimal,
4050 printreason, completely, checkbounds, checkintegrality, checklprows, TRUE, &feasible) );
4051 if( feasible )
4052 {
4053 SCIP_CALL( SCIPprimalAddSol(scip->primal, scip->mem->probmem, scip->set, scip->messagehdlr, scip->stat,
4054 scip->origprob, scip->transprob, scip->tree, scip->reopt, scip->lp, scip->eventqueue, scip->eventfilter,
4055 sol, stored) );
4056
4057 if( *stored )
4058 {
4059 if( bestsol != SCIPgetBestSol(scip) )
4061 }
4062 }
4063 else
4064 *stored = FALSE;
4065 }
4066 else
4067 {
4068 SCIP_CALL( SCIPprimalTrySol(scip->primal, scip->mem->probmem, scip->set, scip->messagehdlr, scip->stat, scip->origprob,
4069 scip->transprob, scip->tree, scip->reopt, scip->lp, scip->eventqueue, scip->eventfilter, sol, printreason,
4070 completely, checkbounds, checkintegrality, checklprows, stored) );
4071
4072 if( *stored )
4073 {
4074 if( bestsol != SCIPgetBestSol(scip) )
4075 {
4076#ifdef SCIP_DEBUG_ABORTATORIGINFEAS
4077 SCIP_Bool feasible;
4078 SCIP_CALL( SCIPsolCheckOrig(sol, scip->set, scip->messagehdlr, scip->mem->probmem, scip->stat, scip->origprob, scip->origprimal, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, &feasible) );
4079
4080 if( ! feasible )
4081 {
4082 SCIPerrorMessage("Accepted solution not feasible for original problem\n");
4083 SCIPABORT();
4084 }
4085#endif
4087 }
4088 }
4089 }
4090
4091 return SCIP_OKAY;
4092}
4093
4094/** checks primal solution; if feasible, adds it to storage; solution is freed afterwards
4095 *
4096 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
4097 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
4098 *
4099 * @pre This method can be called if SCIP is in one of the following stages:
4100 * - \ref SCIP_STAGE_TRANSFORMED
4101 * - \ref SCIP_STAGE_INITPRESOLVE
4102 * - \ref SCIP_STAGE_PRESOLVING
4103 * - \ref SCIP_STAGE_EXITPRESOLVE
4104 * - \ref SCIP_STAGE_PRESOLVED
4105 * - \ref SCIP_STAGE_SOLVING
4106 *
4107 * @note Do not call during propagation, use heur_trysol instead.
4108 */
4110 SCIP* scip, /**< SCIP data structure */
4111 SCIP_SOL** sol, /**< pointer to primal CIP solution; is cleared in function call */
4112 SCIP_Bool printreason, /**< Should all reasons of violations be printed */
4113 SCIP_Bool completely, /**< Should all violations be checked if printreason is true? */
4114 SCIP_Bool checkbounds, /**< Should the bounds of the variables be checked? */
4115 SCIP_Bool checkintegrality, /**< Has integrality to be checked? */
4116 SCIP_Bool checklprows, /**< Do constraints represented by rows in the current LP have to be checked? */
4117 SCIP_Bool* stored /**< stores whether solution was feasible and good enough to keep */
4118 )
4119{
4120 SCIP_SOL* bestsol;
4121
4122 assert(stored != NULL);
4123 assert(sol != NULL);
4124 assert(*sol != NULL);
4125 assert((*sol)->scip == scip);
4126
4128
4129 bestsol = SCIPgetBestSol(scip);
4130
4131 if( !printreason )
4132 completely = FALSE;
4133
4134 /* we cannot check partial solutions */
4135 if( SCIPsolIsPartial(*sol) )
4136 {
4137 SCIPerrorMessage("Cannot check feasibility of partial solutions.\n");
4138 return SCIP_INVALIDDATA;
4139 }
4140
4141 if( SCIPsolIsOriginal(*sol) )
4142 {
4143 SCIP_Bool feasible;
4144
4145 /* SCIPprimalTrySol() can only be called on transformed solutions; therefore check solutions in original problem
4146 * including modifiable constraints
4147 */
4148 SCIP_CALL( SCIPsolCheckOrig(*sol, scip->set, scip->messagehdlr, scip->mem->probmem, scip->stat, scip->origprob, scip->origprimal,
4149 printreason, completely, checkbounds, checkintegrality, checklprows, TRUE, &feasible) );
4150
4151 if( feasible )
4152 {
4153 SCIP_CALL( SCIPprimalAddSolFree(scip->primal, scip->mem->probmem, scip->set, scip->messagehdlr, scip->stat,
4154 scip->origprob, scip->transprob, scip->tree, scip->reopt, scip->lp, scip->eventqueue, scip->eventfilter,
4155 sol, stored) );
4156
4157 if( *stored )
4158 {
4159 if( bestsol != SCIPgetBestSol(scip) )
4161 }
4162 }
4163 else
4164 {
4165 SCIP_CALL( SCIPsolFree(sol, scip->mem->probmem, scip->primal) );
4166 *stored = FALSE;
4167 }
4168 }
4169 else
4170 {
4171 SCIP_CALL( SCIPprimalTrySolFree(scip->primal, scip->mem->probmem, scip->set, scip->messagehdlr, scip->stat,
4172 scip->origprob, scip->transprob, scip->tree, scip->reopt, scip->lp, scip->eventqueue, scip->eventfilter,
4173 sol, printreason, completely, checkbounds, checkintegrality, checklprows, stored) );
4174
4175 if( *stored )
4176 {
4177 if( bestsol != SCIPgetBestSol(scip) )
4178 {
4179#ifdef SCIP_DEBUG_ABORTATORIGINFEAS
4180 SCIP_Bool feasible;
4181 SCIP_CALL( SCIPsolCheckOrig(SCIPgetBestSol(scip), scip->set, scip->messagehdlr, scip->mem->probmem, scip->stat, scip->origprob, scip->origprimal,
4182 TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, &feasible) );
4183
4184 if( ! feasible )
4185 {
4186 SCIPerrorMessage("Accepted incumbent not feasible for original problem\n");
4187 SCIPABORT();
4188 }
4189#endif
4191 }
4192 }
4193 }
4194
4195 return SCIP_OKAY;
4196}
4197
4198/** checks current LP/pseudo solution for feasibility; if possible, adds it to storage
4199 *
4200 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
4201 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
4202 *
4203 * @pre This method can be called if SCIP is in one of the following stages:
4204 * - \ref SCIP_STAGE_PRESOLVED
4205 * - \ref SCIP_STAGE_SOLVING
4206 */
4208 SCIP* scip, /**< SCIP data structure */
4209 SCIP_HEUR* heur, /**< heuristic that found the solution */
4210 SCIP_Bool printreason, /**< Should all reasons of violations be printed? */
4211 SCIP_Bool completely, /**< Should all violations be checked if printreason is true? */
4212 SCIP_Bool checkintegrality, /**< Has integrality to be checked? */
4213 SCIP_Bool checklprows, /**< Do constraints represented by rows in the current LP have to be checked? */
4214 SCIP_Bool* stored /**< stores whether given solution was feasible and good enough to keep */
4215 )
4216{
4217 SCIP_SOL* bestsol;
4218
4220
4221 bestsol = SCIPgetBestSol(scip);
4222
4223 if( !printreason )
4224 completely = FALSE;
4225
4226 SCIP_CALL( SCIPprimalTryCurrentSol(scip->primal, scip->mem->probmem, scip->set, scip->messagehdlr, scip->stat,
4227 scip->origprob, scip->transprob, scip->tree, scip->reopt, scip->lp, scip->eventqueue, scip->eventfilter, heur,
4228 printreason, completely, checkintegrality, checklprows, stored) );
4229
4230 if( *stored )
4231 {
4232 if( bestsol != SCIPgetBestSol(scip) )
4233 {
4234#ifdef SCIP_DEBUG_ABORTATORIGINFEAS
4235 SCIP_Bool feasible;
4236 SCIP_CALL( SCIPsolCheckOrig(SCIPgetBestSol(scip), scip->set, scip->messagehdlr, scip->mem->probmem, scip->stat, scip->origprob, scip->origprimal,
4237 TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, &feasible) );
4238
4239 if( ! feasible )
4240 {
4241 SCIPerrorMessage("Accepted incumbent not feasible for original problem\n");
4242 SCIPABORT();
4243 }
4244#endif
4246 }
4247 }
4248
4249 return SCIP_OKAY;
4250}
4251
4252/** returns all partial solutions
4253 *
4254 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
4255 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
4256 *
4257 * @pre This method can be called if SCIP is in one of the following stages:
4258 * - \ref SCIP_STAGE_PROBLEM
4259 * - \ref SCIP_STAGE_PRESOLVING
4260 * - \ref SCIP_STAGE_SOLVING
4261 * - \ref SCIP_STAGE_SOLVED
4262 */
4264 SCIP* scip /**< SCIP data structure */
4265 )
4266{
4267 assert(scip != NULL);
4268
4270
4271 return scip->origprimal->partialsols;
4272}
4273
4274/** returns number of partial solutions
4275 *
4276 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
4277 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
4278 *
4279 * @pre This method can be called if SCIP is in one of the following stages:
4280 * - \ref SCIP_STAGE_PROBLEM
4281 * - \ref SCIP_STAGE_PRESOLVING
4282 * - \ref SCIP_STAGE_SOLVING
4283 * - \ref SCIP_STAGE_SOLVED
4284 */
4286 SCIP* scip /**< SCIP data structure */
4287 )
4288{
4289 assert(scip != NULL);
4290
4292
4293 return scip->origprimal->npartialsols;
4294}
4295
4296/** checks solution for feasibility without adding it to the solution store
4297 *
4298 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
4299 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
4300 *
4301 * @pre This method can be called if SCIP is in one of the following stages:
4302 * - \ref SCIP_STAGE_PROBLEM
4303 * - \ref SCIP_STAGE_TRANSFORMED
4304 * - \ref SCIP_STAGE_INITPRESOLVE
4305 * - \ref SCIP_STAGE_PRESOLVING
4306 * - \ref SCIP_STAGE_EXITPRESOLVE
4307 * - \ref SCIP_STAGE_PRESOLVED
4308 * - \ref SCIP_STAGE_INITSOLVE
4309 * - \ref SCIP_STAGE_SOLVING
4310 * - \ref SCIP_STAGE_SOLVED
4311 */
4313 SCIP* scip, /**< SCIP data structure */
4314 SCIP_SOL* sol, /**< primal CIP solution */
4315 SCIP_Bool printreason, /**< Should all reasons of violations be printed? */
4316 SCIP_Bool completely, /**< Should all violations be checked if printreason is true? */
4317 SCIP_Bool checkbounds, /**< Should the bounds of the variables be checked? */
4318 SCIP_Bool checkintegrality, /**< Has integrality to be checked? */
4319 SCIP_Bool checklprows, /**< Do constraints represented by rows in the current LP have to be checked? */
4320 SCIP_Bool* feasible /**< stores whether given solution is feasible */
4321 )
4322{
4323 assert(sol != NULL);
4324 assert(sol->scip == scip);
4325
4327
4328 /* return immediately if the solution is of type partial */
4329 if( SCIPsolIsPartial(sol) )
4330 {
4331 SCIPerrorMessage("Cannot check feasibility of partial solutions.");
4332 return SCIP_INVALIDDATA;
4333 }
4334
4335 /* if we want to solve exactly, the constraint handlers cannot rely on the LP's feasibility */
4336 checklprows = checklprows || scip->set->exact_enable;
4337
4338 if( !printreason )
4339 completely = FALSE;
4340
4341 /* SCIPsolCheck() can only be called on transformed solutions */
4342 if( SCIPsolIsOriginal(sol) )
4343 {
4344 if( SCIPisExact(scip) )
4345 {
4346 SCIP_CALL( checkSolOrigExact(scip, sol, feasible, printreason, completely, checkbounds, checkintegrality, checklprows, FALSE) );
4347 }
4348 else
4349 {
4350 SCIP_CALL( SCIPsolCheckOrig(sol, scip->set, scip->messagehdlr, scip->mem->probmem, scip->stat, scip->origprob, scip->origprimal,
4351 printreason, completely, checkbounds, checkintegrality, checklprows, FALSE, feasible) );
4352 }
4353 }
4354 else
4355 {
4356 SCIP_CALL( SCIPsolCheck(sol, scip->set, scip->messagehdlr, scip->mem->probmem, scip->stat, scip->transprob,
4357 printreason, completely, checkbounds, checkintegrality, checklprows, feasible) );
4358 }
4359
4360 return SCIP_OKAY;
4361}
4362
4363/** checks solution for feasibility in original problem without adding it to the solution store;
4364 * this method is used to double check a solution in order to validate the presolving process
4365 *
4366 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
4367 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
4368 *
4369 * @pre This method can be called if SCIP is in one of the following stages:
4370 * - \ref SCIP_STAGE_PROBLEM
4371 * - \ref SCIP_STAGE_TRANSFORMED
4372 * - \ref SCIP_STAGE_INITPRESOLVE
4373 * - \ref SCIP_STAGE_PRESOLVING
4374 * - \ref SCIP_STAGE_EXITPRESOLVE
4375 * - \ref SCIP_STAGE_PRESOLVED
4376 * - \ref SCIP_STAGE_INITSOLVE
4377 * - \ref SCIP_STAGE_SOLVING
4378 * - \ref SCIP_STAGE_SOLVED
4379 */
4381 SCIP* scip, /**< SCIP data structure */
4382 SCIP_SOL* sol, /**< primal CIP solution */
4383 SCIP_Bool* feasible, /**< stores whether given solution is feasible */
4384 SCIP_Bool printreason, /**< should the reason for the violation be printed? */
4385 SCIP_Bool completely /**< Should all violations be checked if printreason is true? */
4386 )
4387{
4388 assert(scip != NULL);
4389 assert(sol != NULL);
4390 assert(sol->scip == scip);
4391 assert(feasible != NULL);
4392
4393 SCIP_CALL( SCIPcheckStage(scip, "SCIPcheckSolOrig", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
4394
4395 /* return immediately if the solution is of type partial */
4396 if( SCIPsolIsPartial(sol) )
4397 {
4398 SCIPerrorMessage("Cannot check feasibility of partial solutions.");
4399 return SCIP_INVALIDDATA;
4400 }
4401
4402 if( !printreason )
4403 completely = FALSE;
4404
4405 /* check solution in original problem; that includes bounds, integrality, and non modifiable constraints */
4406 if( SCIPisExact(scip) )
4407 {
4408 SCIP_CALL( checkSolOrigExact(scip, sol, feasible, printreason, completely, TRUE, TRUE, TRUE, FALSE) );
4409 }
4410 else
4411 {
4412 SCIP_CALL( SCIPsolCheckOrig(sol, scip->set, scip->messagehdlr, scip->mem->probmem, scip->stat, scip->origprob, scip->origprimal,
4413 printreason, completely, TRUE, TRUE, TRUE, FALSE, feasible) );
4414 }
4415
4416 return SCIP_OKAY;
4417}
4418
4419/** return whether a primal ray is stored that proves unboundedness of the LP relaxation
4420 *
4421 * @return return whether a primal ray is stored that proves unboundedness of the LP relaxation
4422 *
4423 * @pre This method can be called if SCIP is in one of the following stages:
4424 * - \ref SCIP_STAGE_SOLVING
4425 * - \ref SCIP_STAGE_SOLVED
4426 */
4428 SCIP* scip /**< SCIP data structure */
4429 )
4430{
4432
4433 return scip->primal->primalray != NULL;
4434}
4435
4436/** gets value of given variable in primal ray causing unboundedness of the LP relaxation;
4437 * should only be called if such a ray is stored (check with SCIPhasPrimalRay())
4438 *
4439 * @return value of given variable in primal ray causing unboundedness of the LP relaxation
4440 *
4441 * @pre This method can be called if SCIP is in one of the following stages:
4442 * - \ref SCIP_STAGE_SOLVING
4443 * - \ref SCIP_STAGE_SOLVED
4444 */
4446 SCIP* scip, /**< SCIP data structure */
4447 SCIP_VAR* var /**< variable to get value for */
4448 )
4449{
4451
4452 assert(var != NULL);
4453 assert(var->scip == scip);
4454 assert(scip->primal != NULL);
4455 assert(scip->primal->primalray != NULL);
4456
4457 return SCIPsolGetRayVal(scip->primal->primalray, scip->set, scip->stat, var);
4458}
4459
4460/** updates the primal ray thats proves unboundedness
4461 *
4462 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
4463 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
4464 *
4465 * @pre This method can be called if @p scip is in one of the following stages:
4466 * - \ref SCIP_STAGE_PRESOLVING
4467 * - \ref SCIP_STAGE_PRESOLVED
4468 * - \ref SCIP_STAGE_SOLVING
4469 * - \ref SCIP_STAGE_SOLVED
4470 *
4471 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
4472 */
4474 SCIP* scip, /**< SCIP data structure */
4475 SCIP_SOL* primalray /**< the new primal ray */
4476 )
4477{
4478 assert(scip != NULL);
4479 assert(primalray != NULL);
4480
4481 SCIP_CALL( SCIPcheckStage(scip, "SCIPupdatePrimalRay", FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE) );
4482
4483 SCIP_CALL( SCIPprimalUpdateRay(scip->primal, scip->set, scip->stat, primalray, scip->mem->probmem) );
4484
4485 return SCIP_OKAY;
4486}
4487
4488/** overwrite the fp-values in a solution with the rounded exact ones */
4490 SCIP* scip, /**< SCIP data structure */
4491 SCIP_SOL* sol /**< primal CIP solution */
4492 )
4493{
4494 assert(scip != NULL);
4495 assert(sol != NULL);
4496 assert(sol->scip == scip);
4497
4498 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPoverwriteFPsol", FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
4499
4500 SCIP_CALL( SCIPsolOverwriteFPSolWithExact(sol, scip->set, scip->stat, scip->origprob, scip->transprob, scip->tree) );
4501
4502 return SCIP_OKAY;
4503}
4504
4505/** checks exact primal solution; if feasible, adds it to storage; solution is freed afterwards
4506 *
4507 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
4508 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
4509 *
4510 * @pre This method can be called if SCIP is in one of the following stages:
4511 * - \ref SCIP_STAGE_TRANSFORMED
4512 * - \ref SCIP_STAGE_INITPRESOLVE
4513 * - \ref SCIP_STAGE_PRESOLVING
4514 * - \ref SCIP_STAGE_EXITPRESOLVE
4515 * - \ref SCIP_STAGE_PRESOLVED
4516 * - \ref SCIP_STAGE_SOLVING
4517 *
4518 * @note Do not call during propagation, use heur_trysol instead.
4519 */
4521 SCIP* scip, /**< SCIP data structure */
4522 SCIP_SOL** sol, /**< pointer to primal CIP solution; is cleared in function call */
4523 SCIP_Bool printreason, /**< Should all reasons of violations be printed */
4524 SCIP_Bool completely, /**< Should all violations be checked if printreason is true? */
4525 SCIP_Bool checkbounds, /**< Should the bounds of the variables be checked? */
4526 SCIP_Bool checkintegrality, /**< Has integrality to be checked? */
4527 SCIP_Bool checklprows, /**< Do constraints represented by rows in the current LP have to be checked? */
4528 SCIP_Bool* stored /**< stores whether solution was feasible and good enough to keep */
4529 )
4530{
4531 SCIP_SOL* bestsol;
4532
4533 assert(stored != NULL);
4534 assert(sol != NULL);
4535 assert(*sol != NULL);
4536 assert((*sol)->scip == scip);
4537
4538 SCIP_CALL( SCIPcheckStage(scip, "SCIPtrySolFreeExact", FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
4539
4540 bestsol = SCIPgetBestSol(scip);
4541
4542 if( !printreason )
4543 completely = FALSE;
4544
4545 /* we cannot check partial solutions */
4546 if( SCIPsolIsPartial(*sol) )
4547 {
4548 SCIPerrorMessage("Cannot check feasibility of partial solutions.\n");
4549 return SCIP_INVALIDDATA;
4550 }
4551
4552 /* if the solution is added during presolving and it is not defined on original variables,
4553 * presolving operations will destroy its validity, so we retransform it to the original space
4554 */
4555 if( scip->set->stage == SCIP_STAGE_PRESOLVING && !SCIPsolIsOriginal(*sol) )
4556 {
4557 SCIP_Bool hasinfval;
4558
4559 SCIP_CALL( SCIPsolUnlink(*sol, scip->set, scip->transprob) );
4560 SCIP_CALL( SCIPsolRetransform(*sol, scip->set, scip->stat, scip->origprob, scip->transprob, &hasinfval) );
4561 }
4562
4563 if( SCIPsolIsOriginal(*sol) )
4564 {
4565 SCIP_Bool feasible;
4566
4567 /* SCIPprimalTrySol() can only be called on transformed solutions; therefore check solutions in original problem
4568 * including modifiable constraints
4569 */
4570 SCIP_CALL( checkSolOrig(scip, *sol, &feasible, printreason, completely, checkbounds, checkintegrality, checklprows, TRUE) );
4571
4572 if( feasible )
4573 {
4574 SCIP_CALL( SCIPprimalAddSolFreeExact(scip->primal, scip->mem->probmem, scip->set, scip->messagehdlr, scip->stat,
4575 scip->origprob, scip->transprob, scip->tree, scip->reopt, scip->lpexact, scip->eventqueue, scip->eventfilter,
4576 sol, stored) );
4577
4578 if( *stored )
4579 {
4580 if( bestsol != SCIPgetBestSol(scip) )
4581 {
4583 }
4584 }
4585 }
4586 else
4587 {
4588 SCIP_CALL( SCIPsolFree(sol, scip->mem->probmem, scip->primal) );
4589 *stored = FALSE;
4590 }
4591 }
4592 else
4593 {
4594 SCIP_CALL( SCIPprimalTrySolFreeExact(scip->primal, scip->mem->probmem, scip->set, scip->messagehdlr, scip->stat,
4595 scip->origprob, scip->transprob, scip->tree, scip->reopt, scip->lpexact, scip->eventqueue, scip->eventfilter,
4596 sol, printreason, completely, checkbounds, checkintegrality, checklprows, stored) );
4597
4598 if( *stored )
4599 {
4600 if( bestsol != SCIPgetBestSol(scip) )
4601 {
4603 }
4604 }
4605 }
4606
4607 return SCIP_OKAY;
4608}
SCIP_VAR * h
Definition: circlepacking.c:68
SCIP_RETCODE SCIPconsGetNVars(SCIP_CONS *cons, SCIP_SET *set, int *nvars, SCIP_Bool *success)
Definition: cons.c:6554
SCIP_RETCODE SCIPconsCheck(SCIP_CONS *cons, SCIP_SET *set, SCIP_SOL *sol, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool printreason, SCIP_RESULT *result)
Definition: cons.c:7599
SCIP_CONS * SCIPconsGetTransformed(SCIP_CONS *cons)
Definition: cons.c:7021
SCIP_RETCODE SCIPconshdlrCheck(SCIP_CONSHDLR *conshdlr, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_SOL *sol, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool printreason, SCIP_Bool completely, SCIP_RESULT *result)
Definition: cons.c:3838
internal methods for constraints and constraint handlers
Constraint handler for linear constraints in their most general form, .
methods for debugging
#define SCIPcheckStage(scip, method, init, problem, transforming, transformed, initpresolve, presolving, exitpresolve, presolved, initsolve, solving, solved, exitsolve, freetrans, freescip)
Definition: debug.h:364
#define NULL
Definition: def.h:248
#define SCIP_MAXSTRLEN
Definition: def.h:269
#define SCIP_Longint
Definition: def.h:141
#define SCIP_INVALID
Definition: def.h:178
#define SCIP_Bool
Definition: def.h:91
#define SCIP_Real
Definition: def.h:156
#define SCIP_UNKNOWN
Definition: def.h:179
#define TRUE
Definition: def.h:93
#define FALSE
Definition: def.h:94
#define SCIP_CALL_ABORT(x)
Definition: def.h:334
#define SCIPABORT()
Definition: def.h:327
#define REALABS(x)
Definition: def.h:182
#define SCIP_CALL(x)
Definition: def.h:355
#define SCIP_CALL_FINALLY(x, y)
Definition: def.h:397
SCIP_FILE * SCIPfopen(const char *path, const char *mode)
Definition: fileio.c:153
int SCIPfeof(SCIP_FILE *stream)
Definition: fileio.c:227
int SCIPfclose(SCIP_FILE *fp)
Definition: fileio.c:232
char * SCIPfgets(char *s, int size, SCIP_FILE *stream)
Definition: fileio.c:200
SCIP_Real SCIPgetDualsolLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_Real SCIPgetRhsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_VAR ** SCIPgetVarsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPaddCoefLinear(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real val)
SCIP_Real SCIPgetLhsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_Real * SCIPgetValsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPcreateConsBasicLinear(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, SCIP_VAR **vars, SCIP_Real *vals, SCIP_Real lhs, SCIP_Real rhs)
SCIP_RETCODE SCIPcopyOrig(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, const char *suffix, SCIP_Bool enablepricing, SCIP_Bool threadsafe, SCIP_Bool passmessagehdlr, SCIP_Bool *valid)
Definition: scip_copy.c:3044
SCIP_Bool SCIPisTransformed(SCIP *scip)
Definition: scip_general.c:647
SCIP_RETCODE SCIPfree(SCIP **scip)
Definition: scip_general.c:402
SCIP_RETCODE SCIPcreate(SCIP **scip)
Definition: scip_general.c:370
SCIP_STAGE SCIPgetStage(SCIP *scip)
Definition: scip_general.c:444
SCIP_RETCODE SCIPaddVar(SCIP *scip, SCIP_VAR *var)
Definition: scip_prob.c:1907
SCIP_RETCODE SCIPgetOrigVarsData(SCIP *scip, SCIP_VAR ***vars, int *nvars, int *nbinvars, int *nintvars, int *nimplvars, int *ncontvars)
Definition: scip_prob.c:2753
int SCIPgetNVars(SCIP *scip)
Definition: scip_prob.c:2246
SCIP_RETCODE SCIPaddCons(SCIP *scip, SCIP_CONS *cons)
Definition: scip_prob.c:3274
SCIP_OBJSENSE SCIPgetObjsense(SCIP *scip)
Definition: scip_prob.c:1400
int SCIPgetNFixedVars(SCIP *scip)
Definition: scip_prob.c:2705
SCIP_VAR ** SCIPgetFixedVars(SCIP *scip)
Definition: scip_prob.c:2662
SCIP_VAR * SCIPfindVar(SCIP *scip, const char *name)
Definition: scip_prob.c:3189
SCIP_RETCODE SCIPreadProb(SCIP *scip, const char *filename, const char *extension)
Definition: scip_prob.c:341
void SCIPhashmapFree(SCIP_HASHMAP **hashmap)
Definition: misc.c:3095
void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin)
Definition: misc.c:3284
SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize)
Definition: misc.c:3061
void SCIPhashsetFree(SCIP_HASHSET **hashset, BMS_BLKMEM *blkmem)
Definition: misc.c:3833
void ** SCIPhashsetGetSlots(SCIP_HASHSET *hashset)
Definition: misc.c:4051
int SCIPhashsetGetNSlots(SCIP_HASHSET *hashset)
Definition: misc.c:4043
SCIP_RETCODE SCIPhashsetInsert(SCIP_HASHSET *hashset, BMS_BLKMEM *blkmem, void *element)
Definition: misc.c:3843
SCIP_RETCODE SCIPhashsetCreate(SCIP_HASHSET **hashset, BMS_BLKMEM *blkmem, int size)
Definition: misc.c:3802
void SCIPverbMessage(SCIP *scip, SCIP_VERBLEVEL msgverblevel, FILE *file, const char *formatstr,...)
Definition: scip_message.c:225
#define SCIPdebugMsg
Definition: scip_message.h:78
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
Definition: scip_message.c:120
SCIP_Real SCIPrelDiff(SCIP_Real val1, SCIP_Real val2)
Definition: misc.c:11162
SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value)
Definition: scip_param.c:487
const char * SCIPconshdlrGetName(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4316
SCIP_Bool SCIPconshdlrNeedsCons(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:5302
int SCIPconshdlrGetCheckPriority(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:5262
SCIP_CONSHDLR * SCIPconsGetHdlr(SCIP_CONS *cons)
Definition: cons.c:8409
SCIP_Bool SCIPconsIsChecked(SCIP_CONS *cons)
Definition: cons.c:8588
SCIP_Bool SCIPconsIsTransformed(SCIP_CONS *cons)
Definition: cons.c:8698
const char * SCIPconsGetName(SCIP_CONS *cons)
Definition: cons.c:8389
SCIP_Bool SCIPconsIsModifiable(SCIP_CONS *cons)
Definition: cons.c:8638
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
Definition: scip_cons.c:1173
SCIP_Bool SCIPisExact(SCIP *scip)
Definition: scip_exact.c:193
SCIP_Bool SCIPlpExactIsSolved(SCIP *scip)
Definition: scip_lpexact.c:456
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
Definition: scip_mem.c:57
BMS_BUFMEM * SCIPbuffer(SCIP *scip)
Definition: scip_mem.c:72
#define SCIPallocBufferArray(scip, ptr, num)
Definition: scip_mem.h:124
#define SCIPfreeBufferArray(scip, ptr)
Definition: scip_mem.h:136
SCIP_Bool SCIPisNLPConstructed(SCIP *scip)
Definition: scip_nlp.c:110
SCIP_Real SCIPrationalGetReal(SCIP_RATIONAL *rational)
Definition: rational.cpp:2085
SCIP_RETCODE SCIPrationalCreateString(BMS_BLKMEM *mem, SCIP_RATIONAL **rational, const char *desc)
Definition: rational.cpp:796
SCIP_Bool SCIPrationalIsString(const char *desc)
Definition: rational.cpp:652
void SCIPrationalFreeBlock(BMS_BLKMEM *mem, SCIP_RATIONAL **rational)
Definition: rational.cpp:461
int SCIPrationalToString(SCIP_RATIONAL *rational, char *str, int strlen)
Definition: rational.cpp:1743
SCIP_Bool SCIPrationalIsLT(SCIP_RATIONAL *rat1, SCIP_RATIONAL *rat2)
Definition: rational.cpp:1503
void SCIPrationalSetReal(SCIP_RATIONAL *res, SCIP_Real real)
Definition: rational.cpp:603
SCIP_Bool SCIPrationalIsGT(SCIP_RATIONAL *rat1, SCIP_RATIONAL *rat2)
Definition: rational.cpp:1474
void SCIPrationalFreeBuffer(BMS_BUFMEM *bufmem, SCIP_RATIONAL **rational)
Definition: rational.cpp:473
SCIP_RETCODE SCIPrationalCreateBuffer(BMS_BUFMEM *bufmem, SCIP_RATIONAL **rational)
Definition: rational.cpp:123
void SCIPrationalSetRational(SCIP_RATIONAL *res, SCIP_RATIONAL *src)
Definition: rational.cpp:569
int SCIPrationalStrLen(SCIP_RATIONAL *rational)
Definition: rational.cpp:1774
SCIP_RETCODE SCIPcheckSolOrig(SCIP *scip, SCIP_SOL *sol, SCIP_Bool *feasible, SCIP_Bool printreason, SCIP_Bool completely)
Definition: scip_sol.c:4380
SCIP_SOL * SCIPgetBestSol(SCIP *scip)
Definition: scip_sol.c:2981
SCIP_RETCODE SCIPcreateSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip_sol.c:516
SCIP_SOLORIGIN SCIPsolGetOrigin(SCIP_SOL *sol)
Definition: sol.c:4130
SCIP_RETCODE SCIPlinkPseudoSol(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:1418
int SCIPgetSolRunnum(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:2189
SCIP_RETCODE SCIPreadSolFile(SCIP *scip, const char *filename, SCIP_SOL *sol, SCIP_Bool xml, SCIP_Bool *partial, SCIP_Bool *error)
Definition: scip_sol.c:3802
SCIP_RETCODE SCIPcreateUnknownSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip_sol.c:799
SCIP_RETCODE SCIPprintTransSol(SCIP *scip, SCIP_SOL *sol, FILE *file, SCIP_Bool printzeros)
Definition: scip_sol.c:2521
SCIP_Real SCIPsolGetOrigObj(SCIP_SOL *sol)
Definition: sol.c:4170
SCIP_RETCODE SCIPcreateSolCopy(SCIP *scip, SCIP_SOL **sol, SCIP_SOL *sourcesol)
Definition: scip_sol.c:884
void SCIPupdateSolIntegralityViolation(SCIP *scip, SCIP_SOL *sol, SCIP_Real absviol)
Definition: scip_sol.c:406
SCIP_RETCODE SCIPprintBestSol(SCIP *scip, FILE *file, SCIP_Bool printzeros)
Definition: scip_sol.c:3047
SCIP_SOL ** SCIPgetPartialSols(SCIP *scip)
Definition: scip_sol.c:4263
void SCIPupdateSolLPRowViolation(SCIP *scip, SCIP_SOL *sol, SCIP_Real absviol, SCIP_Real relviol)
Definition: scip_sol.c:437
SCIP_RETCODE SCIPfreeSol(SCIP *scip, SCIP_SOL **sol)
Definition: scip_sol.c:1252
SCIP_HEUR * SCIPgetSolHeur(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:2249
void SCIPupdateSolBoundViolation(SCIP *scip, SCIP_SOL *sol, SCIP_Real absviol, SCIP_Real relviol)
Definition: scip_sol.c:421
SCIP_RETCODE SCIPaddSolFree(SCIP *scip, SCIP_SOL **sol, SCIP_Bool *stored)
Definition: scip_sol.c:3909
SCIP_RETCODE SCIPprintRay(SCIP *scip, SCIP_SOL *sol, FILE *file, SCIP_Bool printzeros)
Definition: scip_sol.c:2845
SCIP_RETCODE SCIPprintSol(SCIP *scip, SCIP_SOL *sol, FILE *file, SCIP_Bool printzeros)
Definition: scip_sol.c:2349
SCIP_RETCODE SCIPtrySolFreeExact(SCIP *scip, SCIP_SOL **sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored)
Definition: scip_sol.c:4520
SCIP_RETCODE SCIPsetSolValExact(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var, SCIP_RATIONAL *val)
Definition: scip_sol.c:1616
SCIP_Real SCIPsolGetTime(SCIP_SOL *sol)
Definition: sol.c:4219
SCIP_RETCODE SCIPcreateCurrentSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip_sol.c:749
SCIP_RETCODE SCIPgetDualSolVal(SCIP *scip, SCIP_CONS *cons, SCIP_Real *dualsolval, SCIP_Bool *boundconstraint)
Definition: scip_sol.c:2623
void SCIPgetSolValExact(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var, SCIP_RATIONAL *res)
Definition: scip_sol.c:1803
SCIP_Bool SCIPareSolsEqual(SCIP *scip, SCIP_SOL *sol1, SCIP_SOL *sol2)
Definition: scip_sol.c:2280
SCIP_RETCODE SCIPclearSol(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:1475
SCIP_Longint SCIPsolGetNodenum(SCIP_SOL *sol)
Definition: sol.c:4239
SCIP_RETCODE SCIPcreateNLPSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip_sol.c:664
SCIP_Real SCIPtransformObj(SCIP *scip, SCIP_Real obj)
Definition: scip_sol.c:2107
SCIP_RETCODE SCIPoverwriteFPsol(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:4489
int SCIPgetNPartialSols(SCIP *scip)
Definition: scip_sol.c:4285
int SCIPgetNSols(SCIP *scip)
Definition: scip_sol.c:2882
SCIP_HEUR * SCIPsolGetHeur(SCIP_SOL *sol)
Definition: sol.c:4259
SCIP_RETCODE SCIPcreateLPSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip_sol.c:608
SCIP_RETCODE SCIPlinkCurrentSol(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:1441
SCIP_RETCODE SCIPcreateFiniteSolCopy(SCIP *scip, SCIP_SOL **sol, SCIP_SOL *sourcesol, SCIP_Bool *success)
Definition: scip_sol.c:1116
SCIP_RETCODE SCIPprintBestTransSol(SCIP *scip, FILE *file, SCIP_Bool printzeros)
Definition: scip_sol.c:3087
SCIP_RETCODE SCIPadjustImplicitSolVals(SCIP *scip, SCIP_SOL *sol, SCIP_Bool uselprows)
Definition: scip_sol.c:2305
SCIP_RETCODE SCIPaddCurrentSol(SCIP *scip, SCIP_HEUR *heur, SCIP_Bool *stored)
Definition: scip_sol.c:3972
SCIP_RETCODE SCIPcreateOrigSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip_sol.c:831
SCIP_RETCODE SCIPlinkLPSolExact(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:1324
SCIP_RETCODE SCIPunlinkSol(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:1506
SCIP_Bool SCIPsolIsOriginal(SCIP_SOL *sol)
Definition: sol.c:4140
SCIP_RETCODE SCIPcreateRelaxSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip_sol.c:699
SCIP_RETCODE SCIPprintMIPStart(SCIP *scip, SCIP_SOL *sol, FILE *file)
Definition: scip_sol.c:2580
SCIP_RETCODE SCIPreadSol(SCIP *scip, const char *filename)
Definition: scip_sol.c:3306
SCIP_RETCODE SCIPgetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
Definition: scip_sol.c:1846
SCIP_RETCODE SCIPrecomputeSolObj(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:2076
SCIP_RETCODE SCIPaddSol(SCIP *scip, SCIP_SOL *sol, SCIP_Bool *stored)
Definition: scip_sol.c:3842
SCIP_RETCODE SCIPincSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var, SCIP_Real incval)
Definition: scip_sol.c:1719
SCIP_RETCODE SCIPcreateSolCopyOrig(SCIP *scip, SCIP_SOL **sol, SCIP_SOL *sourcesol)
Definition: scip_sol.c:924
SCIP_RETCODE SCIPlinkNLPSol(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:1353
SCIP_RETCODE SCIProundSol(SCIP *scip, SCIP_SOL *sol, SCIP_Bool *success)
Definition: scip_sol.c:3123
SCIP_RETCODE SCIPcreatePartialSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip_sol.c:771
SCIP_Longint SCIPgetSolNodenum(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:2219
SCIP_Bool SCIPsolIsPartial(SCIP_SOL *sol)
Definition: sol.c:4160
SCIP_Real SCIPgetPrimalRayVal(SCIP *scip, SCIP_VAR *var)
Definition: scip_sol.c:4445
void SCIPgetSolTransObjExact(SCIP *scip, SCIP_SOL *sol, SCIP_RATIONAL *res)
Definition: scip_sol.c:2042
SCIP_RETCODE SCIPsetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
Definition: scip_sol.c:1662
void SCIPupdateSolConsViolation(SCIP *scip, SCIP_SOL *sol, SCIP_Real absviol, SCIP_Real relviol)
Definition: scip_sol.c:453
SCIP_SOL ** SCIPgetSols(SCIP *scip)
Definition: scip_sol.c:2931
SCIP_Bool SCIPhasPrimalRay(SCIP *scip)
Definition: scip_sol.c:4427
SCIP_RETCODE SCIPlinkRelaxSol(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:1388
int SCIPsolGetRunnum(SCIP_SOL *sol)
Definition: sol.c:4229
SCIP_RETCODE SCIPtrySol(SCIP *scip, SCIP_SOL *sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored)
Definition: scip_sol.c:4012
SCIP_RETCODE SCIPcheckSol(SCIP *scip, SCIP_SOL *sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *feasible)
Definition: scip_sol.c:4312
SCIP_Bool SCIPisDualSolAvailable(SCIP *scip, SCIP_Bool printreason)
Definition: scip_sol.c:2749
SCIP_RETCODE SCIPtrySolFree(SCIP *scip, SCIP_SOL **sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored)
Definition: scip_sol.c:4109
SCIP_RETCODE SCIPlinkLPSol(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:1295
SCIP_Real SCIPgetSolOrigObj(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:1892
SCIP_RETCODE SCIPretransformSol(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:3182
SCIP_Real SCIPgetSolTime(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:2159
SCIP_RETCODE SCIPcreateLPSolExact(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip_sol.c:636
void SCIPdeactivateSolViolationUpdates(SCIP *scip)
Definition: scip_sol.c:493
SCIP_RETCODE SCIPsetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var, SCIP_Real val)
Definition: scip_sol.c:1571
SCIP_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var)
Definition: scip_sol.c:1765
void SCIPactivateSolViolationUpdates(SCIP *scip)
Definition: scip_sol.c:485
SCIP_Real SCIPgetSolTransObj(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:2005
void SCIPupdateSolLPConsViolation(SCIP *scip, SCIP_SOL *sol, SCIP_Real absviol, SCIP_Real relviol)
Definition: scip_sol.c:469
SCIP_RETCODE SCIPupdatePrimalRay(SCIP *scip, SCIP_SOL *primalray)
Definition: scip_sol.c:4473
SCIP_Real SCIPretransformObj(SCIP *scip, SCIP_Real obj)
Definition: scip_sol.c:2132
SCIP_RETCODE SCIPprintSolExact(SCIP *scip, SCIP_SOL *sol, FILE *file, SCIP_Bool printzeros)
Definition: scip_sol.c:2424
SCIP_RETCODE SCIPcreateSolExact(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip_sol.c:566
SCIP_RETCODE SCIPcreatePseudoSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip_sol.c:726
SCIP_RETCODE SCIPmakeSolExact(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:3146
void SCIPgetSolOrigObjExact(SCIP *scip, SCIP_SOL *sol, SCIP_RATIONAL *res)
Definition: scip_sol.c:1940
SCIP_RETCODE SCIPretransformSolExact(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:3245
SCIP_RETCODE SCIPprintDualSol(SCIP *scip, FILE *file, SCIP_Bool printzeros)
Definition: scip_sol.c:2812
SCIP_Bool SCIPsolIsExact(SCIP_SOL *sol)
Definition: sol.c:4150
SCIP_RETCODE SCIPtryCurrentSol(SCIP *scip, SCIP_HEUR *heur, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored)
Definition: scip_sol.c:4207
SCIP_RETCODE SCIPunlinkSolExact(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:1537
SCIP_RETCODE SCIPsolve(SCIP *scip)
Definition: scip_solve.c:2635
void SCIPstoreSolutionGap(SCIP *scip)
SCIP_Real SCIPinfinity(SCIP *scip)
void SCIPprintReal(SCIP *scip, FILE *file, SCIP_Real val, int width, int precision)
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisFeasLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisFeasGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisZero(SCIP *scip, SCIP_Real val)
SCIP_Real SCIPepsilon(SCIP *scip)
SCIP_Real SCIPvarGetSol(SCIP_VAR *var, SCIP_Bool getlpval)
Definition: var.c:19007
SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
Definition: var.c:23386
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
Definition: var.c:24268
SCIP_Real SCIPvarGetLbOriginal(SCIP_VAR *var)
Definition: var.c:24020
SCIP_Bool SCIPvarIsTransformed(SCIP_VAR *var)
Definition: var.c:23430
SCIP_VAR * SCIPvarGetProbvar(SCIP_VAR *var)
Definition: var.c:17550
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
Definition: var.c:24142
SCIP_RATIONAL * SCIPvarGetLbOriginalExact(SCIP_VAR *var)
Definition: var.c:24040
SCIP_RATIONAL * SCIPvarGetUbOriginalExact(SCIP_VAR *var)
Definition: var.c:24083
const char * SCIPvarGetName(SCIP_VAR *var)
Definition: var.c:23267
SCIP_Real SCIPvarGetUbOriginal(SCIP_VAR *var)
Definition: var.c:24063
SCIP_RETCODE SCIPreleaseVar(SCIP *scip, SCIP_VAR **var)
Definition: scip_var.c:1887
SCIP_RETCODE SCIPchgVarType(SCIP *scip, SCIP_VAR *var, SCIP_VARTYPE vartype, SCIP_Bool *infeasible)
Definition: scip_var.c:10113
SCIP_Real SCIPvarGetLPSol(SCIP_VAR *var)
Definition: var.c:24664
void SCIPvarGetSolExact(SCIP_VAR *var, SCIP_RATIONAL *res, SCIP_Bool getlpval)
Definition: var.c:19019
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
Definition: var.c:24234
SCIP_RETCODE SCIPcreateVar(SCIP *scip, SCIP_VAR **var, const char *name, SCIP_Real lb, SCIP_Real ub, SCIP_Real obj, SCIP_VARTYPE vartype, SCIP_Bool initial, SCIP_Bool removable, SCIP_DECL_VARDELORIG((*vardelorig)), SCIP_DECL_VARTRANS((*vartrans)), SCIP_DECL_VARDELTRANS((*vardeltrans)), SCIP_DECL_VARCOPY((*varcopy)), SCIP_VARDATA *vardata)
Definition: scip_var.c:120
SCIP_Real SCIPgetVarRedcost(SCIP *scip, SCIP_VAR *var)
Definition: scip_var.c:2608
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
Definition: var.c:24120
SCIP_RETCODE SCIPfixVar(SCIP *scip, SCIP_VAR *var, SCIP_Real fixedval, SCIP_Bool *infeasible, SCIP_Bool *fixed)
Definition: scip_var.c:10318
SCIP_RETCODE SCIPgetVarSols(SCIP *scip, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
Definition: scip_var.c:3071
SCIP_RETCODE SCIPchgVarObj(SCIP *scip, SCIP_VAR *var, SCIP_Real newobj)
Definition: scip_var.c:5372
int SCIPsnprintf(char *t, int len, const char *s,...)
Definition: misc.c:10827
SCIP_Bool SCIPstrToRealValue(const char *str, SCIP_Real *value, char **endptr)
Definition: misc.c:10955
void SCIPprintSysError(const char *message)
Definition: misc.c:10719
int SCIPstrncasecmp(const char *s1, const char *s2, int length)
Definition: misc.c:10876
char * SCIPstrtok(char *s, const char *delim, char **ptrptr)
Definition: misc.c:10768
SCIP_Real SCIPlpGetObjval(SCIP_LP *lp, SCIP_SET *set, SCIP_PROB *prob)
Definition: lp.c:13436
SCIP_Bool SCIPlpIsSolved(SCIP_LP *lp)
Definition: lp.c:18211
SCIP_Real SCIPlpGetPseudoObjval(SCIP_LP *lp, SCIP_SET *set, SCIP_PROB *prob)
Definition: lp.c:13619
internal methods for LP management
void SCIPlpExactGetPseudoObjval(SCIP_LPEXACT *lpexact, SCIP_SET *set, SCIP_RATIONAL *res)
Definition: lpexact.c:7438
void SCIPlpExactGetObjval(SCIP_LPEXACT *lpexact, SCIP_SET *set, SCIP_RATIONAL *res)
Definition: lpexact.c:7416
internal methods for exact LP management
memory allocation routines
void SCIPmessageFPrintInfo(SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char *formatstr,...)
Definition: message.c:618
void SCIPmessagePrintInfo(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr,...)
Definition: message.c:594
void SCIPmessagehdlrSetQuiet(SCIP_MESSAGEHDLR *messagehdlr, SCIP_Bool quiet)
Definition: message.c:411
SCIP_Bool SCIPmessagehdlrIsQuiet(SCIP_MESSAGEHDLR *messagehdlr)
Definition: message.c:910
SCIP_Bool SCIPnlpHasSolution(SCIP_NLP *nlp)
Definition: nlp.c:4544
SCIP_NLPSOLSTAT SCIPnlpGetSolstat(SCIP_NLP *nlp)
Definition: nlp.c:4503
internal methods for NLP management
SCIP_RETCODE SCIPprimalAddCurrentSol(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_HEUR *heur, SCIP_Bool *stored)
Definition: primal.c:1793
void SCIPprimalSetUpdateViolations(SCIP_PRIMAL *primal, SCIP_Bool updateviolations)
Definition: primal.c:2311
SCIP_RETCODE SCIPprimalUpdateRay(SCIP_PRIMAL *primal, SCIP_SET *set, SCIP_STAT *stat, SCIP_SOL *primalray, BMS_BLKMEM *blkmem)
Definition: primal.c:810
SCIP_RETCODE SCIPprimalTrySolFreeExact(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LPEXACT *lpexact, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_SOL **sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored)
Definition: primal.c:2382
SCIP_RETCODE SCIPprimalAddOrigSolFree(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_SOL **sol, SCIP_Bool *stored)
Definition: primal.c:1709
SCIP_RETCODE SCIPprimalTryCurrentSol(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_HEUR *heur, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored)
Definition: primal.c:1967
SCIP_RETCODE SCIPprimalTrySolFree(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_SOL **sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored)
Definition: primal.c:1893
SCIP_Bool SCIPprimalUpdateViolations(SCIP_PRIMAL *primal)
Definition: primal.c:2301
SCIP_RETCODE SCIPprimalAddOrigSol(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_SOL *sol, SCIP_Bool *stored)
Definition: primal.c:1654
SCIP_RETCODE SCIPprimalTrySol(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_SOL *sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored)
Definition: primal.c:1823
SCIP_RETCODE SCIPprimalAddSolFree(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_SOL **sol, SCIP_Bool *stored)
Definition: primal.c:1599
SCIP_RETCODE SCIPprimalAddSol(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LP *lp, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_SOL *sol, SCIP_Bool *stored)
Definition: primal.c:1523
SCIP_RETCODE SCIPprimalAddSolFreeExact(SCIP_PRIMAL *primal, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_TREE *tree, SCIP_REOPT *reopt, SCIP_LPEXACT *lpexact, SCIP_EVENTQUEUE *eventqueue, SCIP_EVENTFILTER *eventfilter, SCIP_SOL **sol, SCIP_Bool *stored)
Definition: primal.c:2449
internal methods for collecting primal CIP solutions and primal informations
SCIP_Real SCIPprobExternObjval(SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_SET *set, SCIP_Real objval)
Definition: prob.c:2520
void SCIPprobExternObjvalExact(SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_SET *set, SCIP_RATIONAL *objval, SCIP_RATIONAL *objvalext)
Definition: prob.c:2546
SCIP_Real SCIPprobInternObjval(SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_SET *set, SCIP_Real objval)
Definition: prob.c:2573
internal methods for storing and manipulating the main problem
public methods for managing constraints
wrapper functions to map file i/o to standard or zlib file i/o
struct SCIP_File SCIP_FILE
Definition: pub_fileio.h:43
public methods for message output
#define SCIPerrorMessage
Definition: pub_message.h:64
public data structures and miscellaneous methods
public methods for primal CIP solutions
public methods for problem variables
SCIP_Bool SCIPrelaxationIsSolValid(SCIP_RELAXATION *relaxation)
Definition: relax.c:823
internal methods for relaxators
public methods for constraint handler plugins and constraints
public methods for problem copies
public methods for exact solving
general public methods
public methods for the LP relaxation, rows and columns
public methods for memory management
public methods for message handling
public methods for nonlinear relaxation
public methods for numerical tolerances
public methods for SCIP parameter handling
public methods for global and local (sub)problems
static SCIP_RETCODE checkSolOrig(SCIP *scip, SCIP_SOL *sol, SCIP_Bool *feasible, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool checkmodifiable)
Definition: scip_sol.c:101
static SCIP_RETCODE printDualSol(SCIP *scip, FILE *file, SCIP_Bool printzeros)
Definition: scip_sol.c:2693
static SCIP_RETCODE checkSolOrigExact(SCIP *scip, SCIP_SOL *sol, SCIP_Bool *feasible, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool checkmodifiable)
Definition: scip_sol.c:255
static SCIP_RETCODE readSolFile(SCIP *scip, const char *filename, SCIP_SOL *sol, SCIP_Bool *partial, SCIP_Bool *error)
Definition: scip_sol.c:3321
static SCIP_RETCODE setupAndSolveFiniteSolSubscip(SCIP *scip, SCIP *subscip, SCIP_VAR **origvars, int norigvars, SCIP_Real *solvals, SCIP_Bool *success)
Definition: scip_sol.c:965
static SCIP_RETCODE readXmlSolFile(SCIP *scip, const char *filename, SCIP_SOL *sol, SCIP_Bool *partial, SCIP_Bool *error)
Definition: scip_sol.c:3555
public methods for solutions
public solving methods
public methods for querying solving statistics
public methods for SCIP variables
SCIP_Bool SCIPsetIsFeasGT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:7017
SCIP_Bool SCIPsetIsEQ(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6537
SCIP_Bool SCIPsetIsFeasLT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6969
internal methods for global SCIP settings
SCIP_RETCODE SCIPsolCreateRelaxSol(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_RELAXATION *relaxation, SCIP_HEUR *heur)
Definition: sol.c:914
void SCIPsolUpdateConsViolation(SCIP_SOL *sol, SCIP_Real absviolcons, SCIP_Real relviolcons)
Definition: sol.c:3941
SCIP_RETCODE SCIPsolMakeReal(SCIP_SOL *sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob)
Definition: sol.c:2906
SCIP_RETCODE SCIPsolLinkPseudoSol(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_TREE *tree, SCIP_LP *lp)
Definition: sol.c:1318
SCIP_RETCODE SCIPsolCreatePartial(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PRIMAL *primal, SCIP_HEUR *heur)
Definition: sol.c:1039
SCIP_RETCODE SCIPsolCreateUnknown(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_HEUR *heur)
Definition: sol.c:1079
void SCIPsolUpdateBoundViolation(SCIP_SOL *sol, SCIP_Real absviolbounds, SCIP_Real relviolbounds)
Definition: sol.c:3915
void SCIPsolGetValExact(SCIP_RATIONAL *res, SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_VAR *var)
Definition: sol.c:2039
SCIP_RETCODE SCIPsolCreateNLPSol(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_NLP *nlp, SCIP_HEUR *heur)
Definition: sol.c:893
SCIP_RETCODE SCIPsolMakeExact(SCIP_SOL *sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob)
Definition: sol.c:2870
SCIP_RETCODE SCIPsolLinkCurrentSol(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_TREE *tree, SCIP_LP *lp)
Definition: sol.c:1368
SCIP_RETCODE SCIPsolCheck(SCIP_SOL *sol, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, BMS_BLKMEM *blkmem, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *feasible)
Definition: sol.c:2669
SCIP_RETCODE SCIPsolMarkPartial(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_VAR **vars, int nvars)
Definition: sol.c:2312
SCIP_RETCODE SCIPsolCreateOriginal(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_HEUR *heur)
Definition: sol.c:514
SCIP_RETCODE SCIPsolSetValExact(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_VAR *var, SCIP_RATIONAL *val)
Definition: sol.c:1711
SCIP_RETCODE SCIPsolAdjustImplicitSolVals(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_TREE *tree, SCIP_Bool uselprows)
Definition: sol.c:712
SCIP_RETCODE SCIPsolFree(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_PRIMAL *primal)
Definition: sol.c:1133
SCIP_RETCODE SCIPsolRetransformExact(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_Bool *hasinfval)
Definition: sol.c:3103
void SCIPsolRecomputeObj(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *origprob)
Definition: sol.c:3221
SCIP_RETCODE SCIPsolOverwriteFPSolWithExact(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_TREE *tree)
Definition: sol.c:4037
void SCIPsolUpdateIntegralityViolation(SCIP_SOL *sol, SCIP_Real absviolintegrality)
Definition: sol.c:3904
void SCIPsolUpdateLPRowViolation(SCIP_SOL *sol, SCIP_Real absviollprows, SCIP_Real relviollprows)
Definition: sol.c:3928
SCIP_RETCODE SCIPsolLinkLPSolExact(SCIP_SOL *sol, SCIP_SET *set, SCIP_LPEXACT *lp)
Definition: sol.c:1214
SCIP_RETCODE SCIPsolIncVal(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_VAR *var, SCIP_Real incval)
Definition: sol.c:1832
SCIP_RETCODE SCIPsolLinkNLPSol(SCIP_SOL *sol, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_NLP *nlp)
Definition: sol.c:1237
SCIP_RETCODE SCIPsolPrintExact(SCIP_SOL *sol, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_PROB *transprob, FILE *file, SCIP_Bool mipstart, SCIP_Bool printzeros)
Definition: sol.c:3577
SCIP_RETCODE SCIPsolRetransform(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_Bool *hasinfval)
Definition: sol.c:2970
SCIP_RETCODE SCIPsolCreateCurrentSol(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_LP *lp, SCIP_HEUR *heur)
Definition: sol.c:985
SCIP_RETCODE SCIPsolRound(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_TREE *tree, SCIP_Bool *success)
Definition: sol.c:2797
SCIP_RETCODE SCIPsolSetVal(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_VAR *var, SCIP_Real val)
Definition: sol.c:1490
SCIP_RETCODE SCIPsolCreatePseudoSol(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_LP *lp, SCIP_HEUR *heur)
Definition: sol.c:940
SCIP_RETCODE SCIPsolClear(SCIP_SOL *sol, SCIP_STAT *stat, SCIP_TREE *tree)
Definition: sol.c:1394
SCIP_RETCODE SCIPsolCreateLPSol(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_LP *lp, SCIP_HEUR *heur)
Definition: sol.c:846
SCIP_RETCODE SCIPsolLinkRelaxSol(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_RELAXATION *relaxation)
Definition: sol.c:1288
SCIP_RETCODE SCIPsolCreateOriginalExact(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_HEUR *heur)
Definition: sol.c:555
SCIP_Real SCIPsolGetVal(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_VAR *var)
Definition: sol.c:1908
SCIP_RETCODE SCIPsolCreateExact(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_HEUR *heur)
Definition: sol.c:470
SCIP_RETCODE SCIPsolCreateCurrentSolExact(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_LPEXACT *lp, SCIP_HEUR *heur)
Definition: sol.c:1012
SCIP_RETCODE SCIPsolUnlink(SCIP_SOL *sol, SCIP_SET *set, SCIP_PROB *prob)
Definition: sol.c:1431
void SCIPsolGetObjExact(SCIP_SOL *sol, SCIP_SET *set, SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_RATIONAL *objval)
Definition: sol.c:2274
SCIP_Real SCIPsolGetRayVal(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_VAR *var)
Definition: sol.c:2188
SCIP_RETCODE SCIPsolPrintRay(SCIP_SOL *sol, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_PROB *transprob, FILE *file, SCIP_Bool printzeros)
Definition: sol.c:3766
void SCIPsolResetViolations(SCIP_SOL *sol)
Definition: sol.c:3888
void SCIPsolSetOrigin(SCIP_SOL *sol, SCIP_SOLORIGIN origin)
Definition: sol.c:3874
SCIP_RETCODE SCIPsolLinkLPSol(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_TREE *tree, SCIP_LP *lp)
Definition: sol.c:1156
SCIP_Bool SCIPsolsAreEqual(SCIP_SOL *sol1, SCIP_SOL *sol2, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob)
Definition: sol.c:3370
SCIP_RATIONAL * SCIPsolGetOrigObjExact(SCIP_SOL *sol)
Definition: sol.c:4181
SCIP_Real SCIPsolGetObj(SCIP_SOL *sol, SCIP_SET *set, SCIP_PROB *transprob, SCIP_PROB *origprob)
Definition: sol.c:2257
SCIP_RETCODE SCIPsolPrint(SCIP_SOL *sol, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_PROB *transprob, FILE *file, SCIP_Bool mipstart, SCIP_Bool printzeros)
Definition: sol.c:3441
SCIP_RETCODE SCIPsolCopy(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PRIMAL *primal, SCIP_SOL *sourcesol)
Definition: sol.c:583
SCIP_RETCODE SCIPsolCheckOrig(SCIP_SOL *sol, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, BMS_BLKMEM *blkmem, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_PRIMAL *primal, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool checkmodifiable, SCIP_Bool *feasible)
Definition: sol.c:2502
SCIP_RETCODE SCIPsolCreate(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_HEUR *heur)
Definition: sol.c:428
SCIP_RETCODE SCIPsolCreateLPSolExact(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_LPEXACT *lp, SCIP_HEUR *heur)
Definition: sol.c:871
void SCIPsolUpdateLPConsViolation(SCIP_SOL *sol, SCIP_Real absviol, SCIP_Real relviol)
Definition: sol.c:3954
SCIP_RETCODE SCIPsolUnlinkExact(SCIP_SOL *sol, SCIP_SET *set, SCIP_PROB *prob)
Definition: sol.c:1460
internal methods for storing primal CIP solutions
SCIP * scip
Definition: struct_sol.h:101
SCIP * scip
Definition: struct_var.h:345
data structures for LP management
datastructures for block memory pools and memory buffers
datastructures for collecting primal CIP solutions and primal informations
datastructures for storing and manipulating the main problem
SCIP main data structure.
datastructures for global SCIP settings
datastructures for storing primal CIP solutions
datastructures for problem statistics
datastructures for problem variables
SCIP_Bool SCIPtreeHasCurrentNodeLP(SCIP_TREE *tree)
Definition: tree.c:9496
internal methods for branch and bound tree
@ SCIP_VERBLEVEL_NONE
Definition: type_message.h:57
@ SCIP_VERBLEVEL_NORMAL
Definition: type_message.h:60
@ SCIP_NLPSOLSTAT_FEASIBLE
Definition: type_nlpi.h:162
@ SCIP_OBJSENSE_MAXIMIZE
Definition: type_prob.h:47
@ SCIP_FEASIBLE
Definition: type_result.h:45
enum SCIP_Result SCIP_RESULT
Definition: type_result.h:61
@ SCIP_NOFILE
Definition: type_retcode.h:47
@ SCIP_READERROR
Definition: type_retcode.h:45
@ SCIP_INVALIDDATA
Definition: type_retcode.h:52
@ SCIP_OKAY
Definition: type_retcode.h:42
@ SCIP_INVALIDCALL
Definition: type_retcode.h:51
@ SCIP_ERROR
Definition: type_retcode.h:43
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:63
@ SCIP_STAGE_PROBLEM
Definition: type_set.h:45
@ SCIP_STAGE_INITPRESOLVE
Definition: type_set.h:48
@ SCIP_STAGE_SOLVED
Definition: type_set.h:54
@ SCIP_STAGE_PRESOLVING
Definition: type_set.h:49
@ SCIP_STAGE_TRANSFORMED
Definition: type_set.h:47
@ SCIP_STAGE_INITSOLVE
Definition: type_set.h:52
@ SCIP_STAGE_EXITPRESOLVE
Definition: type_set.h:50
@ SCIP_STAGE_EXITSOLVE
Definition: type_set.h:55
@ SCIP_STAGE_INIT
Definition: type_set.h:44
@ SCIP_STAGE_FREE
Definition: type_set.h:57
@ SCIP_STAGE_FREETRANS
Definition: type_set.h:56
@ SCIP_STAGE_SOLVING
Definition: type_set.h:53
@ SCIP_STAGE_TRANSFORMING
Definition: type_set.h:46
@ SCIP_STAGE_PRESOLVED
Definition: type_set.h:51
@ SCIP_SOLORIGIN_ZERO
Definition: type_sol.h:43
@ SCIP_SOLORIGIN_UNKNOWN
Definition: type_sol.h:51
@ SCIP_SOLORIGIN_RELAXSOL
Definition: type_sol.h:46
@ SCIP_SOLORIGIN_PSEUDOSOL
Definition: type_sol.h:47
@ SCIP_SOLORIGIN_LPSOL
Definition: type_sol.h:44
@ SCIP_SOLORIGIN_PARTIAL
Definition: type_sol.h:48
@ SCIP_SOLORIGIN_ORIGINAL
Definition: type_sol.h:42
@ SCIP_SOLORIGIN_NLPSOL
Definition: type_sol.h:45
@ SCIP_VARTYPE_CONTINUOUS
Definition: type_var.h:71
@ SCIP_VARSTATUS_FIXED
Definition: type_var.h:54
@ SCIP_VARSTATUS_MULTAGGR
Definition: type_var.h:56
declarations for XML parsing
const char * SCIPxmlGetAttrval(const XML_NODE *node, const char *name)
Definition: xmlparse.c:1333
const XML_NODE * SCIPxmlFirstChild(const XML_NODE *node)
Definition: xmlparse.c:1465
const XML_NODE * SCIPxmlFindNodeMaxdepth(const XML_NODE *node, const char *name, int depth, int maxdepth)
Definition: xmlparse.c:1415
const XML_NODE * SCIPxmlNextSibl(const XML_NODE *node)
Definition: xmlparse.c:1445
void SCIPxmlFreeNode(XML_NODE *node)
Definition: xmlparse.c:1271
struct XML_NODE_struct XML_NODE
Definition: xml.h:50
XML_NODE * SCIPxmlProcess(const char *filename)
Definition: xmlparse.c:1089