SCIP Doxygen Documentation
 
Loading...
Searching...
No Matches
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-2023 Zuse Institute Berlin (ZIB) */
7/* */
8/* Licensed under the Apache License, Version 2.0 (the "License"); */
9/* you may not use this file except in compliance with the License. */
10/* You may obtain a copy of the License at */
11/* */
12/* http://www.apache.org/licenses/LICENSE-2.0 */
13/* */
14/* Unless required by applicable law or agreed to in writing, software */
15/* distributed under the License is distributed on an "AS IS" BASIS, */
16/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
17/* See the License for the specific language governing permissions and */
18/* limitations under the License. */
19/* */
20/* You should have received a copy of the Apache-2.0 license */
21/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */
22/* */
23/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24
25/**@file scip_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#if defined(_WIN32) || defined(_WIN64)
47#else
48#include <strings.h> /*lint --e{766}*/
49#endif
50
52#include "scip/cons.h"
53#include "scip/cons_linear.h"
54#include "scip/debug.h"
55#include "scip/lp.h"
56#include "scip/nlp.h"
57#include "scip/primal.h"
58#include "scip/prob.h"
59#include "scip/pub_cons.h"
60#include "scip/pub_fileio.h"
61#include "scip/pub_message.h"
62#include "scip/pub_misc.h"
63#include "scip/pub_sol.h"
64#include "scip/pub_var.h"
65#include "scip/relax.h"
66#include "scip/scip_cons.h"
67#include "scip/scip_copy.h"
68#include "scip/scip_general.h"
69#include "scip/scip_mem.h"
70#include "scip/scip_message.h"
71#include "scip/scip_nlp.h"
72#include "scip/scip_numerics.h"
73#include "scip/scip_param.h"
74#include "scip/scip_prob.h"
75#include "scip/scip_sol.h"
76#include "scip/scip_solve.h"
78#include "scip/scip_var.h"
79#include "scip/set.h"
80#include "scip/sol.h"
81#include "scip/struct_lp.h"
82#include "scip/struct_mem.h"
83#include "scip/struct_primal.h"
84#include "scip/struct_prob.h"
85#include "scip/struct_scip.h"
86#include "scip/struct_set.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{
114 int v;
115 int c;
116 int h;
117
118 assert(scip != NULL);
119 assert(sol != NULL);
120 assert(feasible != NULL);
121
123
124 *feasible = TRUE;
125
127
128 if( !printreason )
130
131 /* check bounds */
132 if( checkbounds )
133 {
134 for( v = 0; v < scip->origprob->nvars; ++v )
135 {
136 SCIP_VAR* var;
137 SCIP_Real solval;
138 SCIP_Real lb;
139 SCIP_Real ub;
140
141 var = scip->origprob->vars[v];
142 solval = SCIPsolGetVal(sol, scip->set, scip->stat, var);
143
146
147 SCIPupdateSolBoundViolation(scip, sol, lb - solval, SCIPrelDiff(lb, solval));
148 SCIPupdateSolBoundViolation(scip, sol, solval - ub, SCIPrelDiff(solval, ub));
149
150 if( SCIPsetIsFeasLT(scip->set, solval, lb) || SCIPsetIsFeasGT(scip->set, solval, ub) )
151 {
152 *feasible = FALSE;
153
154 if( printreason )
155 {
156 SCIPmessagePrintInfo(scip->messagehdlr, "solution violates original bounds of variable <%s> [%g,%g] solution value <%g>\n",
157 SCIPvarGetName(var), lb, ub, solval);
158 }
159
160 if( !completely )
161 return SCIP_OKAY;
162 }
163 }
164 }
165
166 /* call constraint handlers with positive or zero check priority that don't need constraints */
167 for( h = 0; h < scip->set->nconshdlrs; ++h )
168 {
169 if( SCIPconshdlrGetCheckPriority(scip->set->conshdlrs[h]) >= 0 )
170 {
171 if( !SCIPconshdlrNeedsCons(scip->set->conshdlrs[h]) )
172 {
173 SCIP_CALL( SCIPconshdlrCheck(scip->set->conshdlrs[h], scip->mem->probmem, scip->set, scip->stat, sol,
175
176 if( result != SCIP_FEASIBLE )
177 {
178 *feasible = FALSE;
179
180 if( !completely )
181 return SCIP_OKAY;
182 }
183 }
184 }
185 /* constraint handlers are sorted by priority, so we can break when reaching the first one with negative priority */
186 else
187 break;
188 }
189
190 /* check original constraints
191 *
192 * in general modifiable constraints can not be checked, because the variables to fulfill them might be missing in
193 * the original problem; however, if the solution comes from a heuristic during presolving modifiable constraints
194 * have to be checked;
195 */
196 for( c = 0; c < scip->origprob->nconss; ++c )
197 {
198 if( SCIPconsIsChecked(scip->origprob->conss[c]) && (checkmodifiable || !SCIPconsIsModifiable(scip->origprob->conss[c])) )
199 {
200 /* check solution */
201 SCIP_CALL( SCIPconsCheck(scip->origprob->conss[c], scip->set, sol,
203
204 if( result != SCIP_FEASIBLE )
205 {
206 *feasible = FALSE;
207
208 if( !completely )
209 return SCIP_OKAY;
210 }
211 }
212 }
213
214 /* call constraint handlers with negative check priority that don't need constraints;
215 * continue with the first constraint handler with negative priority which caused us to break in the above loop */
216 for( ; h < scip->set->nconshdlrs; ++h )
217 {
218 assert(SCIPconshdlrGetCheckPriority(scip->set->conshdlrs[h]) < 0);
219 if( !SCIPconshdlrNeedsCons(scip->set->conshdlrs[h]) )
220 {
221 SCIP_CALL( SCIPconshdlrCheck(scip->set->conshdlrs[h], scip->mem->probmem, scip->set, scip->stat, sol,
223
224 if( result != SCIP_FEASIBLE )
225 {
226 *feasible = FALSE;
227
228 if( !completely )
229 return SCIP_OKAY;
230 }
231 }
232 }
233
234 return SCIP_OKAY;
235}
236
237/** update integrality violation of a solution */
239 SCIP* scip, /**< SCIP data structure */
240 SCIP_SOL* sol, /**< primal CIP solution */
241 SCIP_Real absviol /**< absolute violation */
242 )
243{
244 if( SCIPprimalUpdateViolations(scip->origprimal) )
246}
247
248/** update bound violation of a solution */
250 SCIP* scip, /**< SCIP data structure */
251 SCIP_SOL* sol, /**< primal CIP solution */
252 SCIP_Real absviol, /**< absolute violation */
253 SCIP_Real relviol /**< relative violation */
254 )
255{
256 if( SCIPprimalUpdateViolations(scip->origprimal) )
258}
259
260/** update LP row violation of a solution */
262 SCIP* scip, /**< SCIP data structure */
263 SCIP_SOL* sol, /**< primal CIP solution */
264 SCIP_Real absviol, /**< absolute violation */
265 SCIP_Real relviol /**< relative violation */
266 )
267{
268 if( SCIPprimalUpdateViolations(scip->origprimal) )
270}
271
272/** update constraint violation of a solution */
274 SCIP* scip, /**< SCIP data structure */
275 SCIP_SOL* sol, /**< primal CIP solution */
276 SCIP_Real absviol, /**< absolute violation */
277 SCIP_Real relviol /**< relative violation */
278 )
279{
280 if( SCIPprimalUpdateViolations(scip->origprimal) )
282}
283
284/** update LP row and constraint violations of a solution */
286 SCIP* scip, /**< SCIP data structure */
287 SCIP_SOL* sol, /**< primal CIP solution */
288 SCIP_Real absviol, /**< absolute violation */
289 SCIP_Real relviol /**< relative violation */
290 )
291{
292 if( SCIPprimalUpdateViolations(scip->origprimal) )
294}
295
296/** allow violation updates */
298 SCIP* scip /**< SCIP data structure */
299 )
300{
302}
303
304/** disallow violation updates */
306 SCIP* scip /**< SCIP data structure */
307 )
308{
310}
311
312/** creates a primal solution, initialized to zero
313 *
314 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
315 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
316 *
317 * @pre This method can be called if SCIP is in one of the following stages:
318 * - \ref SCIP_STAGE_PROBLEM
319 * - \ref SCIP_STAGE_TRANSFORMING
320 * - \ref SCIP_STAGE_TRANSFORMED
321 * - \ref SCIP_STAGE_INITPRESOLVE
322 * - \ref SCIP_STAGE_PRESOLVING
323 * - \ref SCIP_STAGE_EXITPRESOLVE
324 * - \ref SCIP_STAGE_PRESOLVED
325 * - \ref SCIP_STAGE_INITSOLVE
326 * - \ref SCIP_STAGE_SOLVING
327 */
329 SCIP* scip, /**< SCIP data structure */
330 SCIP_SOL** sol, /**< pointer to store the solution */
331 SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
332 )
333{
335
336 switch( scip->set->stage )
337 {
339 SCIP_CALL( SCIPsolCreateOriginal(sol, scip->mem->probmem, scip->set, scip->stat, scip->origprob, scip->origprimal, NULL, heur) );
340 return SCIP_OKAY;
341
350 SCIP_CALL( SCIPsolCreate(sol, scip->mem->probmem, scip->set, scip->stat, scip->primal, scip->tree, heur) );
351 return SCIP_OKAY;
352
356 default:
357 SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
358 return SCIP_INVALIDDATA;
359 } /*lint !e788*/
360}
361
362/** creates a primal solution, initialized to the current LP solution
363 *
364 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
365 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
366 *
367 * @pre This method can be called if SCIP is in one of the following stages:
368 * - \ref SCIP_STAGE_SOLVING
369 */
371 SCIP* scip, /**< SCIP data structure */
372 SCIP_SOL** sol, /**< pointer to store the solution */
373 SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
374 )
375{
377
378 if( !SCIPtreeHasCurrentNodeLP(scip->tree) )
379 {
380 SCIPerrorMessage("LP solution does not exist\n");
381 return SCIP_INVALIDCALL;
382 }
383
384 SCIP_CALL( SCIPsolCreateLPSol(sol, scip->mem->probmem, scip->set, scip->stat, scip->transprob, scip->primal,
385 scip->tree, scip->lp, heur) );
386
387 return SCIP_OKAY;
388}
389
390/** creates a primal solution, initialized to the current NLP solution
391 *
392 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
393 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
394 *
395 * @pre This method can be called if SCIP is in one of the following stages:
396 * - \ref SCIP_STAGE_SOLVING
397 */
399 SCIP* scip, /**< SCIP data structure */
400 SCIP_SOL** sol, /**< pointer to store the solution */
401 SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
402 )
403{
405
407 {
408 SCIPerrorMessage("NLP does not exist\n");
409 return SCIP_INVALIDCALL;
410 }
411 assert(scip->nlp != NULL);
412
413 if( !SCIPnlpHasSolution(scip->nlp) )
414 {
415 SCIPerrorMessage("NLP solution does not exist\n");
416 return SCIP_INVALIDCALL;
417 }
418
419 SCIP_CALL( SCIPsolCreateNLPSol(sol, scip->mem->probmem, scip->set, scip->stat, scip->primal, scip->tree, scip->nlp,
420 heur) );
421
422 return SCIP_OKAY;
423}
424
425/** creates a primal solution, initialized to the current relaxation solution
426 *
427 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
428 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
429 *
430 * @pre This method can be called if SCIP is in one of the following stages:
431 * - \ref SCIP_STAGE_SOLVING
432 */
434 SCIP* scip, /**< SCIP data structure */
435 SCIP_SOL** sol, /**< pointer to store the solution */
436 SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
437 )
438{
440
441 if( !SCIPrelaxationIsSolValid(scip->relaxation) )
442 {
443 SCIPerrorMessage("relaxation solution is not valid\n");
444 return SCIP_INVALIDCALL;
445 }
446
447 SCIP_CALL( SCIPsolCreateRelaxSol(sol, scip->mem->probmem, scip->set, scip->stat, scip->primal, scip->tree, scip->relaxation, heur) );
448
449 return SCIP_OKAY;
450}
451
452/** creates a primal solution, initialized to the current pseudo solution
453 *
454 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
455 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
456 *
457 * @pre This method can be called if SCIP is in one of the following stages:
458 * - \ref SCIP_STAGE_SOLVING
459 */
461 SCIP* scip, /**< SCIP data structure */
462 SCIP_SOL** sol, /**< pointer to store the solution */
463 SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
464 )
465{
467
468 SCIP_CALL( SCIPsolCreatePseudoSol(sol, scip->mem->probmem, scip->set, scip->stat, scip->transprob, scip->primal,
469 scip->tree, scip->lp, heur) );
470
471 return SCIP_OKAY;
472}
473
474/** creates a primal solution, initialized to the current LP or pseudo solution, depending on whether the LP was solved
475 * at the current node
476 *
477 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
478 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
479 *
480 * @pre This method can be called if SCIP is in one of the following stages:
481 * - \ref SCIP_STAGE_SOLVING
482 */
484 SCIP* scip, /**< SCIP data structure */
485 SCIP_SOL** sol, /**< pointer to store the solution */
486 SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
487 )
488{
489 SCIP_CALL( SCIPcheckStage(scip, "SCIPcreateCurrentSol", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
490
491 SCIP_CALL( SCIPsolCreateCurrentSol(sol, scip->mem->probmem, scip->set, scip->stat, scip->transprob, scip->primal,
492 scip->tree, scip->lp, heur) );
493
494 return SCIP_OKAY;
495}
496
497/** creates a partial primal solution, initialized to unknown values
498 *
499 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
500 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
501 *
502 * @pre This method can be called if SCIP is in one of the following stages:
503 * - \ref SCIP_STAGE_PROBLEM
504 */
506 SCIP* scip, /**< SCIP data structure */
507 SCIP_SOL** sol, /**< pointer to store the solution */
508 SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
509 )
510{
511 SCIP_CALL( SCIPcheckStage(scip, "SCIPcreatePartialSol", FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE) );
512
513 SCIP_CALL( SCIPsolCreatePartial(sol, scip->mem->probmem, scip->set, scip->stat, scip->origprimal, heur) );
514
515 return SCIP_OKAY;
516}
517
518/** creates a primal solution, initialized to unknown values
519 *
520 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
521 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
522 *
523 * @pre This method can be called if SCIP is in one of the following stages:
524 * - \ref SCIP_STAGE_TRANSFORMING
525 * - \ref SCIP_STAGE_TRANSFORMED
526 * - \ref SCIP_STAGE_INITPRESOLVE
527 * - \ref SCIP_STAGE_PRESOLVING
528 * - \ref SCIP_STAGE_EXITPRESOLVE
529 * - \ref SCIP_STAGE_PRESOLVED
530 * - \ref SCIP_STAGE_INITSOLVE
531 * - \ref SCIP_STAGE_SOLVING
532 */
534 SCIP* scip, /**< SCIP data structure */
535 SCIP_SOL** sol, /**< pointer to store the solution */
536 SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
537 )
538{
539 SCIP_CALL( SCIPcheckStage(scip, "SCIPcreateUnknownSol", FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE) );
540
541 SCIP_CALL( SCIPsolCreateUnknown(sol, scip->mem->probmem, scip->set, scip->stat, scip->primal, scip->tree, heur) );
542
543 return SCIP_OKAY;
544}
545
546/** creates a primal solution living in the original problem space, initialized to zero;
547 * a solution in original space allows to set original variables to values that would be invalid in the
548 * transformed problem due to preprocessing fixings or aggregations
549 *
550 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
551 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
552 *
553 * @pre This method can be called if SCIP is in one of the following stages:
554 * - \ref SCIP_STAGE_PROBLEM
555 * - \ref SCIP_STAGE_TRANSFORMING
556 * - \ref SCIP_STAGE_TRANSFORMED
557 * - \ref SCIP_STAGE_INITPRESOLVE
558 * - \ref SCIP_STAGE_PRESOLVING
559 * - \ref SCIP_STAGE_EXITPRESOLVE
560 * - \ref SCIP_STAGE_PRESOLVED
561 * - \ref SCIP_STAGE_INITSOLVE
562 * - \ref SCIP_STAGE_SOLVING
563 * - \ref SCIP_STAGE_SOLVED
564 */
566 SCIP* scip, /**< SCIP data structure */
567 SCIP_SOL** sol, /**< pointer to store the solution */
568 SCIP_HEUR* heur /**< heuristic that found the solution (or NULL if it's from the tree) */
569 )
570{
571 SCIP_CALL( SCIPcheckStage(scip, "SCIPcreateOrigSol", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
572
573 switch( scip->set->stage )
574 {
576 SCIP_CALL( SCIPsolCreateOriginal(sol, scip->mem->probmem, scip->set, scip->stat, scip->origprob, scip->origprimal, NULL, heur) );
577 return SCIP_OKAY;
578
588 SCIP_CALL( SCIPsolCreateOriginal(sol, scip->mem->probmem, scip->set, scip->stat, scip->origprob, scip->primal, scip->tree, heur) );
589 return SCIP_OKAY;
590
593 default:
594 SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
595 return SCIP_INVALIDCALL;
596 } /*lint !e788*/
597}
598
599/** creates a copy of a primal solution; note that a copy of a linked solution is also linked and needs to be unlinked
600 * if it should stay unaffected from changes in the LP or pseudo 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_PROBLEM
607 * - \ref SCIP_STAGE_FREETRANS
608 * - \ref SCIP_STAGE_TRANSFORMING
609 * - \ref SCIP_STAGE_TRANSFORMED
610 * - \ref SCIP_STAGE_INITPRESOLVE
611 * - \ref SCIP_STAGE_PRESOLVING
612 * - \ref SCIP_STAGE_EXITPRESOLVE
613 * - \ref SCIP_STAGE_PRESOLVED
614 * - \ref SCIP_STAGE_INITSOLVE
615 * - \ref SCIP_STAGE_SOLVING
616 * - \ref SCIP_STAGE_SOLVED
617 */
619 SCIP* scip, /**< SCIP data structure */
620 SCIP_SOL** sol, /**< pointer to store the solution */
621 SCIP_SOL* sourcesol /**< primal CIP solution to copy */
622 )
623{
624 SCIP_CALL( SCIPcheckStage(scip, "SCIPcreateSolCopy", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
625
626 /* check if we want to copy the current solution, which is the same as creating a current solution */
627 if( sourcesol == NULL )
628 {
630 }
631 else
632 {
633 SCIP_CALL( SCIPsolCopy(sol, scip->mem->probmem, scip->set, scip->stat, scip->primal, sourcesol) );
634 }
635
636 return SCIP_OKAY;
637}
638
639/** creates a copy of a solution in the original primal solution space
640 *
641 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
642 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
643 *
644 * @pre This method can be called if SCIP is in one of the following stages:
645 * - \ref SCIP_STAGE_PROBLEM
646 * - \ref SCIP_STAGE_TRANSFORMING
647 * - \ref SCIP_STAGE_TRANSFORMED
648 * - \ref SCIP_STAGE_INITPRESOLVE
649 * - \ref SCIP_STAGE_PRESOLVING
650 * - \ref SCIP_STAGE_EXITPRESOLVE
651 * - \ref SCIP_STAGE_PRESOLVED
652 * - \ref SCIP_STAGE_INITSOLVE
653 * - \ref SCIP_STAGE_SOLVING
654 * - \ref SCIP_STAGE_SOLVED
655 * - \ref SCIP_STAGE_EXITSOLVE
656 * - \ref SCIP_STAGE_FREETRANS
657 */
659 SCIP* scip, /**< SCIP data structure */
660 SCIP_SOL** sol, /**< pointer to store the solution */
661 SCIP_SOL* sourcesol /**< primal CIP solution to copy */
662 )
663{
664 SCIP_CALL( SCIPcheckStage(scip, "SCIPcreateSolCopyOrig", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
665
666 /* check if we want to copy the current solution, which is the same as creating a current solution */
667 if( sourcesol == NULL )
668 {
670 }
671 else
672 {
673 switch( scip->set->stage )
674 {
686 SCIP_CALL( SCIPsolCopy(sol, scip->mem->probmem, scip->set, scip->stat, scip->origprimal, sourcesol) );
687 break;
688 default:
689 assert(FALSE); /*lint !e506*/
690 } /*lint !e788*/
691 }
692
693 return SCIP_OKAY;
694}
695
696/** helper method that sets up and solves the sub-SCIP for removing infinite values from solutions */
697static
699 SCIP* scip, /**< SCIP data structure */
700 SCIP* subscip, /**< SCIP data structure of sub-SCIP*/
701 SCIP_VAR** origvars, /**< original problem variables of main SCIP */
702 int norigvars, /**< number of original problem variables of main SCIP */
703 SCIP_Real* solvals, /**< array with solution values of variables; infinite ones are replaced */
704 SCIP_Bool* success /**< pointer to store if removing infinite values was successful */
705 )
706{
707 SCIP_HASHMAP* varmap;
709 SCIP_Real fixval;
710 SCIP_Bool valid;
711 SCIP_SOL* bestsol;
712 int v;
713
714 assert(scip != NULL);
715 assert(subscip != NULL);
716 assert(origvars != NULL);
717 assert(solvals != NULL);
718 assert(success != NULL);
719
720 /* copy the original problem to the sub-SCIP */
722 SCIP_CALL( SCIPcopyOrig(scip, subscip, varmap, NULL, "removeinffixings", TRUE, FALSE, TRUE, &valid) );
723
724 SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", (int)SCIP_VERBLEVEL_NONE) );
725
726 /* in the sub-SCIP, we try to minimize the absolute values of all variables with infinite values in the solution
727 * and fix all other variables to the value they have in the solution
728 */
729 for( v = 0; v < norigvars; ++v )
730 {
731 varcopy = (SCIP_VAR*) SCIPhashmapGetImage(varmap, (void*)origvars[v]);
732 assert(varcopy != NULL);
733
734 fixval = solvals[v];
735
737 {
738 /* If a variable with a finite finite lower bound was set to +infinity, we just change its objective to 1.0
739 * to minimize its value; if a variable with a finite finite upper bound was set to -infinity, we just
740 * change its objective to -1.0 to maximize its value; if a variable is free, we split the variable into
741 * positive and negative part by creating two new non-negative variables and one constraint linking those
742 * variables.
743 */
745 {
746 SCIP_CALL( SCIPchgVarObj(subscip, varcopy, 1.0) );
747 }
749 {
750 SCIP_CALL( SCIPchgVarObj(subscip, varcopy, -1.0) );
751 }
752 else
753 {
754 char name[SCIP_MAXSTRLEN];
758
759 (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "%s_%s", SCIPvarGetName(varcopy), "run");
760 SCIP_CALL( SCIPcreateVar(subscip, &posvar, name, 0.0, SCIPinfinity(scip), 1.0,
762 SCIP_CALL( SCIPaddVar(subscip, posvar) );
763
764 (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "%s_%s", SCIPvarGetName(varcopy), "neg");
765 SCIP_CALL( SCIPcreateVar(subscip, &negvar, name, 0.0, SCIPinfinity(scip), 1.0,
767 SCIP_CALL( SCIPaddVar(subscip, negvar) );
768
769 (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "%s_%s", SCIPvarGetName(varcopy), "linkcons");
770 SCIP_CALL( SCIPcreateConsBasicLinear(subscip, &linkcons, name, 0, NULL, NULL, 0.0, 0.0 ) );
771 SCIP_CALL( SCIPaddCoefLinear(subscip, linkcons, varcopy, 1.0) );
772 SCIP_CALL( SCIPaddCoefLinear(subscip, linkcons, posvar, -1.0) );
773 SCIP_CALL( SCIPaddCoefLinear(subscip, linkcons, negvar, 1.0) );
774 SCIP_CALL( SCIPaddCons(subscip, linkcons) );
775
776 SCIP_CALL( SCIPreleaseCons(subscip, &linkcons) );
777 SCIP_CALL( SCIPreleaseVar(subscip, &posvar) );
778 SCIP_CALL( SCIPreleaseVar(subscip, &negvar) );
779
780 SCIP_CALL( SCIPchgVarObj(subscip, varcopy, 0.0) );
781 }
782 }
783 else
784 {
785 SCIP_Bool infeasible;
786 SCIP_Bool fixed;
787
789 {
790 SCIP_CALL( SCIPchgVarType(subscip, varcopy, SCIP_VARTYPE_CONTINUOUS, &infeasible) );
791 assert(!infeasible);
792 }
793
794 /* fix variable to its value in the solution */
795 SCIP_CALL( SCIPfixVar(subscip, varcopy, fixval, &infeasible, &fixed) );
796 assert(!infeasible);
797 }
798 }
799
800 SCIP_CALL( SCIPsolve(subscip) );
801
802 bestsol = SCIPgetBestSol(subscip);
803
804 if( bestsol != NULL )
805 {
806 /* change the stored solution values for variables fixed to infinite values */
807 for( v = 0; v < norigvars; ++v )
808 {
809 varcopy = (SCIP_VAR*) SCIPhashmapGetImage(varmap, (void*)origvars[v]);
810 assert(varcopy != NULL);
811
812 if( (SCIPisInfinity(scip, solvals[v]) || SCIPisInfinity(scip, -solvals[v])) )
813 {
814 solvals[v] = SCIPgetSolVal(subscip, bestsol, varcopy);
815 }
816 }
817 }
818 else
819 {
820 *success = FALSE;
821 }
822
823 SCIPhashmapFree(&varmap);
824
825 return SCIP_OKAY;
826}
827
828
829/** creates a copy of a primal solution, thereby replacing infinite fixings of variables by finite values;
830 * the copy is always defined in the original variable space;
831 * success indicates whether the objective value of the solution was changed by removing infinite values
832 *
833 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
834 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
835 *
836 * @pre This method can be called if SCIP is in one of the following stages:
837 * - \ref SCIP_STAGE_PROBLEM
838 * - \ref SCIP_STAGE_TRANSFORMING
839 * - \ref SCIP_STAGE_TRANSFORMED
840 * - \ref SCIP_STAGE_INITPRESOLVE
841 * - \ref SCIP_STAGE_PRESOLVING
842 * - \ref SCIP_STAGE_EXITPRESOLVE
843 * - \ref SCIP_STAGE_PRESOLVED
844 * - \ref SCIP_STAGE_INITSOLVE
845 * - \ref SCIP_STAGE_SOLVING
846 * - \ref SCIP_STAGE_SOLVED
847 * - \ref SCIP_STAGE_EXITSOLVE
848 */
850 SCIP* scip, /**< SCIP data structure */
851 SCIP_SOL** sol, /**< pointer to store the solution */
852 SCIP_SOL* sourcesol, /**< primal CIP solution to copy */
853 SCIP_Bool* success /**< does the finite solution have the same objective value? */
854 )
855{
856 SCIP_VAR** fixedvars;
857 SCIP_VAR** origvars;
858 SCIP_Real* solvals;
859 SCIP_VAR* var;
860 int nfixedvars;
861 int norigvars;
862 int v;
863
864 SCIP_CALL( SCIPcheckStage(scip, "SCIPcreateFiniteSolCopy", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE) );
865
866 assert(scip != NULL);
867 assert(sol != NULL);
869 assert(success != NULL);
870
871 *success = TRUE;
872 *sol = NULL;
873
874 fixedvars = SCIPgetFixedVars(scip);
875 nfixedvars = SCIPgetNFixedVars(scip);
876 assert(fixedvars != NULL || nfixedvars == 0);
877
878 /* get original variables and their values in the optimal solution */
881 SCIP_CALL( SCIPgetSolVals(scip, sourcesol, norigvars, origvars, solvals) );
882
883 /* check whether there are variables fixed to an infinite value */
884 for( v = 0; v < nfixedvars; ++v )
885 {
886 var = fixedvars[v]; /*lint !e613*/
887
888 /* skip (multi-)aggregated variables */
890 continue;
891
893
895 {
896 SCIPdebugMsg(scip, "var <%s> is fixed to infinite value %g\n", SCIPvarGetName(var), SCIPvarGetLbGlobal(var));
897 break;
898 }
899 }
900
901 /* there were variables fixed to infinite values */
902 if( v < nfixedvars )
903 {
904 SCIP* subscip;
905 SCIP_RETCODE retcode;
906
907 /* if one of the variables was fixed to infinity in the original problem, we stop here */
908 for( v = 0; v < norigvars; ++v )
909 {
910 var = origvars[v];
911
913 {
915
916 SCIPdebugMsg(scip, "--> var <%s> is fixed to infinite value %g in the original problem, stop making solution finite\n",
918
919 *success = FALSE;
920
921 goto TERMINATE;
922 }
923 }
924
925 /* create sub-SCIP */
926 SCIP_CALL( SCIPcreate(&subscip) );
927
928 retcode = setupAndSolveFiniteSolSubscip(scip, subscip, origvars, norigvars, solvals, success);
929
930 /* free sub-SCIP */
931 SCIP_CALL( SCIPfree(&subscip) );
932
933 SCIP_CALL( retcode );
934 }
935
936 /* create original solution and set the solution values */
937 if( *success )
938 {
940 for( v = 0; v < norigvars; ++v )
941 {
942 SCIP_CALL( SCIPsetSolVal(scip, *sol, origvars[v], solvals[v]) );
943 }
944 }
945
946#ifdef SCIP_DEBUG
947 SCIPdebugMsg(scip, "created finites solution copy:\n");
949#endif
950
951 /* the solution of the sub-SCIP should have the same objective value */
953 {
954 /* @todo how should we avoid numerical trobles here for large objective values? */
955 if( (SCIPgetSolOrigObj(scip, *sol) / SCIPepsilon(scip)) < 1e+15 ||
957 *success = FALSE;
958 }
959
960 TERMINATE:
961 SCIPfreeBufferArray(scip, &solvals);
962
963 return SCIP_OKAY;
964}
965
966/** frees primal CIP solution
967 *
968 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
969 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
970 *
971 * @pre This method can be called if SCIP is in one of the following stages:
972 * - \ref SCIP_STAGE_PROBLEM
973 * - \ref SCIP_STAGE_TRANSFORMING
974 * - \ref SCIP_STAGE_TRANSFORMED
975 * - \ref SCIP_STAGE_INITPRESOLVE
976 * - \ref SCIP_STAGE_PRESOLVING
977 * - \ref SCIP_STAGE_EXITPRESOLVE
978 * - \ref SCIP_STAGE_PRESOLVED
979 * - \ref SCIP_STAGE_INITSOLVE
980 * - \ref SCIP_STAGE_SOLVING
981 * - \ref SCIP_STAGE_SOLVED
982 * - \ref SCIP_STAGE_EXITSOLVE
983 * - \ref SCIP_STAGE_FREETRANS
984 */
986 SCIP* scip, /**< SCIP data structure */
987 SCIP_SOL** sol /**< pointer to the solution */
988 )
989{
991
992 switch( scip->set->stage )
993 {
995 SCIP_CALL( SCIPsolFree(sol, scip->mem->probmem, scip->origprimal) );
996 break;
1003 case SCIP_STAGE_SOLVING:
1006 case SCIP_STAGE_SOLVED:
1008 SCIP_CALL( SCIPsolFree(sol, scip->mem->probmem, scip->primal) );
1009 break;
1010 default:
1011 SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
1012 return SCIP_INVALIDCALL;
1013 } /*lint !e788*/
1014
1015 return SCIP_OKAY;
1016}
1017
1018/** links a primal solution to the current LP solution
1019 *
1020 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1021 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1022 *
1023 * @pre This method can be called if SCIP is in one of the following stages:
1024 * - \ref SCIP_STAGE_SOLVING
1025 */
1027 SCIP* scip, /**< SCIP data structure */
1028 SCIP_SOL* sol /**< primal solution */
1029 )
1030{
1032
1033 if( !SCIPlpIsSolved(scip->lp) )
1034 {
1035 SCIPerrorMessage("LP solution does not exist\n");
1036 return SCIP_INVALIDCALL;
1037 }
1038
1039 SCIP_CALL( SCIPsolLinkLPSol(sol, scip->set, scip->stat, scip->transprob, scip->tree, scip->lp) );
1040
1041 return SCIP_OKAY;
1042}
1043
1044/** links a primal solution to the current NLP solution
1045 *
1046 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1047 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1048 *
1049 * @pre This method can be called if SCIP is in one of the following stages:
1050 * - \ref SCIP_STAGE_SOLVING
1051 */
1053 SCIP* scip, /**< SCIP data structure */
1054 SCIP_SOL* sol /**< primal solution */
1055 )
1056{
1058
1059 if( scip->nlp == NULL )
1060 {
1061 SCIPerrorMessage("NLP does not exist\n");
1062 return SCIP_INVALIDCALL;
1063 }
1064
1066 {
1067 SCIPerrorMessage("NLP solution does not exist\n");
1068 return SCIP_INVALIDCALL;
1069 }
1070
1071 SCIP_CALL( SCIPsolLinkNLPSol(sol, scip->stat, scip->tree, scip->nlp) );
1072
1073 return SCIP_OKAY;
1074}
1075
1076/** links a primal solution to the current relaxation solution
1077 *
1078 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1079 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1080 *
1081 * @pre This method can be called if SCIP is in one of the following stages:
1082 * - \ref SCIP_STAGE_SOLVING
1083 */
1085 SCIP* scip, /**< SCIP data structure */
1086 SCIP_SOL* sol /**< primal solution */
1087 )
1088{
1090
1091 if( !SCIPrelaxationIsSolValid(scip->relaxation) )
1092 {
1093 SCIPerrorMessage("relaxation solution is not valid\n");
1094 return SCIP_INVALIDCALL;
1095 }
1096
1097 SCIP_CALL( SCIPsolLinkRelaxSol(sol, scip->set, scip->stat, scip->tree, scip->relaxation) );
1098
1099 return SCIP_OKAY;
1100}
1101
1102/** links a primal solution to the current pseudo solution
1103 *
1104 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1105 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1106 *
1107 * @pre This method can be called if SCIP is in one of the following stages:
1108 * - \ref SCIP_STAGE_PRESOLVING
1109 * - \ref SCIP_STAGE_SOLVING
1110 */
1112 SCIP* scip, /**< SCIP data structure */
1113 SCIP_SOL* sol /**< primal solution */
1114 )
1115{
1117
1118 SCIP_CALL( SCIPsolLinkPseudoSol(sol, scip->set, scip->stat, scip->transprob, scip->tree, scip->lp) );
1119
1120 return SCIP_OKAY;
1121}
1122
1123/** links a primal solution to the current LP or pseudo solution
1124 *
1125 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1126 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1127 *
1128 * @pre This method can be called if SCIP is in one of the following stages:
1129 * - \ref SCIP_STAGE_SOLVING
1130 */
1132 SCIP* scip, /**< SCIP data structure */
1133 SCIP_SOL* sol /**< primal solution */
1134 )
1135{
1137
1138 SCIP_CALL( SCIPsolLinkCurrentSol(sol, scip->set, scip->stat, scip->transprob, scip->tree, scip->lp) );
1139
1140 return SCIP_OKAY;
1141}
1142
1143/** clears a primal solution
1144 *
1145 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1146 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1147 *
1148 * @pre This method can be called if SCIP is in one of the following stages:
1149 * - \ref SCIP_STAGE_PROBLEM
1150 * - \ref SCIP_STAGE_TRANSFORMING
1151 * - \ref SCIP_STAGE_TRANSFORMED
1152 * - \ref SCIP_STAGE_INITPRESOLVE
1153 * - \ref SCIP_STAGE_PRESOLVING
1154 * - \ref SCIP_STAGE_EXITPRESOLVE
1155 * - \ref SCIP_STAGE_PRESOLVED
1156 * - \ref SCIP_STAGE_INITSOLVE
1157 * - \ref SCIP_STAGE_SOLVING
1158 * - \ref SCIP_STAGE_SOLVED
1159 * - \ref SCIP_STAGE_EXITSOLVE
1160 * - \ref SCIP_STAGE_FREETRANS
1161 */
1163 SCIP* scip, /**< SCIP data structure */
1164 SCIP_SOL* sol /**< primal solution */
1165 )
1166{
1167 SCIP_CALL( SCIPcheckStage(scip, "SCIPclearSol", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
1168
1169 SCIP_CALL( SCIPsolClear(sol, scip->stat, scip->tree) );
1170
1171 return SCIP_OKAY;
1172}
1173
1174/** stores solution values of variables in solution's own array
1175 *
1176 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1177 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1178 *
1179 * @pre This method can be called if SCIP is in one of the following stages:
1180 * - \ref SCIP_STAGE_TRANSFORMING
1181 * - \ref SCIP_STAGE_TRANSFORMED
1182 * - \ref SCIP_STAGE_PRESOLVING
1183 * - \ref SCIP_STAGE_PRESOLVED
1184 * - \ref SCIP_STAGE_INITSOLVE
1185 * - \ref SCIP_STAGE_SOLVING
1186 * - \ref SCIP_STAGE_SOLVED
1187 * - \ref SCIP_STAGE_EXITSOLVE
1188 * - \ref SCIP_STAGE_FREETRANS
1189 */
1191 SCIP* scip, /**< SCIP data structure */
1192 SCIP_SOL* sol /**< primal solution */
1193 )
1194{
1196
1197 SCIP_CALL( SCIPsolUnlink(sol, scip->set, scip->transprob) );
1198
1199 return SCIP_OKAY;
1200}
1201
1202/** sets value of variable in primal CIP solution
1203 *
1204 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1205 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1206 *
1207 * @pre This method can be called if SCIP is in one of the following stages:
1208 * - \ref SCIP_STAGE_PROBLEM
1209 * - \ref SCIP_STAGE_TRANSFORMING
1210 * - \ref SCIP_STAGE_TRANSFORMED
1211 * - \ref SCIP_STAGE_INITPRESOLVE
1212 * - \ref SCIP_STAGE_PRESOLVING
1213 * - \ref SCIP_STAGE_EXITPRESOLVE
1214 * - \ref SCIP_STAGE_PRESOLVED
1215 * - \ref SCIP_STAGE_INITSOLVE
1216 * - \ref SCIP_STAGE_SOLVING
1217 * - \ref SCIP_STAGE_SOLVED
1218 * - \ref SCIP_STAGE_EXITSOLVE
1219 * - \ref SCIP_STAGE_FREETRANS
1220 */
1222 SCIP* scip, /**< SCIP data structure */
1223 SCIP_SOL* sol, /**< primal solution */
1224 SCIP_VAR* var, /**< variable to add to solution */
1225 SCIP_Real val /**< solution value of variable */
1226 )
1227{
1228 SCIP_CALL( SCIPcheckStage(scip, "SCIPsetSolVal", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
1229
1230 assert( var->scip == scip );
1231
1233 {
1234 SCIPerrorMessage("cannot set value of transformed variable <%s> in original space solution\n",
1236 return SCIP_INVALIDCALL;
1237 }
1238
1239 SCIP_CALL( SCIPsolSetVal(sol, scip->set, scip->stat, scip->tree, var, val) );
1240
1241 return SCIP_OKAY;
1242}
1243
1244/** sets values of multiple variables in primal CIP solution
1245 *
1246 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1247 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1248 *
1249 * @pre This method can be called if SCIP is in one of the following stages:
1250 * - \ref SCIP_STAGE_PROBLEM
1251 * - \ref SCIP_STAGE_TRANSFORMING
1252 * - \ref SCIP_STAGE_TRANSFORMED
1253 * - \ref SCIP_STAGE_INITPRESOLVE
1254 * - \ref SCIP_STAGE_PRESOLVING
1255 * - \ref SCIP_STAGE_EXITPRESOLVE
1256 * - \ref SCIP_STAGE_PRESOLVED
1257 * - \ref SCIP_STAGE_INITSOLVE
1258 * - \ref SCIP_STAGE_SOLVING
1259 * - \ref SCIP_STAGE_SOLVED
1260 * - \ref SCIP_STAGE_EXITSOLVE
1261 * - \ref SCIP_STAGE_FREETRANS
1262 */
1264 SCIP* scip, /**< SCIP data structure */
1265 SCIP_SOL* sol, /**< primal solution */
1266 int nvars, /**< number of variables to set solution value for */
1267 SCIP_VAR** vars, /**< array with variables to add to solution */
1268 SCIP_Real* vals /**< array with solution values of variables */
1269 )
1270{
1271 int v;
1272
1273 assert(nvars == 0 || vars != NULL);
1274 assert(nvars == 0 || vals != NULL);
1275
1276 SCIP_CALL( SCIPcheckStage(scip, "SCIPsetSolVals", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
1277
1278 if( SCIPsolIsOriginal(sol) )
1279 {
1280 for( v = 0; v < nvars; ++v )
1281 {
1282 if( SCIPvarIsTransformed(vars[v]) )
1283 {
1284 SCIPerrorMessage("cannot set value of transformed variable <%s> in original space solution\n",
1285 SCIPvarGetName(vars[v]));
1286 return SCIP_INVALIDCALL;
1287 }
1288 }
1289 }
1290
1291 for( v = 0; v < nvars; ++v )
1292 {
1293 SCIP_CALL( SCIPsolSetVal(sol, scip->set, scip->stat, scip->tree, vars[v], vals[v]) );
1294 }
1295
1296 return SCIP_OKAY;
1297}
1298
1299/** increases value of variable in primal CIP solution
1300 *
1301 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1302 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1303 *
1304 * @pre This method can be called if SCIP is in one of the following stages:
1305 * - \ref SCIP_STAGE_PROBLEM
1306 * - \ref SCIP_STAGE_TRANSFORMING
1307 * - \ref SCIP_STAGE_TRANSFORMED
1308 * - \ref SCIP_STAGE_INITPRESOLVE
1309 * - \ref SCIP_STAGE_PRESOLVING
1310 * - \ref SCIP_STAGE_EXITPRESOLVE
1311 * - \ref SCIP_STAGE_PRESOLVED
1312 * - \ref SCIP_STAGE_INITSOLVE
1313 * - \ref SCIP_STAGE_SOLVING
1314 * - \ref SCIP_STAGE_SOLVED
1315 * - \ref SCIP_STAGE_EXITSOLVE
1316 * - \ref SCIP_STAGE_FREETRANS
1317 */
1319 SCIP* scip, /**< SCIP data structure */
1320 SCIP_SOL* sol, /**< primal solution */
1321 SCIP_VAR* var, /**< variable to increase solution value for */
1322 SCIP_Real incval /**< increment for solution value of variable */
1323 )
1324{
1325 SCIP_CALL( SCIPcheckStage(scip, "SCIPincSolVal", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
1326
1327 assert( var->scip == scip );
1328
1330 {
1331 SCIPerrorMessage("cannot increase value of transformed variable <%s> in original space solution\n",
1333 return SCIP_INVALIDCALL;
1334 }
1335
1336 SCIP_CALL( SCIPsolIncVal(sol, scip->set, scip->stat, scip->tree, var, incval) );
1337
1338 return SCIP_OKAY;
1339}
1340
1341/** returns value of variable in primal CIP solution, or in current LP/pseudo solution
1342 *
1343 * @return value of variable in primal CIP solution, or in current LP/pseudo solution
1344 *
1345 * @pre In case the solution pointer @p sol is @b NULL, that means it is asked for the LP or pseudo solution, this method
1346 * can only be called if @p scip is in the solving stage \ref SCIP_STAGE_SOLVING. In any other case, this method
1347 * can be called if @p scip is in one of the following stages:
1348 * - \ref SCIP_STAGE_PROBLEM
1349 * - \ref SCIP_STAGE_TRANSFORMING
1350 * - \ref SCIP_STAGE_TRANSFORMED
1351 * - \ref SCIP_STAGE_INITPRESOLVE
1352 * - \ref SCIP_STAGE_PRESOLVING
1353 * - \ref SCIP_STAGE_EXITPRESOLVE
1354 * - \ref SCIP_STAGE_PRESOLVED
1355 * - \ref SCIP_STAGE_INITSOLVE
1356 * - \ref SCIP_STAGE_SOLVING
1357 * - \ref SCIP_STAGE_SOLVED
1358 * - \ref SCIP_STAGE_EXITSOLVE
1359 * - \ref SCIP_STAGE_FREETRANS
1360 */
1362 SCIP* scip, /**< SCIP data structure */
1363 SCIP_SOL* sol, /**< primal solution, or NULL for current LP/pseudo solution */
1364 SCIP_VAR* var /**< variable to get value for */
1365 )
1366{
1368
1369 assert( var->scip == scip );
1370
1371 if( sol != NULL )
1372 return SCIPsolGetVal(sol, scip->set, scip->stat, var);
1373
1374 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetSolVal(sol==NULL)", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1375
1377}
1378
1379/** gets values of multiple variables in primal CIP solution
1380 *
1381 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1382 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1383 *
1384 * @pre This method can be called if SCIP is in one of the following stages:
1385 * - \ref SCIP_STAGE_PROBLEM
1386 * - \ref SCIP_STAGE_TRANSFORMING
1387 * - \ref SCIP_STAGE_TRANSFORMED
1388 * - \ref SCIP_STAGE_INITPRESOLVE
1389 * - \ref SCIP_STAGE_PRESOLVING
1390 * - \ref SCIP_STAGE_EXITPRESOLVE
1391 * - \ref SCIP_STAGE_PRESOLVED
1392 * - \ref SCIP_STAGE_INITSOLVE
1393 * - \ref SCIP_STAGE_SOLVING
1394 * - \ref SCIP_STAGE_SOLVED
1395 * - \ref SCIP_STAGE_EXITSOLVE
1396 * - \ref SCIP_STAGE_FREETRANS
1397 */
1399 SCIP* scip, /**< SCIP data structure */
1400 SCIP_SOL* sol, /**< primal solution, or NULL for current LP/pseudo solution */
1401 int nvars, /**< number of variables to get solution value for */
1402 SCIP_VAR** vars, /**< array with variables to get value for */
1403 SCIP_Real* vals /**< array to store solution values of variables */
1404 )
1405{
1406 assert(nvars == 0 || vars != NULL);
1407 assert(nvars == 0 || vals != NULL);
1408
1409 SCIP_CALL( SCIPcheckStage(scip, "SCIPgetSolVals", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
1410
1411 if( sol != NULL )
1412 {
1413 int v;
1414
1415 for( v = 0; v < nvars; ++v )
1416 vals[v] = SCIPsolGetVal(sol, scip->set, scip->stat, vars[v]);
1417 }
1418 else
1419 {
1421 }
1422
1423 return SCIP_OKAY;
1424}
1425
1426/** returns objective value of primal CIP solution w.r.t. original problem, or current LP/pseudo objective value
1427 *
1428 * @return objective value of primal CIP solution w.r.t. original problem, or current LP/pseudo objective value
1429 *
1430 * @pre This method can be called if SCIP is in one of the following stages:
1431 * - \ref SCIP_STAGE_PROBLEM
1432 * - \ref SCIP_STAGE_TRANSFORMING
1433 * - \ref SCIP_STAGE_TRANSFORMED
1434 * - \ref SCIP_STAGE_INITPRESOLVE
1435 * - \ref SCIP_STAGE_PRESOLVING
1436 * - \ref SCIP_STAGE_EXITPRESOLVE
1437 * - \ref SCIP_STAGE_PRESOLVED
1438 * - \ref SCIP_STAGE_INITSOLVE
1439 * - \ref SCIP_STAGE_SOLVING
1440 * - \ref SCIP_STAGE_SOLVED
1441 * - \ref SCIP_STAGE_EXITSOLVE
1442 * - \ref SCIP_STAGE_FREETRANS
1443 */
1445 SCIP* scip, /**< SCIP data structure */
1446 SCIP_SOL* sol /**< primal solution, or NULL for current LP/pseudo objective value */
1447 )
1448{
1449 /* for original solutions, an original objective value is already available in SCIP_STAGE_PROBLEM
1450 * for all other solutions, we should be at least in SCIP_STAGE_TRANSFORMING
1451 */
1452 if( sol != NULL && SCIPsolIsOriginal(sol) )
1453 {
1454 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetSolOrigObj", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
1455
1456 return SCIPsolGetOrigObj(sol);
1457 }
1458
1459 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetSolOrigObj", FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
1460
1461 if( sol != NULL )
1462 return SCIPprobExternObjval(scip->transprob, scip->origprob, scip->set, SCIPsolGetObj(sol, scip->set, scip->transprob, scip->origprob));
1463 else
1464 {
1465 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetSolOrigObj(sol==NULL)", \
1467 if( SCIPtreeHasCurrentNodeLP(scip->tree) )
1468 return SCIPprobExternObjval(scip->transprob, scip->origprob, scip->set, SCIPlpGetObjval(scip->lp, scip->set, scip->transprob));
1469 else
1470 return SCIPprobExternObjval(scip->transprob, scip->origprob, scip->set, SCIPlpGetPseudoObjval(scip->lp, scip->set, scip->transprob));
1471 }
1472}
1473
1474/** returns transformed objective value of primal CIP solution, or transformed current LP/pseudo objective value
1475 *
1476 * @return transformed objective value of primal CIP solution, or transformed current LP/pseudo objective value
1477 *
1478 * @pre This method can be called if SCIP is in one of the following stages:
1479 * - \ref SCIP_STAGE_TRANSFORMING
1480 * - \ref SCIP_STAGE_TRANSFORMED
1481 * - \ref SCIP_STAGE_INITPRESOLVE
1482 * - \ref SCIP_STAGE_PRESOLVING
1483 * - \ref SCIP_STAGE_EXITPRESOLVE
1484 * - \ref SCIP_STAGE_PRESOLVED
1485 * - \ref SCIP_STAGE_INITSOLVE
1486 * - \ref SCIP_STAGE_SOLVING
1487 * - \ref SCIP_STAGE_SOLVED
1488 * - \ref SCIP_STAGE_EXITSOLVE
1489 * - \ref SCIP_STAGE_FREETRANS
1490 */
1492 SCIP* scip, /**< SCIP data structure */
1493 SCIP_SOL* sol /**< primal solution, or NULL for current LP/pseudo objective value */
1494 )
1495{
1496 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetSolTransObj", FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
1497
1498 if( sol != NULL )
1499 return SCIPsolGetObj(sol, scip->set, scip->transprob, scip->origprob);
1500 else
1501 {
1502 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetSolTransObj(sol==NULL)", \
1504 if( SCIPtreeHasCurrentNodeLP(scip->tree) )
1505 return SCIPlpGetObjval(scip->lp, scip->set, scip->transprob);
1506 else
1507 return SCIPlpGetPseudoObjval(scip->lp, scip->set, scip->transprob);
1508 }
1509}
1510
1511/** recomputes the objective value of an original solution, e.g., when transferring solutions
1512 * from the solution pool (objective coefficients might have changed in the meantime)
1513 *
1514 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1515 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1516 *
1517 * @pre This method can be called if SCIP is in one of the following stages:
1518 * - \ref SCIP_STAGE_PRESOLVING
1519 * - \ref SCIP_STAGE_SOLVING
1520 *
1521 */
1523 SCIP* scip,
1524 SCIP_SOL* sol
1525 )
1526{
1527 assert(scip != NULL);
1528
1529 SCIP_CALL( SCIPcheckStage(scip, "SCIPrecomputeSolObj", FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1530
1531 SCIPsolRecomputeObj(sol, scip->set, scip->stat, scip->origprob);
1532
1533 return SCIP_OKAY;
1534}
1535
1536/** maps original space objective value into transformed objective value
1537 *
1538 * @return transformed objective value
1539 *
1540 * @pre This method can be called if SCIP is in one of the following stages:
1541 * - \ref SCIP_STAGE_TRANSFORMING
1542 * - \ref SCIP_STAGE_TRANSFORMED
1543 * - \ref SCIP_STAGE_INITPRESOLVE
1544 * - \ref SCIP_STAGE_PRESOLVING
1545 * - \ref SCIP_STAGE_EXITPRESOLVE
1546 * - \ref SCIP_STAGE_PRESOLVED
1547 * - \ref SCIP_STAGE_INITSOLVE
1548 * - \ref SCIP_STAGE_SOLVING
1549 * - \ref SCIP_STAGE_SOLVED
1550 */
1552 SCIP* scip, /**< SCIP data structure */
1553 SCIP_Real obj /**< original space objective value to transform */
1554 )
1555{
1557
1558 return SCIPprobInternObjval(scip->transprob, scip->origprob, scip->set, obj);
1559}
1560
1561/** maps transformed objective value into original space
1562 *
1563 * @return objective value into original space
1564 *
1565 * @pre This method can be called if SCIP is in one of the following stages:
1566 * - \ref SCIP_STAGE_TRANSFORMING
1567 * - \ref SCIP_STAGE_TRANSFORMED
1568 * - \ref SCIP_STAGE_INITPRESOLVE
1569 * - \ref SCIP_STAGE_PRESOLVING
1570 * - \ref SCIP_STAGE_EXITPRESOLVE
1571 * - \ref SCIP_STAGE_PRESOLVED
1572 * - \ref SCIP_STAGE_INITSOLVE
1573 * - \ref SCIP_STAGE_SOLVING
1574 * - \ref SCIP_STAGE_SOLVED
1575 */
1577 SCIP* scip, /**< SCIP data structure */
1578 SCIP_Real obj /**< transformed objective value to retransform in original space */
1579 )
1580{
1581 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPretransformObj", FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
1582
1583 return SCIPprobExternObjval(scip->transprob, scip->origprob, scip->set, obj);
1584}
1585
1586/** gets clock time, when this solution was found
1587 *
1588 * @return clock time, when this solution was found
1589 *
1590 * @pre This method can be called if SCIP is in one of the following stages:
1591 * - \ref SCIP_STAGE_TRANSFORMING
1592 * - \ref SCIP_STAGE_TRANSFORMED
1593 * - \ref SCIP_STAGE_INITPRESOLVE
1594 * - \ref SCIP_STAGE_PRESOLVING
1595 * - \ref SCIP_STAGE_EXITPRESOLVE
1596 * - \ref SCIP_STAGE_PRESOLVED
1597 * - \ref SCIP_STAGE_INITSOLVE
1598 * - \ref SCIP_STAGE_SOLVING
1599 * - \ref SCIP_STAGE_SOLVED
1600 * - \ref SCIP_STAGE_EXITSOLVE
1601 * - \ref SCIP_STAGE_FREETRANS
1602 */
1604 SCIP* scip, /**< SCIP data structure */
1605 SCIP_SOL* sol /**< primal solution */
1606 )
1607{
1609
1610 return SCIPsolGetTime(sol);
1611}
1612
1613/** gets branch and bound run number, where this solution was found
1614 *
1615 * @return branch and bound run number, where this solution was found
1616 *
1617 * @pre This method can be called if SCIP is in one of the following stages:
1618 * - \ref SCIP_STAGE_TRANSFORMING
1619 * - \ref SCIP_STAGE_TRANSFORMED
1620 * - \ref SCIP_STAGE_INITPRESOLVE
1621 * - \ref SCIP_STAGE_PRESOLVING
1622 * - \ref SCIP_STAGE_EXITPRESOLVE
1623 * - \ref SCIP_STAGE_PRESOLVED
1624 * - \ref SCIP_STAGE_INITSOLVE
1625 * - \ref SCIP_STAGE_SOLVING
1626 * - \ref SCIP_STAGE_SOLVED
1627 * - \ref SCIP_STAGE_EXITSOLVE
1628 * - \ref SCIP_STAGE_FREETRANS
1629 */
1631 SCIP* scip, /**< SCIP data structure */
1632 SCIP_SOL* sol /**< primal solution */
1633 )
1634{
1636
1637 return SCIPsolGetRunnum(sol);
1638}
1639
1640/** gets node number of the specific branch and bound run, where this solution was found
1641 *
1642 * @return node number of the specific branch and bound run, where this solution was found
1643 *
1644 * @pre This method can be called if SCIP is in one of the following stages:
1645 * - \ref SCIP_STAGE_TRANSFORMING
1646 * - \ref SCIP_STAGE_TRANSFORMED
1647 * - \ref SCIP_STAGE_INITPRESOLVE
1648 * - \ref SCIP_STAGE_PRESOLVING
1649 * - \ref SCIP_STAGE_EXITPRESOLVE
1650 * - \ref SCIP_STAGE_PRESOLVED
1651 * - \ref SCIP_STAGE_INITSOLVE
1652 * - \ref SCIP_STAGE_SOLVING
1653 * - \ref SCIP_STAGE_SOLVED
1654 * - \ref SCIP_STAGE_EXITSOLVE
1655 * - \ref SCIP_STAGE_FREETRANS
1656 */
1658 SCIP* scip, /**< SCIP data structure */
1659 SCIP_SOL* sol /**< primal solution */
1660 )
1661{
1662 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetSolNodenum", FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
1663
1664 return SCIPsolGetNodenum(sol);
1665}
1666
1667/** gets heuristic, that found this solution (or NULL if it's from the tree)
1668 *
1669 * @return heuristic, that found this solution (or NULL if it's from the tree)
1670 *
1671 * @pre This method can be called if SCIP is in one of the following stages:
1672 * - \ref SCIP_STAGE_TRANSFORMING
1673 * - \ref SCIP_STAGE_TRANSFORMED
1674 * - \ref SCIP_STAGE_INITPRESOLVE
1675 * - \ref SCIP_STAGE_PRESOLVING
1676 * - \ref SCIP_STAGE_EXITPRESOLVE
1677 * - \ref SCIP_STAGE_PRESOLVED
1678 * - \ref SCIP_STAGE_INITSOLVE
1679 * - \ref SCIP_STAGE_SOLVING
1680 * - \ref SCIP_STAGE_SOLVED
1681 * - \ref SCIP_STAGE_EXITSOLVE
1682 * - \ref SCIP_STAGE_FREETRANS
1683 */
1685 SCIP* scip, /**< SCIP data structure */
1686 SCIP_SOL* sol /**< primal solution */
1687 )
1688{
1690
1691 return SCIPsolGetHeur(sol);
1692}
1693
1694/** returns whether two given solutions are exactly equal
1695 *
1696 * @return returns whether two given solutions are exactly equal
1697 *
1698 * @pre This method can be called if SCIP is in one of the following stages:
1699 * - \ref SCIP_STAGE_PROBLEM
1700 * - \ref SCIP_STAGE_TRANSFORMING
1701 * - \ref SCIP_STAGE_TRANSFORMED
1702 * - \ref SCIP_STAGE_INITPRESOLVE
1703 * - \ref SCIP_STAGE_PRESOLVING
1704 * - \ref SCIP_STAGE_EXITPRESOLVE
1705 * - \ref SCIP_STAGE_PRESOLVED
1706 * - \ref SCIP_STAGE_INITSOLVE
1707 * - \ref SCIP_STAGE_SOLVING
1708 * - \ref SCIP_STAGE_SOLVED
1709 * - \ref SCIP_STAGE_EXITSOLVE
1710 * - \ref SCIP_STAGE_FREETRANS
1711 */
1713 SCIP* scip, /**< SCIP data structure */
1714 SCIP_SOL* sol1, /**< first primal CIP solution */
1715 SCIP_SOL* sol2 /**< second primal CIP solution */
1716 )
1717{
1718 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPareSolsEqual", FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
1719
1720 return SCIPsolsAreEqual(sol1, sol2, scip->set, scip->stat, scip->origprob, scip->transprob);
1721}
1722
1723/** adjusts solution values of implicit integer variables in handed solution. Solution objective value is not
1724 * deteriorated by this method.
1725 *
1726 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1727 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1728 *
1729 * @pre This method can be called if SCIP is in one of the following stages:
1730 * - \ref SCIP_STAGE_SOLVING
1731 */
1733 SCIP* scip, /**< SCIP data structure */
1734 SCIP_SOL* sol, /**< primal CIP solution */
1735 SCIP_Bool uselprows /**< should LP row information be considered for none-objective variables */
1736 )
1737{
1738 assert(scip != NULL);
1739 SCIP_CALL( SCIPcheckStage(scip, "SCIPadjustImplicitSolVals", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
1740
1741 assert(sol != NULL);
1742 SCIP_CALL( SCIPsolAdjustImplicitSolVals(sol, scip->set, scip->stat, scip->transprob, scip->tree, uselprows) );
1743
1744 return SCIP_OKAY;
1745}
1746
1747/** outputs non-zero variables of solution in original problem space to the given file stream
1748 *
1749 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1750 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1751 *
1752 * @pre In case the solution pointer @p sol is NULL (asking for the current LP/pseudo solution), this method can be
1753 * called if @p scip is in one of the following stages:
1754 * - \ref SCIP_STAGE_PRESOLVING
1755 * - \ref SCIP_STAGE_EXITPRESOLVE
1756 * - \ref SCIP_STAGE_PRESOLVED
1757 * - \ref SCIP_STAGE_INITSOLVE
1758 * - \ref SCIP_STAGE_SOLVING
1759 * - \ref SCIP_STAGE_SOLVED
1760 * - \ref SCIP_STAGE_EXITSOLVE
1761 *
1762 * @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
1763 * following stages:
1764 * - \ref SCIP_STAGE_PROBLEM
1765 * - \ref SCIP_STAGE_TRANSFORMED
1766 * - \ref SCIP_STAGE_INITPRESOLVE
1767 * - \ref SCIP_STAGE_PRESOLVING
1768 * - \ref SCIP_STAGE_EXITPRESOLVE
1769 * - \ref SCIP_STAGE_PRESOLVED
1770 * - \ref SCIP_STAGE_INITSOLVE
1771 * - \ref SCIP_STAGE_SOLVING
1772 * - \ref SCIP_STAGE_SOLVED
1773 * - \ref SCIP_STAGE_EXITSOLVE
1774 */
1776 SCIP* scip, /**< SCIP data structure */
1777 SCIP_SOL* sol, /**< primal solution, or NULL for current LP/pseudo solution */
1778 FILE* file, /**< output file (or NULL for standard output) */
1779 SCIP_Bool printzeros /**< should variables set to zero be printed? */
1780 )
1781{
1782 SCIP_Real objvalue;
1783 SCIP_Bool currentsol;
1784 SCIP_Bool oldquiet = FALSE;
1785
1787
1789
1790 currentsol = (sol == NULL);
1791 if( currentsol )
1792 {
1793 SCIP_CALL( SCIPcheckStage(scip, "SCIPprintSol(sol==NULL)", \
1795
1796 /* create a temporary solution that is linked to the current solution */
1797 SCIP_CALL( SCIPsolCreateCurrentSol(&sol, scip->mem->probmem, scip->set, scip->stat, scip->transprob, scip->primal,
1798 scip->tree, scip->lp, NULL) );
1799 }
1800
1801 if( file != NULL && scip->messagehdlr != NULL )
1802 {
1803 oldquiet = SCIPmessagehdlrIsQuiet(scip->messagehdlr);
1804 SCIPmessagehdlrSetQuiet(scip->messagehdlr, FALSE);
1805 }
1806
1807 SCIPmessageFPrintInfo(scip->messagehdlr, file, "objective value: ");
1808
1809 if( SCIPsolIsPartial(sol) )
1810 {
1811 SCIPmessageFPrintInfo(scip->messagehdlr, file, "unknown\n");
1812 }
1813 else
1814 {
1815 if( SCIPsolIsOriginal(sol) )
1817 else
1818 objvalue = SCIPprobExternObjval(scip->transprob, scip->origprob, scip->set, SCIPsolGetObj(sol, scip->set, scip->transprob, scip->origprob));
1819
1820 SCIPprintReal(scip, file, objvalue, 20, 15);
1821 SCIPmessageFPrintInfo(scip->messagehdlr, file, "\n");
1822 }
1823
1824 SCIP_CALL( SCIPsolPrint(sol, scip->set, scip->messagehdlr, scip->stat, scip->origprob, scip->transprob, file, FALSE,
1825 printzeros) );
1826
1827 if( file != NULL && scip->messagehdlr != NULL )
1828 {
1829 SCIPmessagehdlrSetQuiet(scip->messagehdlr, oldquiet);
1830 }
1831
1832 if( currentsol )
1833 {
1834 /* free temporary solution */
1835 SCIP_CALL( SCIPsolFree(&sol, scip->mem->probmem, scip->primal) );
1836 }
1837
1838 return SCIP_OKAY;
1839}
1840
1841/** outputs non-zero variables of solution in transformed problem space to file stream
1842 *
1843 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1844 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1845 *
1846 * @pre This method can be called if SCIP is in one of the following stages:
1847 * - \ref SCIP_STAGE_TRANSFORMED
1848 * - \ref SCIP_STAGE_INITPRESOLVE
1849 * - \ref SCIP_STAGE_PRESOLVING
1850 * - \ref SCIP_STAGE_EXITPRESOLVE
1851 * - \ref SCIP_STAGE_PRESOLVED
1852 * - \ref SCIP_STAGE_INITSOLVE
1853 * - \ref SCIP_STAGE_SOLVING
1854 * - \ref SCIP_STAGE_SOLVED
1855 * - \ref SCIP_STAGE_EXITSOLVE
1856 */
1858 SCIP* scip, /**< SCIP data structure */
1859 SCIP_SOL* sol, /**< primal solution, or NULL for current LP/pseudo solution */
1860 FILE* file, /**< output file (or NULL for standard output) */
1861 SCIP_Bool printzeros /**< should variables set to zero be printed? */
1862 )
1863{
1864 SCIP_Bool currentsol;
1865
1866 SCIP_CALL( SCIPcheckStage(scip, "SCIPprintTransSol", FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE) );
1867
1868 currentsol = (sol == NULL);
1869 if( currentsol )
1870 {
1871 /* create a temporary solution that is linked to the current solution */
1872 SCIP_CALL( SCIPsolCreateCurrentSol(&sol, scip->mem->probmem, scip->set, scip->stat, scip->transprob, scip->primal,
1873 scip->tree, scip->lp, NULL) );
1874 }
1875
1876 if( SCIPsolIsOriginal(sol) )
1877 {
1878 SCIPerrorMessage("cannot print original space solution as transformed solution\n");
1879 return SCIP_INVALIDCALL;
1880 }
1881
1882 SCIPmessageFPrintInfo(scip->messagehdlr, file, "objective value: ");
1883 SCIPprintReal(scip, file, SCIPsolGetObj(sol, scip->set, scip->transprob, scip->origprob), 20, 9);
1884 SCIPmessageFPrintInfo(scip->messagehdlr, file, "\n");
1885
1886 SCIP_CALL( SCIPsolPrint(sol, scip->set, scip->messagehdlr, scip->stat, scip->transprob, NULL, file, FALSE, printzeros) );
1887
1888 if( currentsol )
1889 {
1890 /* free temporary solution */
1891 SCIP_CALL( SCIPsolFree(&sol, scip->mem->probmem, scip->primal) );
1892 }
1893
1894 return SCIP_OKAY;
1895}
1896
1897/** outputs discrete variables of solution in original problem space to the given file stream
1898 *
1899 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
1900 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
1901 *
1902 * @pre This method can be called if @p scip is in one of the following stages:
1903 * - \ref SCIP_STAGE_PROBLEM
1904 * - \ref SCIP_STAGE_TRANSFORMED
1905 * - \ref SCIP_STAGE_INITPRESOLVE
1906 * - \ref SCIP_STAGE_PRESOLVING
1907 * - \ref SCIP_STAGE_EXITPRESOLVE
1908 * - \ref SCIP_STAGE_PRESOLVED
1909 * - \ref SCIP_STAGE_INITSOLVE
1910 * - \ref SCIP_STAGE_SOLVING
1911 * - \ref SCIP_STAGE_SOLVED
1912 * - \ref SCIP_STAGE_EXITSOLVE
1913 */
1915 SCIP* scip, /**< SCIP data structure */
1916 SCIP_SOL* sol, /**< primal solution */
1917 FILE* file /**< output file (or NULL for standard output) */
1918 )
1919{
1920 SCIP_Real objvalue;
1921 SCIP_Bool oldquiet = FALSE;
1922
1923 assert(sol != NULL);
1925
1926 SCIP_CALL( SCIPcheckStage(scip, "SCIPprintMIPStart", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE) );
1927
1928 if( file != NULL && scip->messagehdlr != NULL )
1929 {
1930 oldquiet = SCIPmessagehdlrIsQuiet(scip->messagehdlr);
1931 SCIPmessagehdlrSetQuiet(scip->messagehdlr, FALSE);
1932 }
1933
1934 SCIPmessageFPrintInfo(scip->messagehdlr, file, "objective value: ");
1935
1936 if( SCIPsolIsOriginal(sol) )
1938 else
1939 objvalue = SCIPprobExternObjval(scip->transprob, scip->origprob, scip->set, SCIPsolGetObj(sol, scip->set, scip->transprob, scip->origprob));
1940
1941 SCIPprintReal(scip, file, objvalue, 20, 15);
1942 SCIPmessageFPrintInfo(scip->messagehdlr, file, "\n");
1943
1944 SCIP_CALL( SCIPsolPrint(sol, scip->set, scip->messagehdlr, scip->stat, scip->origprob, scip->transprob, file, TRUE,
1945 TRUE) );
1946
1947 if( file != NULL && scip->messagehdlr != NULL )
1948 {
1949 SCIPmessagehdlrSetQuiet(scip->messagehdlr, oldquiet);
1950 }
1951
1952 return SCIP_OKAY;
1953}
1954
1955/** returns dual solution value of a constraint */
1957 SCIP* scip, /**< SCIP data structure */
1958 SCIP_CONS* cons, /**< constraint for which the dual solution should be returned */
1959 SCIP_Real* dualsolval, /**< pointer to store the dual solution value */
1960 SCIP_Bool* boundconstraint /**< pointer to store whether the constraint is a bound constraint (or NULL) */
1961 )
1962{
1964 int nvars;
1965 SCIP_Bool success;
1966
1967 assert(scip != NULL);
1968 assert(cons != NULL);
1970
1971 assert(SCIPconsGetHdlr(cons) != NULL);
1972 assert(strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(cons)), "linear" ) == 0);
1973
1974 SCIP_CALL( SCIPconsGetNVars(cons, scip->set, &nvars, &success) );
1975 assert(success); /* is always successful, since we only have linear constraints */
1976
1977 if( boundconstraint != NULL )
1978 *boundconstraint = (nvars == 1);
1979
1980 if( SCIPconsIsTransformed(cons) )
1981 transcons = cons;
1982 else
1984
1985 /* it can happen that a transformed constraints gets deleted due to redundancy. by complementary slackness the
1986 * corresponding dual solution value would be zero. however, if the constraint contains exactly one variable we need
1987 * to check the reduced costs of the variable.
1988 */
1989 if( nvars == 0 || (nvars > 1 && transcons == NULL) )
1990 (*dualsolval) = 0.0;
1991 else
1992 {
1993 if( nvars > 1 )
1994 (*dualsolval) = SCIPgetDualsolLinear(scip, transcons);
1995 else
1996 {
1997 /* the constraint is a bound constraint */
1998 SCIP_VAR** vars;
1999 SCIP_Real* vals;
2000 SCIP_Real activity;
2001
2002 vars = SCIPgetVarsLinear(scip, cons);
2003 vals = SCIPgetValsLinear(scip, cons);
2004
2005 activity = SCIPvarGetLPSol(vars[0]) * vals[0];
2006
2007 /* return the reduced cost of the variable if the constraint would be tight */
2008 if( SCIPsetIsEQ(scip->set, activity, SCIPgetRhsLinear(scip, cons))
2009 || SCIPsetIsEQ(scip->set, activity, SCIPgetLhsLinear(scip, cons)) )
2010 (*dualsolval) = SCIPgetVarRedcost(scip, vars[0]);
2011 else
2012 (*dualsolval) = 0.0;
2013 }
2014 }
2015 assert(*dualsolval != SCIP_INVALID); /*lint !e777*/
2016
2017 /* dual values are coming from the LP solver that is always solving a minimization problem */
2019 (*dualsolval) *= -1.0;
2020
2021 return SCIP_OKAY;
2022}
2023
2024/** outputs dual solution from LP solver to file stream */
2025static
2027 SCIP* scip, /**< SCIP data structure */
2028 FILE* file, /**< output file (or NULL for standard output) */
2029 SCIP_Bool printzeros /**< should variables set to zero be printed? */
2030 )
2031{
2032 SCIP_Bool boundconstraint;
2033 int c;
2034
2035 assert(scip->lp != NULL);
2036 assert(scip->lp->solved);
2037 assert(scip->lp->dualfeasible);
2038
2039 /* print dual solution values of all constraints */
2040 for( c = 0; c < scip->origprob->nconss; ++c )
2041 {
2042 SCIP_CONS* cons;
2043 SCIP_Real solval;
2044
2045 cons = scip->origprob->conss[c];
2046 assert(cons != NULL);
2047
2048 SCIP_CALL( SCIPgetDualSolVal(scip, cons, &solval, &boundconstraint) );
2049
2050 if( printzeros || !SCIPisZero(scip, solval) )
2051 {
2052 SCIP_MESSAGEHDLR* messagehdlr = scip->messagehdlr;
2053
2054 SCIPmessageFPrintInfo(messagehdlr, file, "%-32s", SCIPconsGetName(cons));
2055
2056 if( SCIPisInfinity(scip, solval) )
2057 SCIPmessageFPrintInfo(messagehdlr, file, " +infinity\n");
2058 else if( SCIPisInfinity(scip, -solval) )
2059 SCIPmessageFPrintInfo(messagehdlr, file, " -infinity\n");
2060 else
2061 {
2062 if( boundconstraint )
2063 SCIPmessageFPrintInfo(messagehdlr, file, " %20.15g*\n", solval);
2064 else
2065 SCIPmessageFPrintInfo(messagehdlr, file, " %20.15g\n", solval);
2066 }
2067 }
2068 }
2069
2070 return SCIP_OKAY;
2071}
2072
2073/** check whether the dual solution is available
2074 *
2075 * @note This is used when calling \ref SCIPprintDualSol()
2076 *
2077 * @return is dual solution available?
2078 *
2079 * @pre This method can be called if SCIP is in one of the following stages:
2080 * - \ref SCIP_STAGE_SOLVED
2081 */
2083 SCIP* scip, /**< SCIP data structure */
2084 SCIP_Bool printreason /**< print warning message if dualsol is not available? */
2085 )
2086{
2087 int c;
2088
2089 assert(scip != NULL);
2090
2091 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPisDualSolAvailable", TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE) );
2092
2094 {
2095 if( printreason )
2096 SCIPmessageFPrintInfo(scip->messagehdlr, NULL, "No dual solution available.\n");
2097 return FALSE;
2098 }
2099
2100 assert(scip->stat != NULL);
2101 assert(scip->transprob != NULL);
2102
2103 /* dual solution only useful when no presolving was performed */
2104 if( scip->stat->performpresol )
2105 {
2106 if( printreason )
2107 SCIPwarningMessage(scip, "No dual information available when presolving was performed.\n");
2108 return FALSE;
2109 }
2110
2111 /* dual solution is created by LP solver and therefore only available for pure LPs */
2112 if( scip->transprob->nvars != scip->transprob->ncontvars )
2113 {
2114 if( printreason )
2115 SCIPwarningMessage(scip, "Dual information only available for pure LPs (only continuous variables).\n");
2116 return FALSE;
2117 }
2118
2119 /* dual solution is created by LP solver and therefore only available for linear constraints */
2120 for( c = scip->transprob->nconss - 1; c >= 0; --c )
2121 {
2122 SCIP_CONSHDLR* conshdlr;
2123
2124 conshdlr = SCIPconsGetHdlr(scip->transprob->conss[c]);
2125 assert(conshdlr != NULL);
2126
2127 if( strcmp(SCIPconshdlrGetName(conshdlr), "linear" ) != 0 )
2128 {
2129 if( printreason )
2130 SCIPwarningMessage(scip, "Dual information only available for pure LPs (only linear constraints).\n");
2131 return FALSE;
2132 }
2133 }
2134
2135 return TRUE;
2136}
2137
2138/** outputs dual solution from LP solver to file stream
2139 *
2140 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2141 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2142 *
2143 * @pre This method can be called in all stages but only prints dual information when called in \ref SCIP_STAGE_SOLVED
2144 */
2146 SCIP* scip, /**< SCIP data structure */
2147 FILE* file, /**< output file (or NULL for standard output) */
2148 SCIP_Bool printzeros /**< should variables set to zero be printed? */
2149 )
2150{
2152 {
2153 /* print dual solution */
2155 }
2156
2157 return SCIP_OKAY;
2158}
2159
2160
2161/** outputs non-zero variables of solution representing a ray in original problem space to file stream
2162 *
2163 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2164 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2165 *
2166 * @pre This method can be called if SCIP is in one of the following stages:
2167 * - \ref SCIP_STAGE_PROBLEM
2168 * - \ref SCIP_STAGE_TRANSFORMED
2169 * - \ref SCIP_STAGE_INITPRESOLVE
2170 * - \ref SCIP_STAGE_PRESOLVING
2171 * - \ref SCIP_STAGE_EXITPRESOLVE
2172 * - \ref SCIP_STAGE_PRESOLVED
2173 * - \ref SCIP_STAGE_INITSOLVE
2174 * - \ref SCIP_STAGE_SOLVING
2175 * - \ref SCIP_STAGE_SOLVED
2176 * - \ref SCIP_STAGE_EXITSOLVE
2177 */
2179 SCIP* scip, /**< SCIP data structure */
2180 SCIP_SOL* sol, /**< primal solution representing ray */
2181 FILE* file, /**< output file (or NULL for standard output) */
2182 SCIP_Bool printzeros /**< should variables set to zero be printed? */
2183 )
2184{
2185 assert(scip != NULL);
2186 assert(sol != NULL);
2187
2189
2190 SCIP_CALL( SCIPsolPrintRay(sol, scip->set, scip->messagehdlr, scip->stat, scip->origprob, scip->transprob, file, printzeros) );
2191
2192 return SCIP_OKAY;
2193}
2194
2195/** gets number of feasible primal solutions stored in the solution storage in case the problem is transformed;
2196 * in case the problem stage is SCIP_STAGE_PROBLEM, the number of solution in the original solution candidate
2197 * storage is returned
2198 *
2199 * @return number of feasible primal solutions stored in the solution storage in case the problem is transformed; or
2200 * number of solution in the original solution candidate storage if the problem stage is SCIP_STAGE_PROBLEM
2201 *
2202 * @pre This method can be called if SCIP is in one of the following stages:
2203 * - \ref SCIP_STAGE_PROBLEM
2204 * - \ref SCIP_STAGE_TRANSFORMED
2205 * - \ref SCIP_STAGE_INITPRESOLVE
2206 * - \ref SCIP_STAGE_PRESOLVING
2207 * - \ref SCIP_STAGE_EXITPRESOLVE
2208 * - \ref SCIP_STAGE_PRESOLVED
2209 * - \ref SCIP_STAGE_INITSOLVE
2210 * - \ref SCIP_STAGE_SOLVING
2211 * - \ref SCIP_STAGE_SOLVED
2212 * - \ref SCIP_STAGE_EXITSOLVE
2213 */
2215 SCIP* scip /**< SCIP data structure */
2216 )
2217{
2219
2220 switch( scip->set->stage )
2221 {
2222 case SCIP_STAGE_PROBLEM:
2223 return scip->origprimal->nsols;
2224
2231 case SCIP_STAGE_SOLVING:
2232 case SCIP_STAGE_SOLVED:
2234 return scip->primal->nsols;
2235
2236 case SCIP_STAGE_INIT:
2239 default:
2240 SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
2241 SCIPABORT();
2242 return -1; /*lint !e527*/
2243 } /*lint !e788*/
2244}
2245
2246/** gets array of feasible primal solutions stored in the solution storage in case the problem is transformed; in case
2247 * if the problem stage is in SCIP_STAGE_PROBLEM, it returns the number array of solution candidate stored
2248 *
2249 * @return array of feasible primal solutions
2250 *
2251 * @pre This method can be called if SCIP is in one of the following stages:
2252 * - \ref SCIP_STAGE_PROBLEM
2253 * - \ref SCIP_STAGE_TRANSFORMED
2254 * - \ref SCIP_STAGE_INITPRESOLVE
2255 * - \ref SCIP_STAGE_PRESOLVING
2256 * - \ref SCIP_STAGE_EXITPRESOLVE
2257 * - \ref SCIP_STAGE_PRESOLVED
2258 * - \ref SCIP_STAGE_INITSOLVE
2259 * - \ref SCIP_STAGE_SOLVING
2260 * - \ref SCIP_STAGE_SOLVED
2261 * - \ref SCIP_STAGE_EXITSOLVE
2262 */
2264 SCIP* scip /**< SCIP data structure */
2265 )
2266{
2268
2269 switch( scip->set->stage )
2270 {
2271 case SCIP_STAGE_PROBLEM:
2272 return scip->origprimal->sols;
2273
2280 case SCIP_STAGE_SOLVING:
2281 case SCIP_STAGE_SOLVED:
2283 return scip->primal->sols;
2284
2285 case SCIP_STAGE_INIT:
2288 case SCIP_STAGE_FREE:
2289 default:
2290 SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
2291 return NULL;
2292 } /*lint !e788*/
2293}
2294
2295/** gets best feasible primal solution found so far if the problem is transformed; in case the problem is in
2296 * SCIP_STAGE_PROBLEM it returns the best solution candidate, or NULL if no solution has been found or the candidate
2297 * store is empty;
2298 *
2299 * @return best feasible primal solution so far
2300 *
2301 * @pre This method can be called if SCIP is in one of the following stages:
2302 * - \ref SCIP_STAGE_PROBLEM
2303 * - \ref SCIP_STAGE_TRANSFORMED
2304 * - \ref SCIP_STAGE_INITPRESOLVE
2305 * - \ref SCIP_STAGE_PRESOLVING
2306 * - \ref SCIP_STAGE_EXITPRESOLVE
2307 * - \ref SCIP_STAGE_PRESOLVED
2308 * - \ref SCIP_STAGE_INITSOLVE
2309 * - \ref SCIP_STAGE_SOLVING
2310 * - \ref SCIP_STAGE_SOLVED
2311 * - \ref SCIP_STAGE_EXITSOLVE
2312 */
2314 SCIP* scip /**< SCIP data structure */
2315 )
2316{
2318 switch( scip->set->stage )
2319 {
2320 case SCIP_STAGE_INIT:
2321 return NULL;
2322 case SCIP_STAGE_PROBLEM:
2323 assert(scip->origprimal != NULL);
2324 if( scip->origprimal->nsols > 0 )
2325 {
2326 assert(scip->origprimal->sols != NULL);
2327 assert(scip->origprimal->sols[0] != NULL);
2328 return scip->origprimal->sols[0];
2329 }
2330 break;
2331
2338 case SCIP_STAGE_SOLVING:
2339 case SCIP_STAGE_SOLVED:
2341 assert(scip->primal != NULL);
2342 if( scip->primal->nsols > 0 )
2343 {
2344 assert(scip->primal->sols != NULL);
2345 assert(scip->primal->sols[0] != NULL);
2346 return scip->primal->sols[0];
2347 }
2348 break;
2349
2352 case SCIP_STAGE_FREE:
2353 default:
2354 SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
2355 return NULL;
2356 }
2357
2358 return NULL;
2359}
2360
2361/** outputs best feasible primal solution found so far to file stream
2362 *
2363 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2364 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2365 *
2366 * @pre This method can be called if SCIP is in one of the following stages:
2367 * - \ref SCIP_STAGE_INIT
2368 * - \ref SCIP_STAGE_PROBLEM
2369 * - \ref SCIP_STAGE_TRANSFORMED
2370 * - \ref SCIP_STAGE_INITPRESOLVE
2371 * - \ref SCIP_STAGE_PRESOLVING
2372 * - \ref SCIP_STAGE_EXITPRESOLVE
2373 * - \ref SCIP_STAGE_PRESOLVED
2374 * - \ref SCIP_STAGE_INITSOLVE
2375 * - \ref SCIP_STAGE_SOLVING
2376 * - \ref SCIP_STAGE_SOLVED
2377 * - \ref SCIP_STAGE_EXITSOLVE
2378 */
2380 SCIP* scip, /**< SCIP data structure */
2381 FILE* file, /**< output file (or NULL for standard output) */
2382 SCIP_Bool printzeros /**< should variables set to zero be printed? */
2383 )
2384{
2385 SCIP_SOL* sol;
2386
2387 SCIP_CALL( SCIPcheckStage(scip, "SCIPprintBestSol", TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE) );
2388
2390
2391 if( sol == NULL )
2392 SCIPmessageFPrintInfo(scip->messagehdlr, file, "no solution available\n");
2393 else
2394 {
2396 }
2397
2398 return SCIP_OKAY;
2399}
2400
2401/** outputs best feasible primal solution found so far in transformed variables to file stream
2402 *
2403 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2404 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2405 *
2406 * @pre This method can be called if SCIP is in one of the following stages:
2407 * - \ref SCIP_STAGE_INIT
2408 * - \ref SCIP_STAGE_PROBLEM
2409 * - \ref SCIP_STAGE_TRANSFORMED
2410 * - \ref SCIP_STAGE_INITPRESOLVE
2411 * - \ref SCIP_STAGE_PRESOLVING
2412 * - \ref SCIP_STAGE_EXITPRESOLVE
2413 * - \ref SCIP_STAGE_PRESOLVED
2414 * - \ref SCIP_STAGE_INITSOLVE
2415 * - \ref SCIP_STAGE_SOLVING
2416 * - \ref SCIP_STAGE_SOLVED
2417 * - \ref SCIP_STAGE_EXITSOLVE
2418 */
2420 SCIP* scip, /**< SCIP data structure */
2421 FILE* file, /**< output file (or NULL for standard output) */
2422 SCIP_Bool printzeros /**< should variables set to zero be printed? */
2423 )
2424{
2425 SCIP_SOL* sol;
2426
2427 SCIP_CALL( SCIPcheckStage(scip, "SCIPprintBestTransSol", TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE) );
2428
2430
2431 if( sol != NULL && SCIPsolIsOriginal(sol) )
2432 {
2433 SCIPerrorMessage("best solution is defined in original space - cannot print it as transformed solution\n");
2434 return SCIP_INVALIDCALL;
2435 }
2436
2437 if( sol == NULL )
2438 SCIPmessageFPrintInfo(scip->messagehdlr, file, "no solution available\n");
2439 else
2440 {
2442 }
2443
2444 return SCIP_OKAY;
2445}
2446
2447/** try to round given solution
2448 *
2449 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2450 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2451 *
2452 * @pre This method can be called if SCIP is in one of the following stages:
2453 * - \ref SCIP_STAGE_SOLVING
2454 */
2456 SCIP* scip, /**< SCIP data structure */
2457 SCIP_SOL* sol, /**< primal solution */
2458 SCIP_Bool* success /**< pointer to store whether rounding was successful */
2459 )
2460{
2462
2463 if( SCIPsolIsOriginal(sol) )
2464 {
2465 SCIPerrorMessage("cannot round original space solution\n");
2466 return SCIP_INVALIDCALL;
2467 }
2468
2469 SCIP_CALL( SCIPsolRound(sol, scip->set, scip->stat, scip->transprob, scip->tree, success) );
2470
2471 return SCIP_OKAY;
2472}
2473
2474/** retransforms solution to original problem space
2475 *
2476 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2477 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2478 *
2479 * @pre This method can be called if SCIP is in one of the following stages:
2480 * - \ref SCIP_STAGE_TRANSFORMED
2481 * - \ref SCIP_STAGE_INITPRESOLVE
2482 * - \ref SCIP_STAGE_PRESOLVING
2483 * - \ref SCIP_STAGE_EXITPRESOLVE
2484 * - \ref SCIP_STAGE_PRESOLVED
2485 * - \ref SCIP_STAGE_INITSOLVE
2486 * - \ref SCIP_STAGE_SOLVING
2487 * - \ref SCIP_STAGE_SOLVED
2488 * - \ref SCIP_STAGE_EXITSOLVE
2489 * - \ref SCIP_STAGE_FREETRANS
2490 */
2492 SCIP* scip, /**< SCIP data structure */
2493 SCIP_SOL* sol /**< primal CIP solution */
2494 )
2495{
2496 SCIP_CALL( SCIPcheckStage(scip, "SCIPretransformSol", FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
2497
2498 switch ( SCIPsolGetOrigin(sol) )
2499 {
2501 /* nothing to do */
2502 return SCIP_OKAY;
2503
2508
2509 /* first unlink solution */
2511
2512 /*lint -fallthrough*/
2514 {
2515 SCIP_Bool hasinfval;
2516
2517 SCIP_CALL( SCIPsolRetransform(sol, scip->set, scip->stat, scip->origprob, scip->transprob, &hasinfval) );
2518 break;
2519 }
2522 SCIPerrorMessage("unknown solution origin.\n");
2523 return SCIP_INVALIDCALL;
2524
2525 default:
2526 /* note that this is in an internal SCIP error since all solution origins are covert in the switch above */
2527 SCIPerrorMessage("invalid solution origin <%d>\n", SCIPsolGetOrigin(sol));
2528 return SCIP_ERROR;
2529 }
2530
2531 return SCIP_OKAY;
2532}
2533
2534/** reads a given solution file
2535 *
2536 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2537 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2538 *
2539 * @pre This method can be called if SCIP is in one of the following stages:
2540 * - \ref SCIP_STAGE_PROBLEM
2541 * - \ref SCIP_STAGE_TRANSFORMED
2542 * - \ref SCIP_STAGE_INITPRESOLVE
2543 * - \ref SCIP_STAGE_PRESOLVING
2544 * - \ref SCIP_STAGE_EXITPRESOLVE
2545 * - \ref SCIP_STAGE_PRESOLVED
2546 * - \ref SCIP_STAGE_INITSOLVE
2547 * - \ref SCIP_STAGE_SOLVING
2548 */
2550 SCIP* scip, /**< SCIP data structure */
2551 const char* filename /**< name of the input file */
2552 )
2553{
2555
2556 /* we pass the reading of the solution file on to reader_sol via the following call */
2557 SCIP_CALL( SCIPreadProb(scip, filename, "sol") );
2558
2559 return SCIP_OKAY;
2560}
2561
2562/** reads a given solution file and store the solution values in the given solution pointer */
2563static
2565 SCIP* scip, /**< SCIP data structure */
2566 const char* filename, /**< name of the input file */
2567 SCIP_SOL* sol, /**< solution pointer */
2568 SCIP_Bool* partial, /**< pointer to store if the solution is partial (or NULL, if not needed) */
2569 SCIP_Bool* error /**< pointer store if an error occured */
2570 )
2571{
2572 SCIP_FILE* file;
2573 SCIP_Bool unknownvariablemessage;
2574 SCIP_Bool localpartial;
2575 int lineno;
2576
2577 assert(scip != NULL);
2578 assert(sol != NULL);
2579 assert(error != NULL);
2580
2581 /* open input file */
2582 file = SCIPfopen(filename, "r");
2583 if( file == NULL )
2584 {
2585 SCIPerrorMessage("cannot open file <%s> for reading\n", filename);
2586 SCIPprintSysError(filename);
2587 return SCIP_NOFILE;
2588 }
2589
2590 *error = FALSE;
2592
2594 lineno = 0;
2595
2596 /* read the file */
2597 while( !SCIPfeof(file) && !(*error) )
2598 {
2599 char buffer[SCIP_MAXSTRLEN];
2600 char varname[SCIP_MAXSTRLEN];
2603 char format[SCIP_MAXSTRLEN];
2604 SCIP_VAR* var;
2605 SCIP_Real value;
2606 int nread;
2607
2608 /* get next line */
2609 if( SCIPfgets(buffer, (int) sizeof(buffer), file) == NULL )
2610 break;
2611 lineno++;
2612
2613 /* there are some lines which may preceed the solution information */
2614 if( strncasecmp(buffer, "solution status:", 16) == 0 || strncasecmp(buffer, "objective value:", 16) == 0 ||
2615 strncasecmp(buffer, "Log started", 11) == 0 || strncasecmp(buffer, "Variable Name", 13) == 0 ||
2616 strncasecmp(buffer, "All other variables", 19) == 0 || strspn(buffer, " \n\r\t\f") == strlen(buffer) ||
2617 strncasecmp(buffer, "NAME", 4) == 0 || strncasecmp(buffer, "ENDATA", 6) == 0 || /* allow parsing of SOL-format on the MIPLIB 2003 pages */
2618 strncasecmp(buffer, "=obj=", 5) == 0 ) /* avoid "unknown variable" warning when reading MIPLIB SOL files */
2619 continue;
2620
2621 /* parse the line */
2624 if( nread < 2 )
2625 {
2626 SCIPerrorMessage("Invalid input line %d in solution file <%s>: <%s>.\n", lineno, filename, buffer);
2627 *error = TRUE;
2628 break;
2629 }
2630
2631 /* find the variable */
2633 if( var == NULL )
2634 {
2636 {
2637 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "unknown variable <%s> in line %d of solution file <%s>\n",
2638 varname, lineno, filename);
2639 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, " (further unknown variables are ignored)\n");
2641 }
2642 continue;
2643 }
2644
2645 /* cast the value */
2646 if( strncasecmp(valuestring, "inv", 3) == 0 )
2647 continue;
2648 else if( strncasecmp(valuestring, "+inf", 4) == 0 || strncasecmp(valuestring, "inf", 3) == 0 )
2649 value = SCIPinfinity(scip);
2650 else if( strncasecmp(valuestring, "-inf", 4) == 0 )
2651 value = -SCIPinfinity(scip);
2652 else if( strncasecmp(valuestring, "unknown", 7) == 0 )
2653 {
2654 value = SCIP_UNKNOWN;
2656 }
2657 else
2658 {
2659 /* coverity[secure_coding] */
2660 nread = sscanf(valuestring, "%lf", &value);
2661 if( nread != 1 )
2662 {
2663 SCIPerrorMessage("Invalid solution value <%s> for variable <%s> in line %d of solution file <%s>.\n",
2664 valuestring, varname, lineno, filename);
2665 *error = TRUE;
2666 break;
2667 }
2668 }
2669
2670 /* set the solution value of the variable, if not multiaggregated */
2672 {
2673 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "ignored solution value for multiaggregated variable <%s>\n", SCIPvarGetName(var));
2674 }
2675 else
2676 {
2677 SCIP_RETCODE retcode;
2678
2679 retcode = SCIPsetSolVal(scip, sol, var, value);
2680
2681 if( retcode == SCIP_INVALIDDATA )
2682 {
2684 {
2685 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "ignored conflicting solution value for fixed variable <%s>\n",
2687 }
2688 else
2689 {
2690 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "ignored solution value for multiaggregated variable <%s>\n",
2692 }
2693 }
2694 else
2695 {
2696 SCIP_CALL_FINALLY( retcode, SCIPfclose(file) );
2697 }
2698 }
2699 }
2700
2701 /* close input file */
2702 SCIPfclose(file);
2703
2705 {
2707 {
2708 SCIP_CALL( SCIPsolMarkPartial(sol, scip->set, scip->stat, scip->origprob->vars, scip->origprob->nvars) );
2709 }
2710 else
2711 *error = TRUE;
2712 }
2713
2714 if( partial != NULL )
2716
2717 return SCIP_OKAY;
2718}
2719
2720/** reads a given xml solution file and store the solution values in the given solution pointer */
2721static
2723 SCIP* scip, /**< SCIP data structure */
2724 const char* filename, /**< name of the input file */
2725 SCIP_SOL* sol, /**< solution pointer */
2726 SCIP_Bool* partial, /**< pointer to store if the solution is partial (or NULL if not needed) */
2727 SCIP_Bool* error /**< pointer store if an error occured */
2728 )
2729{
2730 SCIP_Bool unknownvariablemessage;
2731 SCIP_Bool localpartial;
2732 XML_NODE* start;
2733 const XML_NODE* varsnode;
2734 const XML_NODE* varnode;
2735 const char* tag;
2736
2737 assert(scip != NULL);
2738 assert(sol != NULL);
2739 assert(error != NULL);
2740
2741 /* read xml file */
2742 start = xmlProcess(filename);
2743
2744 if( start == NULL )
2745 {
2746 SCIPerrorMessage("Some error occured during parsing the XML solution file.\n");
2747 return SCIP_READERROR;
2748 }
2749
2750 *error = FALSE;
2752
2753 /* find variable sections */
2754 tag = "variables";
2756 if( varsnode == NULL )
2757 {
2758 /* free xml data */
2760
2761 SCIPerrorMessage("Variable section not found.\n");
2762 return SCIP_READERROR;
2763 }
2764
2765 /* loop through all variables */
2768 {
2769 SCIP_VAR* var;
2770 const char* varname;
2771 const char* valuestring;
2772 SCIP_Real value;
2773 int nread;
2774
2775 /* find variable name */
2776 varname = xmlGetAttrval(varnode, "name");
2777 if( varname == NULL )
2778 {
2779 SCIPerrorMessage("Attribute \"name\" of variable not found.\n");
2780 *error = TRUE;
2781 break;
2782 }
2783
2784 /* find the variable */
2786 if( var == NULL )
2787 {
2789 {
2790 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "unknown variable <%s> of solution file <%s>\n",
2791 varname, filename);
2792 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, " (further unknown variables are ignored)\n");
2794 }
2795 continue;
2796 }
2797
2798 /* find value of variable */
2799 valuestring = xmlGetAttrval(varnode, "value");
2800 if( valuestring == NULL )
2801 {
2802 SCIPerrorMessage("Attribute \"value\" of variable not found.\n");
2803 *error = TRUE;
2804 break;
2805 }
2806
2807 /* cast the value */
2808 if( strncasecmp(valuestring, "inv", 3) == 0 )
2809 continue;
2810 else if( strncasecmp(valuestring, "+inf", 4) == 0 || strncasecmp(valuestring, "inf", 3) == 0 )
2811 value = SCIPinfinity(scip);
2812 else if( strncasecmp(valuestring, "-inf", 4) == 0 )
2813 value = -SCIPinfinity(scip);
2814 else if( strncasecmp(valuestring, "unknown", 7) == 0 )
2815 {
2816 value = SCIP_UNKNOWN;
2818 }
2819 else
2820 {
2821 /* coverity[secure_coding] */
2822 nread = sscanf(valuestring, "%lf", &value);
2823 if( nread != 1 )
2824 {
2825 SCIPwarningMessage(scip, "invalid solution value <%s> for variable <%s> in XML solution file <%s>\n", valuestring, varname, filename);
2826 *error = TRUE;
2827 break;
2828 }
2829 }
2830
2831 /* set the solution value of the variable, if not multiaggregated */
2833 {
2834 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "ignored solution value for multiaggregated variable <%s>\n", SCIPvarGetName(var));
2835 }
2836 else
2837 {
2838 SCIP_RETCODE retcode;
2839 retcode = SCIPsetSolVal(scip, sol, var, value);
2840
2841 if( retcode == SCIP_INVALIDDATA )
2842 {
2844 {
2845 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "ignored conflicting solution value for fixed variable <%s>\n",
2847 }
2848 else
2849 {
2850 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "ignored solution value for multiaggregated variable <%s>\n",
2852 }
2853 }
2854 else
2855 {
2856 SCIP_CALL( retcode );
2857 }
2858 }
2859 }
2860
2861 /* free xml data */
2863
2865 {
2867 {
2868 SCIP_CALL( SCIPsolMarkPartial(sol, scip->set, scip->stat, scip->origprob->vars, scip->origprob->nvars) );
2869 }
2870 else
2871 *error = TRUE;
2872 }
2873
2874 if( partial != NULL )
2876
2877 return SCIP_OKAY;
2878}
2879
2880/** reads a given solution file and store the solution values in the given solution pointer
2881 *
2882 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2883 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2884 *
2885 * @pre This method can be called if SCIP is in one of the following stages:
2886 * - \ref SCIP_STAGE_PROBLEM
2887 * - \ref SCIP_STAGE_TRANSFORMED
2888 * - \ref SCIP_STAGE_INITPRESOLVE
2889 * - \ref SCIP_STAGE_PRESOLVING
2890 * - \ref SCIP_STAGE_EXITPRESOLVE
2891 * - \ref SCIP_STAGE_PRESOLVED
2892 * - \ref SCIP_STAGE_INITSOLVE
2893 * - \ref SCIP_STAGE_SOLVING
2894 */
2896 SCIP* scip, /**< SCIP data structure */
2897 const char* filename, /**< name of the input file */
2898 SCIP_SOL* sol, /**< solution pointer */
2899 SCIP_Bool xml, /**< true, iff the given solution in written in XML */
2900 SCIP_Bool* partial, /**< pointer to store if the solution is partial */
2901 SCIP_Bool* error /**< pointer store if an error occured */
2902 )
2903{
2904 SCIP_CALL( SCIPcheckStage(scip, "SCIPreadSolFile", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE) );
2905
2906 if( xml )
2907 {
2908 SCIP_CALL( readXmlSolFile(scip, filename, sol, partial, error) );
2909 }
2910 else
2911 {
2912 SCIP_CALL( readSolFile(scip, filename, sol, partial, error) );
2913 }
2914
2915 return SCIP_OKAY;
2916}
2917
2918/** adds feasible primal solution to solution storage by copying it
2919 *
2920 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2921 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2922 *
2923 * @pre This method can be called if SCIP is in one of the following stages:
2924 * - \ref SCIP_STAGE_PROBLEM
2925 * - \ref SCIP_STAGE_TRANSFORMED
2926 * - \ref SCIP_STAGE_INITPRESOLVE
2927 * - \ref SCIP_STAGE_PRESOLVING
2928 * - \ref SCIP_STAGE_EXITPRESOLVE
2929 * - \ref SCIP_STAGE_PRESOLVED
2930 * - \ref SCIP_STAGE_SOLVING
2931 * - \ref SCIP_STAGE_FREETRANS
2932 *
2933 * @note Do not call during propagation, use heur_trysol instead.
2934 */
2936 SCIP* scip, /**< SCIP data structure */
2937 SCIP_SOL* sol, /**< primal CIP solution */
2938 SCIP_Bool* stored /**< stores whether given solution was good enough to keep */
2939 )
2940{
2942
2943 switch( scip->set->stage )
2944 {
2945 case SCIP_STAGE_PROBLEM:
2948 SCIP_CALL( SCIPprimalAddOrigSol(scip->origprimal, scip->mem->probmem, scip->set, scip->stat, scip->origprob, sol, stored) );
2949 return SCIP_OKAY;
2950
2956 case SCIP_STAGE_SOLVING:
2957 {
2958 SCIP_SOL* bestsol = SCIPgetBestSol(scip);
2959
2960 SCIP_CALL( SCIPprimalAddSol(scip->primal, scip->mem->probmem, scip->set, scip->messagehdlr, scip->stat,
2961 scip->origprob, scip->transprob, scip->tree, scip->reopt, scip->lp, scip->eventqueue, scip->eventfilter, sol,
2962 stored) );
2963
2964 /* @todo use solution index rather than pointer */
2965 if( *stored && (bestsol != SCIPgetBestSol(scip)) )
2966 {
2968 }
2969
2970 return SCIP_OKAY;
2971 }
2974 case SCIP_STAGE_SOLVED:
2976 default:
2977 SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
2978 return SCIP_INVALIDCALL;
2979 } /*lint !e788*/
2980}
2981
2982/** adds primal solution to solution storage, frees the solution afterwards
2983 *
2984 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2985 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2986 *
2987 * @pre This method can be called if SCIP is in one of the following stages:
2988 * - \ref SCIP_STAGE_PROBLEM
2989 * - \ref SCIP_STAGE_TRANSFORMED
2990 * - \ref SCIP_STAGE_INITPRESOLVE
2991 * - \ref SCIP_STAGE_PRESOLVING
2992 * - \ref SCIP_STAGE_EXITPRESOLVE
2993 * - \ref SCIP_STAGE_PRESOLVED
2994 * - \ref SCIP_STAGE_SOLVING
2995 * - \ref SCIP_STAGE_FREETRANS
2996 *
2997 * @note Do not call during propagation, use heur_trysol instead.
2998 */
3000 SCIP* scip, /**< SCIP data structure */
3001 SCIP_SOL** sol, /**< pointer to primal CIP solution; is cleared in function call */
3002 SCIP_Bool* stored /**< stores whether given solution was good enough to keep */
3003 )
3004{
3006
3007 switch( scip->set->stage )
3008 {
3009 case SCIP_STAGE_PROBLEM:
3012 SCIP_CALL( SCIPprimalAddOrigSolFree(scip->origprimal, scip->mem->probmem, scip->set, scip->stat, scip->origprob, sol, stored) );
3013 return SCIP_OKAY;
3014
3020 case SCIP_STAGE_SOLVING:
3021 {
3022 SCIP_SOL* bestsol = SCIPgetBestSol(scip);
3023
3024 SCIP_CALL( SCIPprimalAddSolFree(scip->primal, scip->mem->probmem, scip->set, scip->messagehdlr, scip->stat,
3025 scip->origprob, scip->transprob, scip->tree, scip->reopt, scip->lp, scip->eventqueue, scip->eventfilter,
3026 sol, stored) );
3027
3028 if( *stored )
3029 {
3030 if( bestsol != SCIPgetBestSol(scip) )
3031 {
3034 }
3035 }
3036
3037 return SCIP_OKAY;
3038 }
3041 case SCIP_STAGE_SOLVED:
3043 default:
3044 SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
3045 return SCIP_INVALIDCALL;
3046 } /*lint !e788*/
3047}
3048
3049/** adds current LP/pseudo solution to solution storage
3050 *
3051 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
3052 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
3053 *
3054 * @pre This method can be called if SCIP is in one of the following stages:
3055 * - \ref SCIP_STAGE_PRESOLVED
3056 * - \ref SCIP_STAGE_SOLVING
3057 */
3059 SCIP* scip, /**< SCIP data structure */
3060 SCIP_HEUR* heur, /**< heuristic that found the solution */
3061 SCIP_Bool* stored /**< stores whether given solution was good enough to keep */
3062 )
3063{
3064 SCIP_SOL* bestsol;
3065
3067
3068 bestsol = SCIPgetBestSol(scip);
3069
3070 SCIP_CALL( SCIPprimalAddCurrentSol(scip->primal, scip->mem->probmem, scip->set, scip->messagehdlr, scip->stat,
3071 scip->origprob, scip->transprob, scip->tree, scip->reopt, scip->lp, scip->eventqueue, scip->eventfilter, heur,
3072 stored) );
3073
3074 if( *stored )
3075 {
3076 if( bestsol != SCIPgetBestSol(scip) )
3078 }
3079
3080 return SCIP_OKAY;
3081}
3082
3083/** checks solution for feasibility; if possible, adds it to storage by copying
3084 *
3085 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
3086 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
3087 *
3088 * @pre This method can be called if SCIP is in one of the following stages:
3089 * - \ref SCIP_STAGE_TRANSFORMED
3090 * - \ref SCIP_STAGE_INITPRESOLVE
3091 * - \ref SCIP_STAGE_PRESOLVING
3092 * - \ref SCIP_STAGE_EXITPRESOLVE
3093 * - \ref SCIP_STAGE_PRESOLVED
3094 * - \ref SCIP_STAGE_SOLVING
3095 *
3096 * @note Do not call during propagation, use heur_trysol instead.
3097 */
3099 SCIP* scip, /**< SCIP data structure */
3100 SCIP_SOL* sol, /**< primal CIP solution */
3101 SCIP_Bool printreason, /**< Should all reasons of violation be printed? */
3102 SCIP_Bool completely, /**< Should all violations be checked if printreason is true? */
3103 SCIP_Bool checkbounds, /**< Should the bounds of the variables be checked? */
3104 SCIP_Bool checkintegrality, /**< Has integrality to be checked? */
3105 SCIP_Bool checklprows, /**< Do constraints represented by rows in the current LP have to be checked? */
3106 SCIP_Bool* stored /**< stores whether given solution was feasible and good enough to keep */
3107 )
3108{
3109 SCIP_SOL* bestsol;
3110
3111 assert(sol != NULL);
3112 assert(stored != NULL);
3113
3115
3116 bestsol = SCIPgetBestSol(scip);
3117
3118 if( !printreason )
3119 completely = FALSE;
3120
3121 /* we cannot check partial solutions */
3122 if( SCIPsolIsPartial(sol) )
3123 {
3124 SCIPerrorMessage("Cannot check feasibility of partial solutions.\n");
3125 return SCIP_INVALIDDATA;
3126 }
3127
3128 if( SCIPsolIsOriginal(sol) )
3129 {
3130 SCIP_Bool feasible;
3131
3132 /* SCIPprimalTrySol() can only be called on transformed solutions; therefore check solutions in original problem
3133 * including modifiable constraints */
3135 if( feasible )
3136 {
3137 SCIP_CALL( SCIPprimalAddSol(scip->primal, scip->mem->probmem, scip->set, scip->messagehdlr, scip->stat,
3138 scip->origprob, scip->transprob, scip->tree, scip->reopt, scip->lp, scip->eventqueue, scip->eventfilter,
3139 sol, stored) );
3140
3141 if( *stored )
3142 {
3143 if( bestsol != SCIPgetBestSol(scip) )
3145 }
3146 }
3147 else
3148 *stored = FALSE;
3149 }
3150 else
3151 {
3152 SCIP_CALL( SCIPprimalTrySol(scip->primal, scip->mem->probmem, scip->set, scip->messagehdlr, scip->stat, scip->origprob,
3153 scip->transprob, scip->tree, scip->reopt, scip->lp, scip->eventqueue, scip->eventfilter, sol, printreason,
3155
3156 if( *stored )
3157 {
3158 if( bestsol != SCIPgetBestSol(scip) )
3159 {
3160#ifdef SCIP_DEBUG_ABORTATORIGINFEAS
3161 SCIP_Bool feasible;
3163
3164 if( ! feasible )
3165 {
3166 SCIPerrorMessage("Accepted solution not feasible for original problem\n");
3167 SCIPABORT();
3168 }
3169#endif
3171 }
3172 }
3173 }
3174
3175 return SCIP_OKAY;
3176}
3177
3178/** checks primal solution; if feasible, adds it to storage; solution is freed afterwards
3179 *
3180 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
3181 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
3182 *
3183 * @pre This method can be called if SCIP is in one of the following stages:
3184 * - \ref SCIP_STAGE_TRANSFORMED
3185 * - \ref SCIP_STAGE_INITPRESOLVE
3186 * - \ref SCIP_STAGE_PRESOLVING
3187 * - \ref SCIP_STAGE_EXITPRESOLVE
3188 * - \ref SCIP_STAGE_PRESOLVED
3189 * - \ref SCIP_STAGE_SOLVING
3190 *
3191 * @note Do not call during propagation, use heur_trysol instead.
3192 */
3194 SCIP* scip, /**< SCIP data structure */
3195 SCIP_SOL** sol, /**< pointer to primal CIP solution; is cleared in function call */
3196 SCIP_Bool printreason, /**< Should all reasons of violations be printed */
3197 SCIP_Bool completely, /**< Should all violations be checked if printreason is true? */
3198 SCIP_Bool checkbounds, /**< Should the bounds of the variables be checked? */
3199 SCIP_Bool checkintegrality, /**< Has integrality to be checked? */
3200 SCIP_Bool checklprows, /**< Do constraints represented by rows in the current LP have to be checked? */
3201 SCIP_Bool* stored /**< stores whether solution was feasible and good enough to keep */
3202 )
3203{
3204 SCIP_SOL* bestsol;
3205
3206 assert(stored != NULL);
3207 assert(sol != NULL);
3208
3210
3211 bestsol = SCIPgetBestSol(scip);
3212
3213 if( !printreason )
3214 completely = FALSE;
3215
3216 /* we cannot check partial solutions */
3217 if( SCIPsolIsPartial(*sol) )
3218 {
3219 SCIPerrorMessage("Cannot check feasibility of partial solutions.\n");
3220 return SCIP_INVALIDDATA;
3221 }
3222
3223 if( SCIPsolIsOriginal(*sol) )
3224 {
3225 SCIP_Bool feasible;
3226
3227 /* SCIPprimalTrySol() can only be called on transformed solutions; therefore check solutions in original problem
3228 * including modifiable constraints
3229 */
3231
3232 if( feasible )
3233 {
3234 SCIP_CALL( SCIPprimalAddSolFree(scip->primal, scip->mem->probmem, scip->set, scip->messagehdlr, scip->stat,
3235 scip->origprob, scip->transprob, scip->tree, scip->reopt, scip->lp, scip->eventqueue, scip->eventfilter,
3236 sol, stored) );
3237
3238 if( *stored )
3239 {
3240 if( bestsol != SCIPgetBestSol(scip) )
3242 }
3243 }
3244 else
3245 {
3246 SCIP_CALL( SCIPsolFree(sol, scip->mem->probmem, scip->primal) );
3247 *stored = FALSE;
3248 }
3249 }
3250 else
3251 {
3252 SCIP_CALL( SCIPprimalTrySolFree(scip->primal, scip->mem->probmem, scip->set, scip->messagehdlr, scip->stat,
3253 scip->origprob, scip->transprob, scip->tree, scip->reopt, scip->lp, scip->eventqueue, scip->eventfilter,
3255
3256 if( *stored )
3257 {
3258 if( bestsol != SCIPgetBestSol(scip) )
3259 {
3260#ifdef SCIP_DEBUG_ABORTATORIGINFEAS
3261 SCIP_Bool feasible;
3263
3264 if( ! feasible )
3265 {
3266 SCIPerrorMessage("Accepted incumbent not feasible for original problem\n");
3267 SCIPABORT();
3268 }
3269#endif
3271 }
3272 }
3273 }
3274
3275 return SCIP_OKAY;
3276}
3277
3278/** checks current LP/pseudo solution for feasibility; if possible, adds it to storage
3279 *
3280 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
3281 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
3282 *
3283 * @pre This method can be called if SCIP is in one of the following stages:
3284 * - \ref SCIP_STAGE_PRESOLVED
3285 * - \ref SCIP_STAGE_SOLVING
3286 */
3288 SCIP* scip, /**< SCIP data structure */
3289 SCIP_HEUR* heur, /**< heuristic that found the solution */
3290 SCIP_Bool printreason, /**< Should all reasons of violations be printed? */
3291 SCIP_Bool completely, /**< Should all violations be checked if printreason is true? */
3292 SCIP_Bool checkintegrality, /**< Has integrality to be checked? */
3293 SCIP_Bool checklprows, /**< Do constraints represented by rows in the current LP have to be checked? */
3294 SCIP_Bool* stored /**< stores whether given solution was feasible and good enough to keep */
3295 )
3296{
3297 SCIP_SOL* bestsol;
3298
3300
3301 bestsol = SCIPgetBestSol(scip);
3302
3303 if( !printreason )
3304 completely = FALSE;
3305
3306 SCIP_CALL( SCIPprimalTryCurrentSol(scip->primal, scip->mem->probmem, scip->set, scip->messagehdlr, scip->stat,
3307 scip->origprob, scip->transprob, scip->tree, scip->reopt, scip->lp, scip->eventqueue, scip->eventfilter, heur,
3309
3310 if( *stored )
3311 {
3312 if( bestsol != SCIPgetBestSol(scip) )
3313 {
3314#ifdef SCIP_DEBUG_ABORTATORIGINFEAS
3315 SCIP_Bool feasible;
3317
3318 if( ! feasible )
3319 {
3320 SCIPerrorMessage("Accepted incumbent not feasible for original problem\n");
3321 SCIPABORT();
3322 }
3323#endif
3325 }
3326 }
3327
3328 return SCIP_OKAY;
3329}
3330
3331/** returns all partial solutions
3332 *
3333 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
3334 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
3335 *
3336 * @pre This method can be called if SCIP is in one of the following stages:
3337 * - \ref SCIP_STAGE_PROBLEM
3338 * - \ref SCIP_STAGE_PRESOLVING
3339 * - \ref SCIP_STAGE_SOLVING
3340 * - \ref SCIP_STAGE_SOLVED
3341 */
3343 SCIP* scip /**< SCIP data structure */
3344 )
3345{
3346 assert(scip != NULL);
3347
3349
3350 return scip->origprimal->partialsols;
3351}
3352
3353/** returns number of partial solutions
3354 *
3355 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
3356 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
3357 *
3358 * @pre This method can be called if SCIP is in one of the following stages:
3359 * - \ref SCIP_STAGE_PROBLEM
3360 * - \ref SCIP_STAGE_PRESOLVING
3361 * - \ref SCIP_STAGE_SOLVING
3362 * - \ref SCIP_STAGE_SOLVED
3363 */
3365 SCIP* scip /**< SCIP data structure */
3366 )
3367{
3368 assert(scip != NULL);
3369
3371
3372 return scip->origprimal->npartialsols;
3373}
3374
3375/** checks solution for feasibility without adding it to the solution store
3376 *
3377 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
3378 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
3379 *
3380 * @pre This method can be called if SCIP is in one of the following stages:
3381 * - \ref SCIP_STAGE_PROBLEM
3382 * - \ref SCIP_STAGE_TRANSFORMED
3383 * - \ref SCIP_STAGE_INITPRESOLVE
3384 * - \ref SCIP_STAGE_PRESOLVING
3385 * - \ref SCIP_STAGE_EXITPRESOLVE
3386 * - \ref SCIP_STAGE_PRESOLVED
3387 * - \ref SCIP_STAGE_INITSOLVE
3388 * - \ref SCIP_STAGE_SOLVING
3389 * - \ref SCIP_STAGE_SOLVED
3390 */
3392 SCIP* scip, /**< SCIP data structure */
3393 SCIP_SOL* sol, /**< primal CIP solution */
3394 SCIP_Bool printreason, /**< Should all reasons of violations be printed? */
3395 SCIP_Bool completely, /**< Should all violations be checked if printreason is true? */
3396 SCIP_Bool checkbounds, /**< Should the bounds of the variables be checked? */
3397 SCIP_Bool checkintegrality, /**< Has integrality to be checked? */
3398 SCIP_Bool checklprows, /**< Do constraints represented by rows in the current LP have to be checked? */
3399 SCIP_Bool* feasible /**< stores whether given solution is feasible */
3400 )
3401{
3403
3404 /* return immediately if the solution is of type partial */
3405 if( SCIPsolIsPartial(sol) )
3406 {
3407 SCIPerrorMessage("Cannot check feasibility of partial solutions.");
3408 return SCIP_INVALIDDATA;
3409 }
3410
3411 /* if we want to solve exactly, the constraint handlers cannot rely on the LP's feasibility */
3412 checklprows = checklprows || scip->set->misc_exactsolve;
3413
3414 if( !printreason )
3415 completely = FALSE;
3416
3417 if( SCIPsolIsOriginal(sol) )
3418 {
3419 /* SCIPsolCheck() can only be called on transformed solutions */
3421 }
3422 else
3423 {
3424 SCIP_CALL( SCIPsolCheck(sol, scip->set, scip->messagehdlr, scip->mem->probmem, scip->stat, scip->transprob,
3426 }
3427
3428 return SCIP_OKAY;
3429}
3430
3431/** checks solution for feasibility in original problem without adding it to the solution store;
3432 * this method is used to double check a solution in order to validate the presolving process
3433 *
3434 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
3435 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
3436 *
3437 * @pre This method can be called if SCIP is in one of the following stages:
3438 * - \ref SCIP_STAGE_PROBLEM
3439 * - \ref SCIP_STAGE_TRANSFORMED
3440 * - \ref SCIP_STAGE_INITPRESOLVE
3441 * - \ref SCIP_STAGE_PRESOLVING
3442 * - \ref SCIP_STAGE_EXITPRESOLVE
3443 * - \ref SCIP_STAGE_PRESOLVED
3444 * - \ref SCIP_STAGE_INITSOLVE
3445 * - \ref SCIP_STAGE_SOLVING
3446 * - \ref SCIP_STAGE_SOLVED
3447 */
3449 SCIP* scip, /**< SCIP data structure */
3450 SCIP_SOL* sol, /**< primal CIP solution */
3451 SCIP_Bool* feasible, /**< stores whether given solution is feasible */
3452 SCIP_Bool printreason, /**< should the reason for the violation be printed? */
3453 SCIP_Bool completely /**< Should all violations be checked if printreason is true? */
3454 )
3455{
3456 assert(scip != NULL);
3457 assert(sol != NULL);
3458 assert(feasible != NULL);
3459
3460 SCIP_CALL( SCIPcheckStage(scip, "SCIPcheckSolOrig", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
3461
3462 /* return immediately if the solution is of type partial */
3463 if( SCIPsolIsPartial(sol) )
3464 {
3465 SCIPerrorMessage("Cannot check feasibility of partial solutions.");
3466 return SCIP_INVALIDDATA;
3467 }
3468
3469 if( !printreason )
3470 completely = FALSE;
3471
3472 /* check solution in original problem; that includes bounds, integrality, and non modifiable constraints */
3474
3475 return SCIP_OKAY;
3476}
3477
3478/** return whether a primal ray is stored that proves unboundedness of the LP relaxation
3479 *
3480 * @return return whether a primal ray is stored that proves unboundedness of the LP relaxation
3481 *
3482 * @pre This method can be called if SCIP is in one of the following stages:
3483 * - \ref SCIP_STAGE_SOLVING
3484 * - \ref SCIP_STAGE_SOLVED
3485 */
3487 SCIP* scip /**< SCIP data structure */
3488 )
3489{
3491
3492 return scip->primal->primalray != NULL;
3493}
3494
3495/** gets value of given variable in primal ray causing unboundedness of the LP relaxation;
3496 * should only be called if such a ray is stored (check with SCIPhasPrimalRay())
3497 *
3498 * @return value of given variable in primal ray causing unboundedness of the LP relaxation
3499 *
3500 * @pre This method can be called if SCIP is in one of the following stages:
3501 * - \ref SCIP_STAGE_SOLVING
3502 * - \ref SCIP_STAGE_SOLVED
3503 */
3505 SCIP* scip, /**< SCIP data structure */
3506 SCIP_VAR* var /**< variable to get value for */
3507 )
3508{
3510
3511 assert(var != NULL);
3512 assert(scip->primal->primalray != NULL);
3513 assert(var->scip == scip);
3514
3515 return SCIPsolGetRayVal(scip->primal->primalray, scip->set, scip->stat, var);
3516}
3517
3518/** updates the primal ray thats proves unboundedness
3519 *
3520 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
3521 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
3522 *
3523 * @pre This method can be called if @p scip is in one of the following stages:
3524 * - \ref SCIP_STAGE_PRESOLVING
3525 * - \ref SCIP_STAGE_PRESOLVED
3526 * - \ref SCIP_STAGE_SOLVING
3527 * - \ref SCIP_STAGE_SOLVED
3528 *
3529 * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
3530 */
3532 SCIP* scip, /**< SCIP data structure */
3533 SCIP_SOL* primalray /**< the new primal ray */
3534 )
3535{
3536 assert(scip != NULL);
3537 assert(primalray != NULL);
3538
3539 SCIP_CALL( SCIPcheckStage(scip, "SCIPupdatePrimalRay", FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE) );
3540
3541 SCIP_CALL( SCIPprimalUpdateRay(scip->primal, scip->set, scip->stat, primalray, scip->mem->probmem) );
3542
3543 return SCIP_OKAY;
3544}
SCIP_VAR * h
SCIP_RETCODE SCIPconsGetNVars(SCIP_CONS *cons, SCIP_SET *set, int *nvars, SCIP_Bool *success)
Definition cons.c:6321
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:7298
SCIP_CONS * SCIPconsGetTransformed(SCIP_CONS *cons)
Definition cons.c:6722
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:3743
internal methods for constraints and constraint handlers
Constraint handler for linear constraints in their most general form, .
SCIP_RETCODE SCIPcheckStage(SCIP *scip, const char *method, SCIP_Bool init, SCIP_Bool problem, SCIP_Bool transforming, SCIP_Bool transformed, SCIP_Bool initpresolve, SCIP_Bool presolving, SCIP_Bool exitpresolve, SCIP_Bool presolved, SCIP_Bool initsolve, SCIP_Bool solving, SCIP_Bool solved, SCIP_Bool exitsolve, SCIP_Bool freetrans, SCIP_Bool freescip)
Definition debug.c:2208
methods for debugging
#define SCIP_MAXSTRLEN
Definition def.h:302
#define SCIP_INVALID
Definition def.h:206
#define SCIP_UNKNOWN
Definition def.h:207
#define TRUE
Definition def.h:95
#define FALSE
Definition def.h:96
#define SCIP_CALL_ABORT(x)
Definition def.h:367
#define SCIPABORT()
Definition def.h:360
#define REALABS(x)
Definition def.h:210
#define SCIP_CALL(x)
Definition def.h:388
#define SCIP_CALL_FINALLY(x, y)
Definition def.h:430
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:3046
SCIP_Bool SCIPisTransformed(SCIP *scip)
SCIP_RETCODE SCIPfree(SCIP **scip)
SCIP_RETCODE SCIPcreate(SCIP **scip)
SCIP_STAGE SCIPgetStage(SCIP *scip)
SCIP_RETCODE SCIPaddVar(SCIP *scip, SCIP_VAR *var)
Definition scip_prob.c:1668
SCIP_RETCODE SCIPgetOrigVarsData(SCIP *scip, SCIP_VAR ***vars, int *nvars, int *nbinvars, int *nintvars, int *nimplvars, int *ncontvars)
Definition scip_prob.c:2357
SCIP_RETCODE SCIPaddCons(SCIP *scip, SCIP_CONS *cons)
Definition scip_prob.c:2770
SCIP_OBJSENSE SCIPgetObjsense(SCIP *scip)
Definition scip_prob.c:1225
int SCIPgetNFixedVars(SCIP *scip)
Definition scip_prob.c:2309
SCIP_VAR ** SCIPgetFixedVars(SCIP *scip)
Definition scip_prob.c:2266
SCIP_VAR * SCIPfindVar(SCIP *scip, const char *name)
Definition scip_prob.c:2685
SCIP_RETCODE SCIPreadProb(SCIP *scip, const char *filename, const char *extension)
Definition scip_prob.c:339
void SCIPhashmapFree(SCIP_HASHMAP **hashmap)
Definition misc.c:3058
void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin)
Definition misc.c:3211
SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize)
Definition misc.c:3024
void SCIPverbMessage(SCIP *scip, SCIP_VERBLEVEL msgverblevel, FILE *file, const char *formatstr,...)
#define SCIPdebugMsg
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
SCIP_Real SCIPrelDiff(SCIP_Real val1, SCIP_Real val2)
Definition misc.c:11096
SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value)
Definition scip_param.c:487
const char * SCIPconshdlrGetName(SCIP_CONSHDLR *conshdlr)
Definition cons.c:4180
SCIP_Bool SCIPconshdlrNeedsCons(SCIP_CONSHDLR *conshdlr)
Definition cons.c:5119
int SCIPconshdlrGetCheckPriority(SCIP_CONSHDLR *conshdlr)
Definition cons.c:5079
SCIP_CONSHDLR * SCIPconsGetHdlr(SCIP_CONS *cons)
Definition cons.c:8108
SCIP_Bool SCIPconsIsChecked(SCIP_CONS *cons)
Definition cons.c:8287
SCIP_Bool SCIPconsIsTransformed(SCIP_CONS *cons)
Definition cons.c:8397
const char * SCIPconsGetName(SCIP_CONS *cons)
Definition cons.c:8088
SCIP_Bool SCIPconsIsModifiable(SCIP_CONS *cons)
Definition cons.c:8337
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
Definition scip_cons.c:1119
#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_RETCODE SCIPcheckSolOrig(SCIP *scip, SCIP_SOL *sol, SCIP_Bool *feasible, SCIP_Bool printreason, SCIP_Bool completely)
Definition scip_sol.c:3448
SCIP_SOL * SCIPgetBestSol(SCIP *scip)
Definition scip_sol.c:2313
SCIP_RETCODE SCIPcreateSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition scip_sol.c:328
SCIP_SOLORIGIN SCIPsolGetOrigin(SCIP_SOL *sol)
Definition sol.c:2545
SCIP_RETCODE SCIPlinkPseudoSol(SCIP *scip, SCIP_SOL *sol)
Definition scip_sol.c:1111
int SCIPgetSolRunnum(SCIP *scip, SCIP_SOL *sol)
Definition scip_sol.c:1630
SCIP_RETCODE SCIPreadSolFile(SCIP *scip, const char *filename, SCIP_SOL *sol, SCIP_Bool xml, SCIP_Bool *partial, SCIP_Bool *error)
Definition scip_sol.c:2895
SCIP_RETCODE SCIPcreateUnknownSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition scip_sol.c:533
SCIP_RETCODE SCIPprintTransSol(SCIP *scip, SCIP_SOL *sol, FILE *file, SCIP_Bool printzeros)
Definition scip_sol.c:1857
SCIP_Real SCIPsolGetOrigObj(SCIP_SOL *sol)
Definition sol.c:2575
SCIP_RETCODE SCIPcreateSolCopy(SCIP *scip, SCIP_SOL **sol, SCIP_SOL *sourcesol)
Definition scip_sol.c:618
void SCIPupdateSolIntegralityViolation(SCIP *scip, SCIP_SOL *sol, SCIP_Real absviol)
Definition scip_sol.c:238
SCIP_RETCODE SCIPprintBestSol(SCIP *scip, FILE *file, SCIP_Bool printzeros)
Definition scip_sol.c:2379
SCIP_SOL ** SCIPgetPartialSols(SCIP *scip)
Definition scip_sol.c:3342
void SCIPupdateSolLPRowViolation(SCIP *scip, SCIP_SOL *sol, SCIP_Real absviol, SCIP_Real relviol)
Definition scip_sol.c:261
SCIP_RETCODE SCIPfreeSol(SCIP *scip, SCIP_SOL **sol)
Definition scip_sol.c:985
SCIP_HEUR * SCIPgetSolHeur(SCIP *scip, SCIP_SOL *sol)
Definition scip_sol.c:1684
void SCIPupdateSolBoundViolation(SCIP *scip, SCIP_SOL *sol, SCIP_Real absviol, SCIP_Real relviol)
Definition scip_sol.c:249
SCIP_RETCODE SCIPaddSolFree(SCIP *scip, SCIP_SOL **sol, SCIP_Bool *stored)
Definition scip_sol.c:2999
SCIP_RETCODE SCIPprintRay(SCIP *scip, SCIP_SOL *sol, FILE *file, SCIP_Bool printzeros)
Definition scip_sol.c:2178
SCIP_RETCODE SCIPprintSol(SCIP *scip, SCIP_SOL *sol, FILE *file, SCIP_Bool printzeros)
Definition scip_sol.c:1775
SCIP_Real SCIPsolGetTime(SCIP_SOL *sol)
Definition sol.c:2598
SCIP_RETCODE SCIPcreateCurrentSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition scip_sol.c:483
SCIP_RETCODE SCIPgetDualSolVal(SCIP *scip, SCIP_CONS *cons, SCIP_Real *dualsolval, SCIP_Bool *boundconstraint)
Definition scip_sol.c:1956
SCIP_Bool SCIPareSolsEqual(SCIP *scip, SCIP_SOL *sol1, SCIP_SOL *sol2)
Definition scip_sol.c:1712
SCIP_RETCODE SCIPclearSol(SCIP *scip, SCIP_SOL *sol)
Definition scip_sol.c:1162
SCIP_Longint SCIPsolGetNodenum(SCIP_SOL *sol)
Definition sol.c:2618
SCIP_RETCODE SCIPcreateNLPSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition scip_sol.c:398
SCIP_Real SCIPtransformObj(SCIP *scip, SCIP_Real obj)
Definition scip_sol.c:1551
int SCIPgetNPartialSols(SCIP *scip)
Definition scip_sol.c:3364
int SCIPgetNSols(SCIP *scip)
Definition scip_sol.c:2214
SCIP_HEUR * SCIPsolGetHeur(SCIP_SOL *sol)
Definition sol.c:2638
SCIP_RETCODE SCIPcreateLPSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition scip_sol.c:370
SCIP_RETCODE SCIPlinkCurrentSol(SCIP *scip, SCIP_SOL *sol)
Definition scip_sol.c:1131
SCIP_RETCODE SCIPcreateFiniteSolCopy(SCIP *scip, SCIP_SOL **sol, SCIP_SOL *sourcesol, SCIP_Bool *success)
Definition scip_sol.c:849
SCIP_RETCODE SCIPprintBestTransSol(SCIP *scip, FILE *file, SCIP_Bool printzeros)
Definition scip_sol.c:2419
SCIP_RETCODE SCIPadjustImplicitSolVals(SCIP *scip, SCIP_SOL *sol, SCIP_Bool uselprows)
Definition scip_sol.c:1732
SCIP_RETCODE SCIPaddCurrentSol(SCIP *scip, SCIP_HEUR *heur, SCIP_Bool *stored)
Definition scip_sol.c:3058
SCIP_RETCODE SCIPcreateOrigSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition scip_sol.c:565
SCIP_RETCODE SCIPunlinkSol(SCIP *scip, SCIP_SOL *sol)
Definition scip_sol.c:1190
SCIP_Bool SCIPsolIsOriginal(SCIP_SOL *sol)
Definition sol.c:2555
SCIP_RETCODE SCIPcreateRelaxSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition scip_sol.c:433
SCIP_RETCODE SCIPprintMIPStart(SCIP *scip, SCIP_SOL *sol, FILE *file)
Definition scip_sol.c:1914
SCIP_RETCODE SCIPreadSol(SCIP *scip, const char *filename)
Definition scip_sol.c:2549
SCIP_RETCODE SCIPgetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
Definition scip_sol.c:1398
SCIP_RETCODE SCIPrecomputeSolObj(SCIP *scip, SCIP_SOL *sol)
Definition scip_sol.c:1522
SCIP_RETCODE SCIPaddSol(SCIP *scip, SCIP_SOL *sol, SCIP_Bool *stored)
Definition scip_sol.c:2935
SCIP_RETCODE SCIPincSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var, SCIP_Real incval)
Definition scip_sol.c:1318
SCIP_RETCODE SCIPcreateSolCopyOrig(SCIP *scip, SCIP_SOL **sol, SCIP_SOL *sourcesol)
Definition scip_sol.c:658
SCIP_RETCODE SCIPlinkNLPSol(SCIP *scip, SCIP_SOL *sol)
Definition scip_sol.c:1052
SCIP_RETCODE SCIProundSol(SCIP *scip, SCIP_SOL *sol, SCIP_Bool *success)
Definition scip_sol.c:2455
SCIP_RETCODE SCIPcreatePartialSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition scip_sol.c:505
SCIP_Longint SCIPgetSolNodenum(SCIP *scip, SCIP_SOL *sol)
Definition scip_sol.c:1657
SCIP_Bool SCIPsolIsPartial(SCIP_SOL *sol)
Definition sol.c:2565
SCIP_Real SCIPgetPrimalRayVal(SCIP *scip, SCIP_VAR *var)
Definition scip_sol.c:3504
SCIP_RETCODE SCIPsetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
Definition scip_sol.c:1263
void SCIPupdateSolConsViolation(SCIP *scip, SCIP_SOL *sol, SCIP_Real absviol, SCIP_Real relviol)
Definition scip_sol.c:273
SCIP_SOL ** SCIPgetSols(SCIP *scip)
Definition scip_sol.c:2263
SCIP_Bool SCIPhasPrimalRay(SCIP *scip)
Definition scip_sol.c:3486
SCIP_RETCODE SCIPlinkRelaxSol(SCIP *scip, SCIP_SOL *sol)
Definition scip_sol.c:1084
int SCIPsolGetRunnum(SCIP_SOL *sol)
Definition sol.c:2608
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:3098
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:3391
SCIP_Bool SCIPisDualSolAvailable(SCIP *scip, SCIP_Bool printreason)
Definition scip_sol.c:2082
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:3193
SCIP_RETCODE SCIPlinkLPSol(SCIP *scip, SCIP_SOL *sol)
Definition scip_sol.c:1026
SCIP_Real SCIPgetSolOrigObj(SCIP *scip, SCIP_SOL *sol)
Definition scip_sol.c:1444
SCIP_RETCODE SCIPretransformSol(SCIP *scip, SCIP_SOL *sol)
Definition scip_sol.c:2491
SCIP_Real SCIPgetSolTime(SCIP *scip, SCIP_SOL *sol)
Definition scip_sol.c:1603
void SCIPdeactivateSolViolationUpdates(SCIP *scip)
Definition scip_sol.c:305
SCIP_RETCODE SCIPsetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var, SCIP_Real val)
Definition scip_sol.c:1221
SCIP_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var)
Definition scip_sol.c:1361
void SCIPactivateSolViolationUpdates(SCIP *scip)
Definition scip_sol.c:297
SCIP_Real SCIPgetSolTransObj(SCIP *scip, SCIP_SOL *sol)
Definition scip_sol.c:1491
void SCIPupdateSolLPConsViolation(SCIP *scip, SCIP_SOL *sol, SCIP_Real absviol, SCIP_Real relviol)
Definition scip_sol.c:285
SCIP_RETCODE SCIPupdatePrimalRay(SCIP *scip, SCIP_SOL *primalray)
Definition scip_sol.c:3531
SCIP_Real SCIPretransformObj(SCIP *scip, SCIP_Real obj)
Definition scip_sol.c:1576
SCIP_RETCODE SCIPcreatePseudoSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition scip_sol.c:460
SCIP_RETCODE SCIPprintDualSol(SCIP *scip, FILE *file, SCIP_Bool printzeros)
Definition scip_sol.c:2145
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:3287
SCIP_RETCODE SCIPsolve(SCIP *scip)
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:13246
SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
Definition var.c:17360
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
Definition var.c:17966
SCIP_Real SCIPvarGetLbOriginal(SCIP_VAR *var)
Definition var.c:17846
SCIP_Bool SCIPvarIsTransformed(SCIP_VAR *var)
Definition var.c:17383
SCIP_VAR * SCIPvarGetProbvar(SCIP_VAR *var)
Definition var.c:12207
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
Definition var.c:17910
const char * SCIPvarGetName(SCIP_VAR *var)
Definition var.c:17241
SCIP_Real SCIPvarGetUbOriginal(SCIP_VAR *var)
Definition var.c:17866
SCIP_RETCODE SCIPreleaseVar(SCIP *scip, SCIP_VAR **var)
Definition scip_var.c:1248
SCIP_RETCODE SCIPchgVarType(SCIP *scip, SCIP_VAR *var, SCIP_VARTYPE vartype, SCIP_Bool *infeasible)
Definition scip_var.c:8176
SCIP_Real SCIPvarGetLPSol(SCIP_VAR *var)
Definition var.c:18274
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
Definition var.c:17956
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:114
SCIP_Real SCIPgetVarRedcost(SCIP *scip, SCIP_VAR *var)
Definition scip_var.c:1864
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
Definition var.c:17900
SCIP_RETCODE SCIPfixVar(SCIP *scip, SCIP_VAR *var, SCIP_Real fixedval, SCIP_Bool *infeasible, SCIP_Bool *fixed)
Definition scip_var.c:8276
SCIP_RETCODE SCIPgetVarSols(SCIP *scip, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
Definition scip_var.c:2327
SCIP_RETCODE SCIPchgVarObj(SCIP *scip, SCIP_VAR *var, SCIP_Real newobj)
Definition scip_var.c:4513
int SCIPsnprintf(char *t, int len, const char *s,...)
Definition misc.c:10788
void SCIPprintSysError(const char *message)
Definition misc.c:10680
return SCIP_OKAY
int c
static SCIP_SOL * sol
SCIP_Real obj
assert(minobj< SCIPgetCutoffbound(scip))
int nvars
SCIP_VAR * var
static SCIP_VAR ** vars
SCIP_Real SCIPlpGetObjval(SCIP_LP *lp, SCIP_SET *set, SCIP_PROB *prob)
Definition lp.c:13119
SCIP_Bool SCIPlpIsSolved(SCIP_LP *lp)
Definition lp.c:17807
SCIP_Real SCIPlpGetPseudoObjval(SCIP_LP *lp, SCIP_SET *set, SCIP_PROB *prob)
Definition lp.c:13302
internal methods for LP management
#define NULL
Definition lpi_spx1.cpp:161
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
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
Definition scip_mem.c:57
SCIP_Bool SCIPnlpHasSolution(SCIP_NLP *nlp)
Definition nlp.c:4430
SCIP_NLPSOLSTAT SCIPnlpGetSolstat(SCIP_NLP *nlp)
Definition nlp.c:4389
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:1470
void SCIPprimalSetUpdateViolations(SCIP_PRIMAL *primal, SCIP_Bool updateviolations)
Definition primal.c:1988
SCIP_RETCODE SCIPprimalUpdateRay(SCIP_PRIMAL *primal, SCIP_SET *set, SCIP_STAT *stat, SCIP_SOL *primalray, BMS_BLKMEM *blkmem)
Definition primal.c:601
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:1386
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:1644
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:1570
SCIP_Bool SCIPprimalUpdateViolations(SCIP_PRIMAL *primal)
Definition primal.c:1978
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:1331
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:1500
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:1276
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:1208
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:2116
SCIP_Real SCIPprobInternObjval(SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_SET *set, SCIP_Real objval)
Definition prob.c:2138
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:808
internal methods for relaxators
public methods for constraint handler plugins and constraints
public methods for problem copies
general public methods
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:2026
static SCIP_RETCODE readSolFile(SCIP *scip, const char *filename, SCIP_SOL *sol, SCIP_Bool *partial, SCIP_Bool *error)
Definition scip_sol.c:2564
static SCIP_RETCODE setupAndSolveFiniteSolSubscip(SCIP *scip, SCIP *subscip, SCIP_VAR **origvars, int norigvars, SCIP_Real *solvals, SCIP_Bool *success)
Definition scip_sol.c:698
static SCIP_RETCODE readXmlSolFile(SCIP *scip, const char *filename, SCIP_SOL *sol, SCIP_Bool *partial, SCIP_Bool *error)
Definition scip_sol.c:2722
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:6597
SCIP_Bool SCIPsetIsEQ(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition set.c:6155
SCIP_Bool SCIPsetIsFeasLT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition set.c:6553
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:652
void SCIPsolUpdateConsViolation(SCIP_SOL *sol, SCIP_Real absviolcons, SCIP_Real relviolcons)
Definition sol.c:2421
SCIP_RETCODE SCIPsolLinkPseudoSol(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_TREE *tree, SCIP_LP *lp)
Definition sol.c:959
SCIP_RETCODE SCIPsolCreatePartial(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PRIMAL *primal, SCIP_HEUR *heur)
Definition sol.c:730
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:766
void SCIPsolUpdateBoundViolation(SCIP_SOL *sol, SCIP_Real absviolbounds, SCIP_Real relviolbounds)
Definition sol.c:2395
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:631
SCIP_RETCODE SCIPsolLinkCurrentSol(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_TREE *tree, SCIP_LP *lp)
Definition sol.c:988
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:1672
SCIP_RETCODE SCIPsolMarkPartial(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_VAR **vars, int nvars)
Definition sol.c:1607
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:325
SCIP_RETCODE SCIPsolAdjustImplicitSolVals(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_TREE *tree, SCIP_Bool uselprows)
Definition sol.c:473
SCIP_RETCODE SCIPsolFree(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_PRIMAL *primal)
Definition sol.c:801
void SCIPsolRecomputeObj(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *origprob)
Definition sol.c:2020
void SCIPsolUpdateIntegralityViolation(SCIP_SOL *sol, SCIP_Real absviolintegrality)
Definition sol.c:2384
void SCIPsolUpdateLPRowViolation(SCIP_SOL *sol, SCIP_Real absviollprows, SCIP_Real relviollprows)
Definition sol.c:2408
SCIP_RETCODE SCIPsolIncVal(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_VAR *var, SCIP_Real incval)
Definition sol.c:1296
SCIP_RETCODE SCIPsolLinkNLPSol(SCIP_SOL *sol, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_NLP *nlp)
Definition sol.c:878
SCIP_RETCODE SCIPsolRetransform(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_Bool *hasinfval)
Definition sol.c:1893
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:703
SCIP_RETCODE SCIPsolRound(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_TREE *tree, SCIP_Bool *success)
Definition sol.c:1793
SCIP_RETCODE SCIPsolSetVal(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_VAR *var, SCIP_Real val)
Definition sol.c:1077
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:678
SCIP_RETCODE SCIPsolClear(SCIP_SOL *sol, SCIP_STAT *stat, SCIP_TREE *tree)
Definition sol.c:1014
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:608
SCIP_RETCODE SCIPsolLinkRelaxSol(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_RELAXATION *relaxation)
Definition sol.c:929
SCIP_Real SCIPsolGetVal(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_VAR *var)
Definition sol.c:1372
SCIP_RETCODE SCIPsolUnlink(SCIP_SOL *sol, SCIP_SET *set, SCIP_PROB *prob)
Definition sol.c:1048
SCIP_Real SCIPsolGetRayVal(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_VAR *var)
Definition sol.c:1502
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:2256
void SCIPsolResetViolations(SCIP_SOL *sol)
Definition sol.c:2368
SCIP_RETCODE SCIPsolLinkLPSol(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_TREE *tree, SCIP_LP *lp)
Definition sol.c:820
SCIP_Bool SCIPsolsAreEqual(SCIP_SOL *sol1, SCIP_SOL *sol2, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob)
Definition sol.c:2055
SCIP_Real SCIPsolGetObj(SCIP_SOL *sol, SCIP_SET *set, SCIP_PROB *transprob, SCIP_PROB *origprob)
Definition sol.c:1571
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:2120
SCIP_RETCODE SCIPsolCopy(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PRIMAL *primal, SCIP_SOL *sourcesol)
Definition sol.c:362
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:288
void SCIPsolUpdateLPConsViolation(SCIP_SOL *sol, SCIP_Real absviol, SCIP_Real relviol)
Definition sol.c:2434
internal methods for storing primal CIP solutions
SCIP * scip
Definition struct_var.h:288
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 problem statistics
datastructures for problem variables
SCIP_Bool SCIPtreeHasCurrentNodeLP(SCIP_TREE *tree)
Definition tree.c:8421
internal methods for branch and bound tree
@ SCIP_VERBLEVEL_NONE
@ SCIP_VERBLEVEL_NORMAL
@ 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
@ SCIP_READERROR
@ SCIP_INVALIDDATA
@ SCIP_INVALIDCALL
@ SCIP_ERROR
enum SCIP_Retcode SCIP_RETCODE
@ 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:52
@ SCIP_VARSTATUS_MULTAGGR
Definition type_var.h:54
declarations for XML parsing
const XML_NODE * xmlFirstChild(const XML_NODE *node)
Definition xmlparse.c:1469
const XML_NODE * xmlFindNodeMaxdepth(const XML_NODE *node, const char *name, int depth, int maxdepth)
Definition xmlparse.c:1419
const char * xmlGetAttrval(const XML_NODE *node, const char *name)
Definition xmlparse.c:1337
struct XML_NODE_struct XML_NODE
Definition xml.h:50
const XML_NODE * xmlNextSibl(const XML_NODE *node)
Definition xmlparse.c:1449
XML_NODE * xmlProcess(const char *filename)
Definition xmlparse.c:1085
void xmlFreeNode(XML_NODE *node)
Definition xmlparse.c:1275