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