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