Scippy

SCIP

Solving Constraint Integer Programs

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