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-2019 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SCIP; see the file COPYING. If not visit scip.zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file scip_sol.c
17  * @brief public methods for solutions
18  * @author Tobias Achterberg
19  * @author Timo Berthold
20  * @author Gerald Gamrath
21  * @author Robert Lion Gottwald
22  * @author Stefan Heinz
23  * @author Gregor Hendel
24  * @author Thorsten Koch
25  * @author Alexander Martin
26  * @author Marc Pfetsch
27  * @author Michael Winkler
28  * @author Kati Wolter
29  *
30  * @todo check all SCIP_STAGE_* switches, and include the new stages TRANSFORMED and INITSOLVE
31  */
32 
33 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
34 
35 #include <string.h>
36 #if defined(_WIN32) || defined(_WIN64)
37 #else
38 #include <strings.h> /*lint --e{766}*/
39 #endif
40 
41 #include "blockmemshell/memory.h"
42 #include "nlpi/type_nlpi.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);
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, 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  SCIP_VAR* var;
2595  SCIP_Real value;
2596  int nread;
2597 
2598  /* get next line */
2599  if( SCIPfgets(buffer, (int) sizeof(buffer), file) == NULL )
2600  break;
2601  lineno++;
2602 
2603  /* there are some lines which may preceed the solution information */
2604  if( strncasecmp(buffer, "solution status:", 16) == 0 || strncasecmp(buffer, "objective value:", 16) == 0 ||
2605  strncasecmp(buffer, "Log started", 11) == 0 || strncasecmp(buffer, "Variable Name", 13) == 0 ||
2606  strncasecmp(buffer, "All other variables", 19) == 0 || strncasecmp(buffer, "\n", 1) == 0 ||
2607  strncasecmp(buffer, "NAME", 4) == 0 || strncasecmp(buffer, "ENDATA", 6) == 0 ) /* allow parsing of SOL-format on the MIPLIB 2003 pages */
2608  continue;
2609 
2610  /* parse the line */
2611  /* cppcheck-suppress invalidscanf */
2612  nread = sscanf(buffer, "%s %s %s\n", varname, valuestring, objstring);
2613  if( nread < 2 )
2614  {
2615  SCIPerrorMessage("Invalid input line %d in solution file <%s>: <%s>.\n", lineno, filename, buffer);
2616  *error = TRUE;
2617  break;
2618  }
2619 
2620  /* find the variable */
2621  var = SCIPfindVar(scip, varname);
2622  if( var == NULL )
2623  {
2624  if( !unknownvariablemessage )
2625  {
2626  SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "unknown variable <%s> in line %d of solution file <%s>\n",
2627  varname, lineno, filename);
2628  SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, " (further unknown variables are ignored)\n");
2629  unknownvariablemessage = TRUE;
2630  }
2631  continue;
2632  }
2633 
2634  /* cast the value */
2635  if( strncasecmp(valuestring, "inv", 3) == 0 )
2636  continue;
2637  else if( strncasecmp(valuestring, "+inf", 4) == 0 || strncasecmp(valuestring, "inf", 3) == 0 )
2638  value = SCIPinfinity(scip);
2639  else if( strncasecmp(valuestring, "-inf", 4) == 0 )
2640  value = -SCIPinfinity(scip);
2641  else if( strncasecmp(valuestring, "unknown", 7) == 0 )
2642  {
2643  value = SCIP_UNKNOWN;
2644  localpartial = TRUE;
2645  }
2646  else
2647  {
2648  /* coverity[secure_coding] */
2649  nread = sscanf(valuestring, "%lf", &value);
2650  if( nread != 1 )
2651  {
2652  SCIPerrorMessage("Invalid solution value <%s> for variable <%s> in line %d of solution file <%s>.\n",
2653  valuestring, varname, lineno, filename);
2654  *error = TRUE;
2655  break;
2656  }
2657  }
2658 
2659  /* set the solution value of the variable, if not multiaggregated */
2661  {
2662  SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "ignored solution value for multiaggregated variable <%s>\n", SCIPvarGetName(var));
2663  }
2664  else
2665  {
2666  SCIP_RETCODE retcode;
2667 
2668  retcode = SCIPsetSolVal(scip, sol, var, value);
2669 
2670  if( retcode == SCIP_INVALIDDATA )
2671  {
2673  {
2674  SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "ignored conflicting solution value for fixed variable <%s>\n",
2675  SCIPvarGetName(var));
2676  }
2677  else
2678  {
2679  SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "ignored solution value for multiaggregated variable <%s>\n",
2680  SCIPvarGetName(var));
2681  }
2682  }
2683  else
2684  {
2685  SCIP_CALL_FINALLY( retcode, SCIPfclose(file) );
2686  }
2687  }
2688  }
2689 
2690  /* close input file */
2691  SCIPfclose(file);
2692 
2693  if( localpartial && !SCIPsolIsPartial(sol) )
2694  {
2695  if( SCIPgetStage(scip) == SCIP_STAGE_PROBLEM )
2696  {
2697  SCIP_CALL( SCIPsolMarkPartial(sol, scip->set, scip->stat, scip->origprob->vars, scip->origprob->nvars) );
2698  }
2699  else
2700  *error = TRUE;
2701  }
2702 
2703  if( partial != NULL )
2704  *partial = localpartial;
2705 
2706  return SCIP_OKAY;
2707 }
2708 
2709 /** reads a given xml solution file and store the solution values in the given solution pointer */
2710 static
2712  SCIP* scip, /**< SCIP data structure */
2713  const char* filename, /**< name of the input file */
2714  SCIP_SOL* sol, /**< solution pointer */
2715  SCIP_Bool* partial, /**< pointer to store if the solution is partial (or NULL if not needed) */
2716  SCIP_Bool* error /**< pointer store if an error occured */
2717  )
2718 {
2719  SCIP_Bool unknownvariablemessage;
2720  SCIP_Bool localpartial;
2721  XML_NODE* start;
2722  const XML_NODE* varsnode;
2723  const XML_NODE* varnode;
2724  const char* tag;
2725 
2726  assert(scip != NULL);
2727  assert(sol != NULL);
2728  assert(error != NULL);
2729 
2730  /* read xml file */
2731  start = xmlProcess(filename);
2732 
2733  if( start == NULL )
2734  {
2735  SCIPerrorMessage("Some error occured during parsing the XML solution file.\n");
2736  return SCIP_READERROR;
2737  }
2738 
2739  *error = FALSE;
2740  localpartial = SCIPsolIsPartial(sol);
2741 
2742  /* find variable sections */
2743  tag = "variables";
2744  varsnode = xmlFindNodeMaxdepth(start, tag, 0, 3);
2745  if( varsnode == NULL )
2746  {
2747  /* free xml data */
2748  xmlFreeNode(start);
2749 
2750  SCIPerrorMessage("Variable section not found.\n");
2751  return SCIP_READERROR;
2752  }
2753 
2754  /* loop through all variables */
2755  unknownvariablemessage = FALSE;
2756  for( varnode = xmlFirstChild(varsnode); varnode != NULL; varnode = xmlNextSibl(varnode) )
2757  {
2758  SCIP_VAR* var;
2759  const char* varname;
2760  const char* valuestring;
2761  SCIP_Real value;
2762  int nread;
2763 
2764  /* find variable name */
2765  varname = xmlGetAttrval(varnode, "name");
2766  if( varname == NULL )
2767  {
2768  SCIPerrorMessage("Attribute \"name\" of variable not found.\n");
2769  *error = TRUE;
2770  break;
2771  }
2772 
2773  /* find the variable */
2774  var = SCIPfindVar(scip, varname);
2775  if( var == NULL )
2776  {
2777  if( !unknownvariablemessage )
2778  {
2779  SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "unknown variable <%s> of solution file <%s>\n",
2780  varname, filename);
2781  SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, " (further unknown variables are ignored)\n");
2782  unknownvariablemessage = TRUE;
2783  }
2784  continue;
2785  }
2786 
2787  /* find value of variable */
2788  valuestring = xmlGetAttrval(varnode, "value");
2789  if( valuestring == NULL )
2790  {
2791  SCIPerrorMessage("Attribute \"value\" of variable not found.\n");
2792  *error = TRUE;
2793  break;
2794  }
2795 
2796  /* cast the value */
2797  if( strncasecmp(valuestring, "inv", 3) == 0 )
2798  continue;
2799  else if( strncasecmp(valuestring, "+inf", 4) == 0 || strncasecmp(valuestring, "inf", 3) == 0 )
2800  value = SCIPinfinity(scip);
2801  else if( strncasecmp(valuestring, "-inf", 4) == 0 )
2802  value = -SCIPinfinity(scip);
2803  else if( strncasecmp(valuestring, "unknown", 7) == 0 )
2804  {
2805  value = SCIP_UNKNOWN;
2806  localpartial = TRUE;
2807  }
2808  else
2809  {
2810  /* coverity[secure_coding] */
2811  nread = sscanf(valuestring, "%lf", &value);
2812  if( nread != 1 )
2813  {
2814  SCIPwarningMessage(scip, "invalid solution value <%s> for variable <%s> in XML solution file <%s>\n", valuestring, varname, filename);
2815  *error = TRUE;
2816  break;
2817  }
2818  }
2819 
2820  /* set the solution value of the variable, if not multiaggregated */
2822  {
2823  SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "ignored solution value for multiaggregated variable <%s>\n", SCIPvarGetName(var));
2824  }
2825  else
2826  {
2827  SCIP_RETCODE retcode;
2828  retcode = SCIPsetSolVal(scip, sol, var, value);
2829 
2830  if( retcode == SCIP_INVALIDDATA )
2831  {
2833  {
2834  SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "ignored conflicting solution value for fixed variable <%s>\n",
2835  SCIPvarGetName(var));
2836  }
2837  else
2838  {
2839  SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "ignored solution value for multiaggregated variable <%s>\n",
2840  SCIPvarGetName(var));
2841  }
2842  }
2843  else
2844  {
2845  SCIP_CALL( retcode );
2846  }
2847  }
2848  }
2849 
2850  /* free xml data */
2851  xmlFreeNode(start);
2852 
2853  if( localpartial && !SCIPsolIsPartial(sol) )
2854  {
2855  if( SCIPgetStage(scip) == SCIP_STAGE_PROBLEM )
2856  {
2857  SCIP_CALL( SCIPsolMarkPartial(sol, scip->set, scip->stat, scip->origprob->vars, scip->origprob->nvars) );
2858  }
2859  else
2860  *error = TRUE;
2861  }
2862 
2863  if( partial != NULL )
2864  *partial = localpartial;
2865 
2866  return SCIP_OKAY;
2867 }
2868 
2869 /** reads a given solution file and store the solution values in the given solution pointer
2870  *
2871  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2872  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2873  *
2874  * @pre This method can be called if SCIP is in one of the following stages:
2875  * - \ref SCIP_STAGE_PROBLEM
2876  * - \ref SCIP_STAGE_TRANSFORMED
2877  * - \ref SCIP_STAGE_INITPRESOLVE
2878  * - \ref SCIP_STAGE_PRESOLVING
2879  * - \ref SCIP_STAGE_EXITPRESOLVE
2880  * - \ref SCIP_STAGE_PRESOLVED
2881  * - \ref SCIP_STAGE_INITSOLVE
2882  * - \ref SCIP_STAGE_SOLVING
2883  */
2885  SCIP* scip, /**< SCIP data structure */
2886  const char* filename, /**< name of the input file */
2887  SCIP_SOL* sol, /**< solution pointer */
2888  SCIP_Bool xml, /**< true, iff the given solution in written in XML */
2889  SCIP_Bool* partial, /**< pointer to store if the solution is partial */
2890  SCIP_Bool* error /**< pointer store if an error occured */
2891  )
2892 {
2893  SCIP_CALL( SCIPcheckStage(scip, "SCIPreadSolFile", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE) );
2894 
2895  if( xml )
2896  {
2897  SCIP_CALL( readXmlSolFile(scip, filename, sol, partial, error) );
2898  }
2899  else
2900  {
2901  SCIP_CALL( readSolFile(scip, filename, sol, partial, error) );
2902  }
2903 
2904  return SCIP_OKAY;
2905 }
2906 
2907 /** adds feasible primal solution to solution storage by copying it
2908  *
2909  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
2910  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
2911  *
2912  * @pre This method can be called if SCIP is in one of the following stages:
2913  * - \ref SCIP_STAGE_PROBLEM
2914  * - \ref SCIP_STAGE_TRANSFORMED
2915  * - \ref SCIP_STAGE_INITPRESOLVE
2916  * - \ref SCIP_STAGE_PRESOLVING
2917  * - \ref SCIP_STAGE_EXITPRESOLVE
2918  * - \ref SCIP_STAGE_PRESOLVED
2919  * - \ref SCIP_STAGE_SOLVING
2920  * - \ref SCIP_STAGE_FREETRANS
2921  *
2922  * @note Do not call during propagation, use heur_trysol instead.
2923  */
2925  SCIP* scip, /**< SCIP data structure */
2926  SCIP_SOL* sol, /**< primal CIP solution */
2927  SCIP_Bool* stored /**< stores whether given solution was good enough to keep */
2928  )
2929 {
2930  SCIP_CALL( SCIPcheckStage(scip, "SCIPaddSol", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE) );
2931 
2932  switch( scip->set->stage )
2933  {
2934  case SCIP_STAGE_PROBLEM:
2935  case SCIP_STAGE_FREETRANS:
2936  assert(SCIPsolIsOriginal(sol));
2937  SCIP_CALL( SCIPprimalAddOrigSol(scip->origprimal, scip->mem->probmem, scip->set, scip->stat, scip->origprob, sol, stored) );
2938  return SCIP_OKAY;
2939 
2942  case SCIP_STAGE_PRESOLVING:
2944  /* if the solution is added during presolving and it is not defined on original variables,
2945  * presolving operations will destroy its validity, so we retransform it to the original space
2946  */
2947  if( !SCIPsolIsOriginal(sol) )
2948  {
2949  SCIP_SOL* bestsol = SCIPgetBestSol(scip);
2950  SCIP_SOL* tmpsol = sol;
2951  SCIP_Bool hasinfval;
2952 
2953  SCIP_CALL( SCIPcreateSolCopy(scip, &tmpsol, sol) );
2954 
2955  SCIP_CALL( SCIPsolUnlink(tmpsol, scip->set, scip->transprob) );
2956  SCIP_CALL( SCIPsolRetransform(tmpsol, scip->set, scip->stat, scip->origprob, scip->transprob, &hasinfval) );
2957 
2958  SCIP_CALL( SCIPprimalAddSolFree(scip->primal, scip->mem->probmem, scip->set, scip->messagehdlr, scip->stat,
2959  scip->origprob, scip->transprob, scip->tree, scip->reopt, scip->lp, scip->eventqueue, scip->eventfilter,
2960  &tmpsol, stored) );
2961 
2962  if( *stored && (bestsol != SCIPgetBestSol(scip)) )
2963  {
2964  SCIPstoreSolutionGap(scip);
2965  }
2966 
2967  return SCIP_OKAY;
2968  }
2969  /*lint -fallthrough*/
2970  case SCIP_STAGE_PRESOLVED:
2971  case SCIP_STAGE_SOLVING:
2972  {
2973  SCIP_SOL* bestsol = SCIPgetBestSol(scip);
2974 
2975  SCIP_CALL( SCIPprimalAddSol(scip->primal, scip->mem->probmem, scip->set, scip->messagehdlr, scip->stat,
2976  scip->origprob, scip->transprob, scip->tree, scip->reopt, scip->lp, scip->eventqueue, scip->eventfilter, sol,
2977  stored) );
2978 
2979  /* @todo use solution index rather than pointer */
2980  if( *stored && (bestsol != SCIPgetBestSol(scip)) )
2981  {
2982  SCIPstoreSolutionGap(scip);
2983  }
2984 
2985  return SCIP_OKAY;
2986  }
2988  case SCIP_STAGE_INITSOLVE:
2989  case SCIP_STAGE_SOLVED:
2990  case SCIP_STAGE_EXITSOLVE:
2991  default:
2992  SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
2993  return SCIP_INVALIDCALL;
2994  } /*lint !e788*/
2995 }
2996 
2997 /** adds primal solution to solution storage, frees the solution afterwards
2998  *
2999  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
3000  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
3001  *
3002  * @pre This method can be called if SCIP is in one of the following stages:
3003  * - \ref SCIP_STAGE_PROBLEM
3004  * - \ref SCIP_STAGE_TRANSFORMED
3005  * - \ref SCIP_STAGE_INITPRESOLVE
3006  * - \ref SCIP_STAGE_PRESOLVING
3007  * - \ref SCIP_STAGE_EXITPRESOLVE
3008  * - \ref SCIP_STAGE_PRESOLVED
3009  * - \ref SCIP_STAGE_SOLVING
3010  * - \ref SCIP_STAGE_FREETRANS
3011  *
3012  * @note Do not call during propagation, use heur_trysol instead.
3013  */
3015  SCIP* scip, /**< SCIP data structure */
3016  SCIP_SOL** sol, /**< pointer to primal CIP solution; is cleared in function call */
3017  SCIP_Bool* stored /**< stores whether given solution was good enough to keep */
3018  )
3019 {
3020  SCIP_CALL( SCIPcheckStage(scip, "SCIPaddSolFree", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, FALSE) );
3021 
3022  switch( scip->set->stage )
3023  {
3024  case SCIP_STAGE_PROBLEM:
3025  case SCIP_STAGE_FREETRANS:
3026  assert(SCIPsolIsOriginal(*sol));
3027  SCIP_CALL( SCIPprimalAddOrigSolFree(scip->origprimal, scip->mem->probmem, scip->set, scip->stat, scip->origprob, sol, stored) );
3028  return SCIP_OKAY;
3029 
3032  case SCIP_STAGE_PRESOLVING:
3034  /* if the solution is added during presolving and it is not defined on original variables,
3035  * presolving operations will destroy its validity, so we retransform it to the original space
3036  */
3037  if( !SCIPsolIsOriginal(*sol) )
3038  {
3039  SCIP_Bool hasinfval;
3040 
3041  SCIP_CALL( SCIPsolUnlink(*sol, scip->set, scip->transprob) );
3042  SCIP_CALL( SCIPsolRetransform(*sol, scip->set, scip->stat, scip->origprob, scip->transprob, &hasinfval) );
3043  }
3044  /*lint -fallthrough*/
3045  case SCIP_STAGE_PRESOLVED:
3046  case SCIP_STAGE_SOLVING:
3047  {
3048  SCIP_SOL* bestsol = SCIPgetBestSol(scip);
3049 
3050  SCIP_CALL( SCIPprimalAddSolFree(scip->primal, scip->mem->probmem, scip->set, scip->messagehdlr, scip->stat,
3051  scip->origprob, scip->transprob, scip->tree, scip->reopt, scip->lp, scip->eventqueue, scip->eventfilter,
3052  sol, stored) );
3053 
3054  if( *stored )
3055  {
3056  if( bestsol != SCIPgetBestSol(scip) )
3057  {
3058  assert(SCIPgetBestSol(scip) != NULL);
3059  SCIPstoreSolutionGap(scip);
3060  }
3061  }
3062 
3063  return SCIP_OKAY;
3064  }
3066  case SCIP_STAGE_INITSOLVE:
3067  case SCIP_STAGE_SOLVED:
3068  case SCIP_STAGE_EXITSOLVE:
3069  default:
3070  SCIPerrorMessage("invalid SCIP stage <%d>\n", scip->set->stage);
3071  return SCIP_INVALIDCALL;
3072  } /*lint !e788*/
3073 }
3074 
3075 /** adds current LP/pseudo solution to solution storage
3076  *
3077  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
3078  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
3079  *
3080  * @pre This method can be called if SCIP is in one of the following stages:
3081  * - \ref SCIP_STAGE_PRESOLVED
3082  * - \ref SCIP_STAGE_SOLVING
3083  */
3085  SCIP* scip, /**< SCIP data structure */
3086  SCIP_HEUR* heur, /**< heuristic that found the solution */
3087  SCIP_Bool* stored /**< stores whether given solution was good enough to keep */
3088  )
3089 {
3090  SCIP_SOL* bestsol;
3091 
3092  SCIP_CALL( SCIPcheckStage(scip, "SCIPaddCurrentSol", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
3093 
3094  bestsol = SCIPgetBestSol(scip);
3095 
3096  SCIP_CALL( SCIPprimalAddCurrentSol(scip->primal, scip->mem->probmem, scip->set, scip->messagehdlr, scip->stat,
3097  scip->origprob, scip->transprob, scip->tree, scip->reopt, scip->lp, scip->eventqueue, scip->eventfilter, heur,
3098  stored) );
3099 
3100  if( *stored )
3101  {
3102  if( bestsol != SCIPgetBestSol(scip) )
3103  SCIPstoreSolutionGap(scip);
3104  }
3105 
3106  return SCIP_OKAY;
3107 }
3108 
3109 /** checks solution for feasibility; if possible, adds it to storage by copying
3110  *
3111  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
3112  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
3113  *
3114  * @pre This method can be called if SCIP is in one of the following stages:
3115  * - \ref SCIP_STAGE_TRANSFORMED
3116  * - \ref SCIP_STAGE_INITPRESOLVE
3117  * - \ref SCIP_STAGE_PRESOLVING
3118  * - \ref SCIP_STAGE_EXITPRESOLVE
3119  * - \ref SCIP_STAGE_PRESOLVED
3120  * - \ref SCIP_STAGE_SOLVING
3121  *
3122  * @note Do not call during propagation, use heur_trysol instead.
3123  */
3125  SCIP* scip, /**< SCIP data structure */
3126  SCIP_SOL* sol, /**< primal CIP solution */
3127  SCIP_Bool printreason, /**< Should all reasons of violation be printed? */
3128  SCIP_Bool completely, /**< Should all violations be checked if printreason is true? */
3129  SCIP_Bool checkbounds, /**< Should the bounds of the variables be checked? */
3130  SCIP_Bool checkintegrality, /**< Has integrality to be checked? */
3131  SCIP_Bool checklprows, /**< Do constraints represented by rows in the current LP have to be checked? */
3132  SCIP_Bool* stored /**< stores whether given solution was feasible and good enough to keep */
3133  )
3134 {
3135  SCIP_SOL* bestsol;
3136 
3137  assert(sol != NULL);
3138  assert(stored != NULL);
3139 
3140  SCIP_CALL( SCIPcheckStage(scip, "SCIPtrySol", FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
3141 
3142  bestsol = SCIPgetBestSol(scip);
3143 
3144  if( !printreason )
3145  completely = FALSE;
3146 
3147  /* we cannot check partial solutions */
3148  if( SCIPsolIsPartial(sol) )
3149  {
3150  SCIPerrorMessage("Cannot check feasibility of partial solutions.\n");
3151  return SCIP_INVALIDDATA;
3152  }
3153 
3154  /* if the solution is added during presolving and it is not defined on original variables,
3155  * presolving operations will destroy its validity, so we retransform it to the original space
3156  */
3157  if( scip->set->stage == SCIP_STAGE_PRESOLVING && !SCIPsolIsOriginal(sol) )
3158  {
3159  SCIP_Bool hasinfval;
3160 
3161  SCIP_CALL( SCIPsolUnlink(sol, scip->set, scip->transprob) );
3162  SCIP_CALL( SCIPsolRetransform(sol, scip->set, scip->stat, scip->origprob, scip->transprob, &hasinfval) );
3163  }
3164 
3165  if( SCIPsolIsOriginal(sol) )
3166  {
3167  SCIP_Bool feasible;
3168 
3169  /* SCIPprimalTrySol() can only be called on transformed solutions; therefore check solutions in original problem
3170  * including modifiable constraints */
3171  SCIP_CALL( checkSolOrig(scip, sol, &feasible, printreason, completely, checkbounds, checkintegrality, checklprows, TRUE) );
3172  if( feasible )
3173  {
3174  SCIP_CALL( SCIPprimalAddSol(scip->primal, scip->mem->probmem, scip->set, scip->messagehdlr, scip->stat,
3175  scip->origprob, scip->transprob, scip->tree, scip->reopt, scip->lp, scip->eventqueue, scip->eventfilter,
3176  sol, stored) );
3177 
3178  if( *stored )
3179  {
3180  if( bestsol != SCIPgetBestSol(scip) )
3181  SCIPstoreSolutionGap(scip);
3182  }
3183  }
3184  else
3185  *stored = FALSE;
3186  }
3187  else
3188  {
3189  SCIP_CALL( SCIPprimalTrySol(scip->primal, scip->mem->probmem, scip->set, scip->messagehdlr, scip->stat, scip->origprob,
3190  scip->transprob, scip->tree, scip->reopt, scip->lp, scip->eventqueue, scip->eventfilter, sol, printreason,
3191  completely, checkbounds, checkintegrality, checklprows, stored) );
3192 
3193  if( *stored )
3194  {
3195  if( bestsol != SCIPgetBestSol(scip) )
3196  SCIPstoreSolutionGap(scip);
3197  }
3198  }
3199 
3200  return SCIP_OKAY;
3201 }
3202 
3203 /** checks primal solution; if feasible, adds it to storage; solution is freed afterwards
3204  *
3205  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
3206  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
3207  *
3208  * @pre This method can be called if SCIP is in one of the following stages:
3209  * - \ref SCIP_STAGE_TRANSFORMED
3210  * - \ref SCIP_STAGE_INITPRESOLVE
3211  * - \ref SCIP_STAGE_PRESOLVING
3212  * - \ref SCIP_STAGE_EXITPRESOLVE
3213  * - \ref SCIP_STAGE_PRESOLVED
3214  * - \ref SCIP_STAGE_SOLVING
3215  *
3216  * @note Do not call during propagation, use heur_trysol instead.
3217  */
3219  SCIP* scip, /**< SCIP data structure */
3220  SCIP_SOL** sol, /**< pointer to primal CIP solution; is cleared in function call */
3221  SCIP_Bool printreason, /**< Should all reasons of violations be printed */
3222  SCIP_Bool completely, /**< Should all violations be checked if printreason is true? */
3223  SCIP_Bool checkbounds, /**< Should the bounds of the variables be checked? */
3224  SCIP_Bool checkintegrality, /**< Has integrality to be checked? */
3225  SCIP_Bool checklprows, /**< Do constraints represented by rows in the current LP have to be checked? */
3226  SCIP_Bool* stored /**< stores whether solution was feasible and good enough to keep */
3227  )
3228 {
3229  SCIP_SOL* bestsol;
3230 
3231  assert(stored != NULL);
3232  assert(sol != NULL);
3233 
3234  SCIP_CALL( SCIPcheckStage(scip, "SCIPtrySolFree", FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
3235 
3236  bestsol = SCIPgetBestSol(scip);
3237 
3238  if( !printreason )
3239  completely = FALSE;
3240 
3241  /* we cannot check partial solutions */
3242  if( SCIPsolIsPartial(*sol) )
3243  {
3244  SCIPerrorMessage("Cannot check feasibility of partial solutions.\n");
3245  return SCIP_INVALIDDATA;
3246  }
3247 
3248  /* if the solution is added during presolving and it is not defined on original variables,
3249  * presolving operations will destroy its validity, so we retransform it to the original space
3250  */
3251  if( scip->set->stage == SCIP_STAGE_PRESOLVING && !SCIPsolIsOriginal(*sol) )
3252  {
3253  SCIP_Bool hasinfval;
3254 
3255  SCIP_CALL( SCIPsolUnlink(*sol, scip->set, scip->transprob) );
3256  SCIP_CALL( SCIPsolRetransform(*sol, scip->set, scip->stat, scip->origprob, scip->transprob, &hasinfval) );
3257  }
3258 
3259  if( SCIPsolIsOriginal(*sol) )
3260  {
3261  SCIP_Bool feasible;
3262 
3263  /* SCIPprimalTrySol() can only be called on transformed solutions; therefore check solutions in original problem
3264  * including modifiable constraints
3265  */
3266  SCIP_CALL( checkSolOrig(scip, *sol, &feasible, printreason, completely, checkbounds, checkintegrality, checklprows, TRUE) );
3267 
3268  if( feasible )
3269  {
3270  SCIP_CALL( SCIPprimalAddSolFree(scip->primal, scip->mem->probmem, scip->set, scip->messagehdlr, scip->stat,
3271  scip->origprob, scip->transprob, scip->tree, scip->reopt, scip->lp, scip->eventqueue, scip->eventfilter,
3272  sol, stored) );
3273 
3274  if( *stored )
3275  {
3276  if( bestsol != SCIPgetBestSol(scip) )
3277  SCIPstoreSolutionGap(scip);
3278  }
3279  }
3280  else
3281  {
3282  SCIP_CALL( SCIPsolFree(sol, scip->mem->probmem, scip->primal) );
3283  *stored = FALSE;
3284  }
3285  }
3286  else
3287  {
3288  SCIP_CALL( SCIPprimalTrySolFree(scip->primal, scip->mem->probmem, scip->set, scip->messagehdlr, scip->stat,
3289  scip->origprob, scip->transprob, scip->tree, scip->reopt, scip->lp, scip->eventqueue, scip->eventfilter,
3290  sol, printreason, completely, checkbounds, checkintegrality, checklprows, stored) );
3291 
3292  if( *stored )
3293  {
3294  if( bestsol != SCIPgetBestSol(scip) )
3295  SCIPstoreSolutionGap(scip);
3296  }
3297  }
3298 
3299  return SCIP_OKAY;
3300 }
3301 
3302 /** checks current LP/pseudo solution for feasibility; if possible, adds it to storage
3303  *
3304  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
3305  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
3306  *
3307  * @pre This method can be called if SCIP is in one of the following stages:
3308  * - \ref SCIP_STAGE_PRESOLVED
3309  * - \ref SCIP_STAGE_SOLVING
3310  */
3312  SCIP* scip, /**< SCIP data structure */
3313  SCIP_HEUR* heur, /**< heuristic that found the solution */
3314  SCIP_Bool printreason, /**< Should all reasons of violations be printed? */
3315  SCIP_Bool completely, /**< Should all violations be checked if printreason is true? */
3316  SCIP_Bool checkintegrality, /**< Has integrality to be checked? */
3317  SCIP_Bool checklprows, /**< Do constraints represented by rows in the current LP have to be checked? */
3318  SCIP_Bool* stored /**< stores whether given solution was feasible and good enough to keep */
3319  )
3320 {
3321  SCIP_SOL* bestsol;
3322 
3323  SCIP_CALL( SCIPcheckStage(scip, "SCIPtryCurrentSol", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE) );
3324 
3325  bestsol = SCIPgetBestSol(scip);
3326 
3327  if( !printreason )
3328  completely = FALSE;
3329 
3330  SCIP_CALL( SCIPprimalTryCurrentSol(scip->primal, scip->mem->probmem, scip->set, scip->messagehdlr, scip->stat,
3331  scip->origprob, scip->transprob, scip->tree, scip->reopt, scip->lp, scip->eventqueue, scip->eventfilter, heur,
3332  printreason, completely, checkintegrality, checklprows, stored) );
3333 
3334  if( *stored )
3335  {
3336  if( bestsol != SCIPgetBestSol(scip) )
3337  SCIPstoreSolutionGap(scip);
3338  }
3339 
3340  return SCIP_OKAY;
3341 }
3342 
3343 /** returns all partial solutions
3344  *
3345  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
3346  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
3347  *
3348  * @pre This method can be called if SCIP is in one of the following stages:
3349  * - \ref SCIP_STAGE_PROBLEM
3350  * - \ref SCIP_STAGE_PRESOLVING
3351  * - \ref SCIP_STAGE_SOLVING
3352  * - \ref SCIP_STAGE_SOLVED
3353  */
3355  SCIP* scip /**< SCIP data structure */
3356  )
3357 {
3358  assert(scip != NULL);
3359 
3360  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetPartialSols", FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE) );
3361 
3362  return scip->origprimal->partialsols;
3363 }
3364 
3365 /** returns number of partial solutions
3366  *
3367  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
3368  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
3369  *
3370  * @pre This method can be called if SCIP is in one of the following stages:
3371  * - \ref SCIP_STAGE_PROBLEM
3372  * - \ref SCIP_STAGE_PRESOLVING
3373  * - \ref SCIP_STAGE_SOLVING
3374  * - \ref SCIP_STAGE_SOLVED
3375  */
3377  SCIP* scip /**< SCIP data structure */
3378  )
3379 {
3380  assert(scip != NULL);
3381 
3382  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetNPartialSols", FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE) );
3383 
3384  return scip->origprimal->npartialsols;
3385 }
3386 
3387 /** checks solution for feasibility without adding it to the solution store
3388  *
3389  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
3390  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
3391  *
3392  * @pre This method can be called if SCIP is in one of the following stages:
3393  * - \ref SCIP_STAGE_PROBLEM
3394  * - \ref SCIP_STAGE_TRANSFORMED
3395  * - \ref SCIP_STAGE_INITPRESOLVE
3396  * - \ref SCIP_STAGE_PRESOLVING
3397  * - \ref SCIP_STAGE_EXITPRESOLVE
3398  * - \ref SCIP_STAGE_PRESOLVED
3399  * - \ref SCIP_STAGE_INITSOLVE
3400  * - \ref SCIP_STAGE_SOLVING
3401  * - \ref SCIP_STAGE_SOLVED
3402  */
3404  SCIP* scip, /**< SCIP data structure */
3405  SCIP_SOL* sol, /**< primal CIP solution */
3406  SCIP_Bool printreason, /**< Should all reasons of violations be printed? */
3407  SCIP_Bool completely, /**< Should all violations be checked if printreason is true? */
3408  SCIP_Bool checkbounds, /**< Should the bounds of the variables be checked? */
3409  SCIP_Bool checkintegrality, /**< Has integrality to be checked? */
3410  SCIP_Bool checklprows, /**< Do constraints represented by rows in the current LP have to be checked? */
3411  SCIP_Bool* feasible /**< stores whether given solution is feasible */
3412  )
3413 {
3414  SCIP_CALL( SCIPcheckStage(scip, "SCIPcheckSol", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
3415 
3416  /* return immediately if the solution is of type partial */
3417  if( SCIPsolIsPartial(sol) )
3418  {
3419  SCIPerrorMessage("Cannot check feasibility of partial solutions.");
3420  return SCIP_INVALIDDATA;
3421  }
3422 
3423  /* if we want to solve exactly, the constraint handlers cannot rely on the LP's feasibility */
3424  checklprows = checklprows || scip->set->misc_exactsolve;
3425 
3426  if( !printreason )
3427  completely = FALSE;
3428 
3429  if( SCIPsolIsOriginal(sol) )
3430  {
3431  /* SCIPsolCheck() can only be called on transformed solutions */
3432  SCIP_CALL( checkSolOrig(scip, sol, feasible, printreason, completely, checkbounds, checkintegrality, checklprows, FALSE) );
3433  }
3434  else
3435  {
3436  SCIP_CALL( SCIPsolCheck(sol, scip->set, scip->messagehdlr, scip->mem->probmem, scip->stat, scip->transprob,
3437  printreason, completely, checkbounds, checkintegrality, checklprows, feasible) );
3438  }
3439 
3440  return SCIP_OKAY;
3441 }
3442 
3443 /** checks solution for feasibility in original problem without adding it to the solution store;
3444  * this method is used to double check a solution in order to validate the presolving process
3445  *
3446  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
3447  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
3448  *
3449  * @pre This method can be called if SCIP is in one of the following stages:
3450  * - \ref SCIP_STAGE_PROBLEM
3451  * - \ref SCIP_STAGE_TRANSFORMED
3452  * - \ref SCIP_STAGE_INITPRESOLVE
3453  * - \ref SCIP_STAGE_PRESOLVING
3454  * - \ref SCIP_STAGE_EXITPRESOLVE
3455  * - \ref SCIP_STAGE_PRESOLVED
3456  * - \ref SCIP_STAGE_INITSOLVE
3457  * - \ref SCIP_STAGE_SOLVING
3458  * - \ref SCIP_STAGE_SOLVED
3459  */
3461  SCIP* scip, /**< SCIP data structure */
3462  SCIP_SOL* sol, /**< primal CIP solution */
3463  SCIP_Bool* feasible, /**< stores whether given solution is feasible */
3464  SCIP_Bool printreason, /**< should the reason for the violation be printed? */
3465  SCIP_Bool completely /**< Should all violations be checked if printreason is true? */
3466  )
3467 {
3468  assert(scip != NULL);
3469  assert(sol != NULL);
3470  assert(feasible != NULL);
3471 
3472  SCIP_CALL( SCIPcheckStage(scip, "SCIPcheckSolOrig", FALSE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE) );
3473 
3474  /* return immediately if the solution is of type partial */
3475  if( SCIPsolIsPartial(sol) )
3476  {
3477  SCIPerrorMessage("Cannot check feasibility of partial solutions.");
3478  return SCIP_INVALIDDATA;
3479  }
3480 
3481  if( !printreason )
3482  completely = FALSE;
3483 
3484  /* check solution in original problem; that includes bounds, integrality, and non modifiable constraints */
3485  SCIP_CALL( checkSolOrig(scip, sol, feasible, printreason, completely, TRUE, TRUE, TRUE, FALSE) );
3486 
3487  return SCIP_OKAY;
3488 }
3489 
3490 /** return whether a primal ray is stored that proves unboundedness of the LP relaxation
3491  *
3492  * @return return whether a primal ray is stored that proves unboundedness of the LP relaxation
3493  *
3494  * @pre This method can be called if SCIP is in one of the following stages:
3495  * - \ref SCIP_STAGE_SOLVING
3496  * - \ref SCIP_STAGE_SOLVED
3497  */
3499  SCIP* scip /**< SCIP data structure */
3500  )
3501 {
3502  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPhasPrimalRay", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE) );
3503 
3504  return scip->primal->primalray != NULL;
3505 }
3506 
3507 /** gets value of given variable in primal ray causing unboundedness of the LP relaxation;
3508  * should only be called if such a ray is stored (check with SCIPhasPrimalRay())
3509  *
3510  * @return value of given variable in primal ray causing unboundedness of the LP relaxation
3511  *
3512  * @pre This method can be called if SCIP is in one of the following stages:
3513  * - \ref SCIP_STAGE_SOLVING
3514  * - \ref SCIP_STAGE_SOLVED
3515  */
3517  SCIP* scip, /**< SCIP data structure */
3518  SCIP_VAR* var /**< variable to get value for */
3519  )
3520 {
3521  SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPgetPrimalRayVal", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE) );
3522 
3523  assert(var != NULL);
3524  assert(scip->primal->primalray != NULL);
3525  assert(var->scip == scip);
3526 
3527  return SCIPsolGetRayVal(scip->primal->primalray, scip->set, scip->stat, var);
3528 }
3529 
3530 /** updates the primal ray thats proves unboundedness
3531  *
3532  * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
3533  * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
3534  *
3535  * @pre This method can be called if @p scip is in one of the following stages:
3536  * - \ref SCIP_STAGE_PRESOLVING
3537  * - \ref SCIP_STAGE_PRESOLVED
3538  * - \ref SCIP_STAGE_SOLVING
3539  * - \ref SCIP_STAGE_SOLVED
3540  *
3541  * See \ref SCIP_Stage "SCIP_STAGE" for a complete list of all possible solving stages.
3542  */
3544  SCIP* scip, /**< SCIP data structure */
3545  SCIP_SOL* primalray /**< the new primal ray */
3546  )
3547 {
3548  assert(scip != NULL);
3549  assert(primalray != NULL);
3550 
3551  SCIP_CALL( SCIPcheckStage(scip, "SCIPupdatePrimalRay", FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE) );
3552 
3553  SCIP_CALL( SCIPprimalUpdateRay(scip->primal, scip->set, scip->stat, primalray, scip->mem->probmem) );
3554 
3555  return SCIP_OKAY;
3556 }
SCIP_RETCODE SCIPprintBestTransSol(SCIP *scip, FILE *file, SCIP_Bool printzeros)
Definition: scip_sol.c:2410
enum SCIP_Result SCIP_RESULT
Definition: type_result.h:52
SCIP_Real SCIPgetPrimalRayVal(SCIP *scip, SCIP_VAR *var)
Definition: scip_sol.c:3516
SCIP_Bool SCIPisEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_STAT * stat
Definition: struct_scip.h:69
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:3311
SCIP_RETCODE SCIPcreateOrigSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip_sol.c:556
SCIP_SOL * primalray
Definition: struct_primal.h:52
SCIP_RETCODE SCIPsolCreateRelaxSol(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_RELAXATION *relaxation, SCIP_HEUR *heur)
Definition: sol.c:616
SCIP_RETCODE SCIPsolUnlink(SCIP_SOL *sol, SCIP_SET *set, SCIP_PROB *prob)
Definition: sol.c:1000
SCIP_RETCODE SCIPfreeSol(SCIP *scip, SCIP_SOL **sol)
Definition: scip_sol.c:976
SCIP_RETCODE SCIPsolRound(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_TREE *tree, SCIP_Bool *success)
Definition: sol.c:1720
SCIP_EXPORT SCIP_Bool SCIPvarIsTransformed(SCIP_VAR *var)
Definition: var.c:16880
SCIP_Real SCIPepsilon(SCIP *scip)
SCIP_RETCODE SCIPsolCreatePartial(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PRIMAL *primal, SCIP_HEUR *heur)
Definition: sol.c:686
SCIP_RETCODE SCIProundSol(SCIP *scip, SCIP_SOL *sol, SCIP_Bool *success)
Definition: scip_sol.c:2446
SCIP_Bool SCIPmessagehdlrIsQuiet(SCIP_MESSAGEHDLR *messagehdlr)
Definition: message.c:900
#define NULL
Definition: def.h:253
int lineno
Definition: reader_tim.c:90
SCIP_Bool SCIPconshdlrNeedsCons(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:5107
SCIP_RETCODE SCIPsolLinkPseudoSol(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_TREE *tree, SCIP_LP *lp)
Definition: sol.c:911
internal methods for storing primal CIP solutions
SCIP_RETCODE SCIPsetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var, SCIP_Real val)
Definition: scip_sol.c:1212
public methods for SCIP parameter handling
SCIP_Real SCIPgetLhsLinear(SCIP *scip, SCIP_CONS *cons)
internal methods for branch and bound tree
SCIP_RETCODE SCIPprintDualSol(SCIP *scip, FILE *file, SCIP_Bool printzeros)
Definition: scip_sol.c:2136
SCIP_RETCODE SCIPaddCurrentSol(SCIP *scip, SCIP_HEUR *heur, SCIP_Bool *stored)
Definition: scip_sol.c:3084
public methods for memory management
SCIP_Real SCIPgetVarRedcost(SCIP *scip, SCIP_VAR *var)
Definition: scip_var.c:1866
SCIP_RETCODE SCIPlinkCurrentSol(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:1122
SCIP_Bool SCIPconsIsChecked(SCIP_CONS *cons)
Definition: cons.c:8275
int SCIPgetSolRunnum(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:1621
SCIP_RETCODE SCIPsolLinkNLPSol(SCIP_SOL *sol, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_NLP *nlp)
Definition: sol.c:830
#define SCIP_MAXSTRLEN
Definition: def.h:274
SCIP_EXPORT SCIP_Bool SCIPsolIsOriginal(SCIP_SOL *sol)
Definition: sol.c:2470
SCIP_PRIMAL * origprimal
Definition: struct_scip.h:71
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:1438
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
Definition: scip_message.c:122
SCIP_Real SCIPtransformObj(SCIP *scip, SCIP_Real obj)
Definition: scip_sol.c:1542
SCIP_RETCODE SCIPcreatePartialSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip_sol.c:496
#define SCIP_CALL_FINALLY(x, y)
Definition: def.h:407
SCIP_EXPORT SCIP_Real SCIPvarGetLPSol(SCIP_VAR *var)
Definition: var.c:17726
SCIP_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var)
Definition: scip_sol.c:1352
SCIP_EVENTQUEUE * eventqueue
Definition: struct_scip.h:78
public solving methods
SCIP_RETCODE SCIPaddCoefLinear(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real val)
SCIP_PRIMAL * primal
Definition: struct_scip.h:83
SCIP_RETCODE SCIPsolLinkLPSol(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_TREE *tree, SCIP_LP *lp)
Definition: sol.c:772
SCIP_RETCODE SCIPgetDualSolVal(SCIP *scip, SCIP_CONS *cons, SCIP_Real *dualsolval, SCIP_Bool *boundconstraint)
Definition: scip_sol.c:1947
SCIP_RETCODE SCIPsolCreateUnknown(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_HEUR *heur)
Definition: sol.c:720
SCIP_RETCODE 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:1269
SCIP_RETCODE SCIPlinkPseudoSol(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:1102
SCIP_RETCODE SCIPsolLinkCurrentSol(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_TREE *tree, SCIP_LP *lp)
Definition: sol.c:940
void SCIPdeactivateSolViolationUpdates(SCIP *scip)
Definition: scip_sol.c:296
SCIP_SOL ** sols
Definition: struct_primal.h:48
void SCIPstoreSolutionGap(SCIP *scip)
static SCIP_RETCODE setupAndSolveFiniteSolSubscip(SCIP *scip, SCIP *subscip, SCIP_VAR **origvars, int norigvars, SCIP_Real *solvals, SCIP_Bool *success)
Definition: scip_sol.c:689
void SCIPverbMessage(SCIP *scip, SCIP_VERBLEVEL msgverblevel, FILE *file, const char *formatstr,...)
Definition: scip_message.c:215
#define FALSE
Definition: def.h:73
SCIP_RETCODE SCIPreadSolFile(SCIP *scip, const char *filename, SCIP_SOL *sol, SCIP_Bool xml, SCIP_Bool *partial, SCIP_Bool *error)
Definition: scip_sol.c:2884
SCIP_Bool solved
Definition: struct_lp.h:352
SCIP_EXPORT SCIP_HEUR * SCIPsolGetHeur(SCIP_SOL *sol)
Definition: sol.c:2553
int SCIPgetNPartialSols(SCIP *scip)
Definition: scip_sol.c:3376
SCIP_RETCODE SCIPsolCopy(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PRIMAL *primal, SCIP_SOL *sourcesol)
Definition: sol.c:346
SCIP_STAGE stage
Definition: struct_set.h:63
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)
#define TRUE
Definition: def.h:72
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
SCIP_RETCODE SCIPlinkLPSol(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:1017
SCIP_Real SCIPprobInternObjval(SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_SET *set, SCIP_Real objval)
Definition: prob.c:2096
SCIP_RETCODE SCIPrecomputeSolObj(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:1513
SCIP_Real SCIPsolGetRayVal(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_VAR *var)
Definition: sol.c:1429
void SCIPupdateSolLPConsViolation(SCIP *scip, SCIP_SOL *sol, SCIP_Real absviol, SCIP_Real relviol)
Definition: scip_sol.c:276
SCIP_Bool SCIPsolsAreEqual(SCIP_SOL *sol1, SCIP_SOL *sol2, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob)
Definition: sol.c:1982
SCIP_RETCODE SCIPsolve(SCIP *scip)
Definition: scip_solve.c:2535
void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin)
Definition: misc.c:3078
public methods for problem variables
XML_NODE * xmlProcess(const char *filename)
Definition: xmlparse.c:1073
const XML_NODE * xmlFirstChild(const XML_NODE *node)
Definition: xmlparse.c:1457
SCIP_Real SCIPlpGetPseudoObjval(SCIP_LP *lp, SCIP_SET *set, SCIP_PROB *prob)
Definition: lp.c:13101
SCIP_EXPORT SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
Definition: var.c:16857
SCIP_PROB * transprob
Definition: struct_scip.h:87
SCIP_Bool SCIPrelaxationIsSolValid(SCIP_RELAXATION *relaxation)
Definition: relax.c:685
SCIP_RETCODE SCIPsolClear(SCIP_SOL *sol, SCIP_STAT *stat, SCIP_TREE *tree)
Definition: sol.c:966
#define SCIPfreeBufferArray(scip, ptr)
Definition: scip_mem.h:123
SCIP_EXPORT int SCIPsolGetRunnum(SCIP_SOL *sol)
Definition: sol.c:2523
SCIP_Real * SCIPgetValsLinear(SCIP *scip, SCIP_CONS *cons)
public methods for SCIP variables
SCIP_CONS * SCIPconsGetTransformed(SCIP_CONS *cons)
Definition: cons.c:6712
SCIP_RETCODE SCIPunlinkSol(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:1181
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:3124
#define SCIPdebugMsg
Definition: scip_message.h:69
SCIP_RETCODE SCIPcreateNLPSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip_sol.c:389
internal methods for LP management
SCIP_PROB * origprob
Definition: struct_scip.h:70
SCIP_Bool SCIPisTransformed(SCIP *scip)
Definition: scip_general.c:558
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
public methods for numerical tolerances
internal methods for collecting primal CIP solutions and primal informations
SCIP_Real SCIPsolGetVal(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_VAR *var)
Definition: sol.c:1299
void SCIPupdateSolConsViolation(SCIP *scip, SCIP_SOL *sol, SCIP_Real absviol, SCIP_Real relviol)
Definition: scip_sol.c:264
SCIP_RETCODE SCIPcreateSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip_sol.c:319
static SCIP_RETCODE printDualSol(SCIP *scip, FILE *file, SCIP_Bool printzeros)
Definition: scip_sol.c:2017
public methods for querying solving statistics
SCIP_RETCODE SCIPprintBestSol(SCIP *scip, FILE *file, SCIP_Bool printzeros)
Definition: scip_sol.c:2370
int SCIPgetNSols(SCIP *scip)
Definition: scip_sol.c:2205
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:1408
SCIP_FILE * SCIPfopen(const char *path, const char *mode)
Definition: fileio.c:140
SCIP_RETCODE SCIPcreateRelaxSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip_sol.c:424
SCIP_RETCODE SCIPcreateSolCopy(SCIP *scip, SCIP_SOL **sol, SCIP_SOL *sourcesol)
Definition: scip_sol.c:609
SCIP_RETCODE SCIPcreate(SCIP **scip)
Definition: scip_general.c:282
SCIP_MEM * mem
Definition: struct_scip.h:61
public methods for managing constraints
SCIP_Real SCIPrelDiff(SCIP_Real val1, SCIP_Real val2)
Definition: misc.c:10571
SCIP_EXPORT SCIP_Real SCIPvarGetSol(SCIP_VAR *var, SCIP_Bool getlpval)
Definition: var.c:12749
SCIP_Real SCIPsolGetObj(SCIP_SOL *sol, SCIP_SET *set, SCIP_PROB *transprob, SCIP_PROB *origprob)
Definition: sol.c:1498
SCIP_EXPORT const char * SCIPvarGetName(SCIP_VAR *var)
Definition: var.c:16738
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:1508
SCIP_VAR ** SCIPgetFixedVars(SCIP *scip)
Definition: scip_prob.c:2261
internal methods for storing and manipulating the main problem
#define SCIPerrorMessage
Definition: pub_message.h:45
void SCIPupdateSolIntegralityViolation(SCIP *scip, SCIP_SOL *sol, SCIP_Real absviol)
Definition: scip_sol.c:229
SCIP_EVENTFILTER * eventfilter
Definition: struct_scip.h:77
SCIP_RETCODE SCIPincSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var, SCIP_Real incval)
Definition: scip_sol.c:1309
struct XML_NODE_struct XML_NODE
Definition: xml.h:41
static SCIP_RETCODE readXmlSolFile(SCIP *scip, const char *filename, SCIP_SOL *sol, SCIP_Bool *partial, SCIP_Bool *error)
Definition: scip_sol.c:2711
SCIP_RETCODE SCIPprintTransSol(SCIP *scip, SCIP_SOL *sol, FILE *file, SCIP_Bool printzeros)
Definition: scip_sol.c:1848
SCIP_RETCODE SCIPsolCreateCurrentSol(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_LP *lp, SCIP_HEUR *heur)
Definition: sol.c:659
SCIP_EXPORT SCIP_SOLORIGIN SCIPsolGetOrigin(SCIP_SOL *sol)
Definition: sol.c:2460
static SCIP_RETCODE readSolFile(SCIP *scip, const char *filename, SCIP_SOL *sol, SCIP_Bool *partial, SCIP_Bool *error)
Definition: scip_sol.c:2555
void SCIPupdateSolBoundViolation(SCIP *scip, SCIP_SOL *sol, SCIP_Real absviol, SCIP_Real relviol)
Definition: scip_sol.c:240
SCIP_RETCODE SCIPreadProb(SCIP *scip, const char *filename, const char *extension)
Definition: scip_prob.c:325
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:2010
const XML_NODE * xmlFindNodeMaxdepth(const XML_NODE *node, const char *name, int depth, int maxdepth)
Definition: xmlparse.c:1407
int SCIPfeof(SCIP_FILE *stream)
Definition: fileio.c:214
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
Definition: scip_mem.c:47
struct SCIP_File SCIP_FILE
Definition: pub_fileio.h:34
char * SCIPfgets(char *s, int size, SCIP_FILE *stream)
Definition: fileio.c:187
SCIP_RETCODE SCIPsolSetVal(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_VAR *var, SCIP_Real val)
Definition: sol.c:1029
SCIP_CONSHDLR ** conshdlrs
Definition: struct_set.h:70
SCIP_Real SCIPgetRhsLinear(SCIP *scip, SCIP_CONS *cons)
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
SCIP_Bool SCIPisZero(SCIP *scip, SCIP_Real val)
SCIP_REOPT * reopt
Definition: struct_scip.h:74
internal methods for NLP management
SCIP_RETCODE SCIPcopyOrig(SCIP *sourcescip, SCIP *targetscip, SCIP_HASHMAP *varmap, SCIP_HASHMAP *consmap, const char *suffix, SCIP_Bool enablepricing, SCIP_Bool passmessagehdlr, SCIP_Bool *valid)
Definition: scip_copy.c:2715
int SCIPgetNFixedVars(SCIP *scip)
Definition: scip_prob.c:2304
void SCIPprintReal(SCIP *scip, FILE *file, SCIP_Real val, int width, int precision)
SCIP_OBJSENSE SCIPgetObjsense(SCIP *scip)
Definition: scip_prob.c:1224
SCIP_RETCODE SCIPlinkRelaxSol(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:1075
SCIP_RETCODE SCIPadjustImplicitSolVals(SCIP *scip, SCIP_SOL *sol, SCIP_Bool uselprows)
Definition: scip_sol.c:1723
#define REALABS(x)
Definition: def.h:188
SCIP_RETCODE SCIPcreateCurrentSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip_sol.c:474
SCIP_Bool SCIPprimalUpdateViolations(SCIP_PRIMAL *primal)
Definition: primal.c:1913
public methods for problem copies
public methods for primal CIP solutions
SCIP_RETCODE SCIPsolCreateOriginal(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_HEUR *heur)
Definition: sol.c:312
internal methods for global SCIP settings
#define SCIP_CALL(x)
Definition: def.h:365
SCIP main data structure.
SCIP_RETCODE SCIPreadSol(SCIP *scip, const char *filename)
Definition: scip_sol.c:2540
SCIP_VAR * h
Definition: circlepacking.c:59
void SCIPmessagePrintInfo(SCIP_MESSAGEHDLR *messagehdlr, const char *formatstr,...)
Definition: message.c:584
internal methods for relaxators
SCIP_Bool SCIPsetIsEQ(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:5975
SCIP_Real SCIPlpGetObjval(SCIP_LP *lp, SCIP_SET *set, SCIP_PROB *prob)
Definition: lp.c:12918
SCIP_RETCODE SCIPcreateFiniteSolCopy(SCIP *scip, SCIP_SOL **sol, SCIP_SOL *sourcesol, SCIP_Bool *success)
Definition: scip_sol.c:840
SCIP_HEUR * SCIPgetSolHeur(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:1675
public methods for constraint handler plugins and constraints
void SCIPsolRecomputeObj(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *origprob)
Definition: sol.c:1947
wrapper functions to map file i/o to standard or zlib file i/o
SCIP_Longint SCIPgetSolNodenum(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:1648
#define SCIPallocBufferArray(scip, ptr, num)
Definition: scip_mem.h:111
#define SCIP_UNKNOWN
Definition: def.h:185
SCIP_Real SCIPinfinity(SCIP *scip)
public data structures and miscellaneous methods
SCIP_Bool SCIPareSolsEqual(SCIP *scip, SCIP_SOL *sol1, SCIP_SOL *sol2)
Definition: scip_sol.c:1703
SCIP_RETCODE SCIPlinkNLPSol(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:1043
SCIP_RETCODE SCIPconsGetNVars(SCIP_CONS *cons, SCIP_SET *set, int *nvars, SCIP_Bool *success)
Definition: cons.c:6311
SCIP_RETCODE SCIPsetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
Definition: scip_sol.c:1254
#define SCIP_Bool
Definition: def.h:70
SCIP_RETCODE SCIPaddSolFree(SCIP *scip, SCIP_SOL **sol, SCIP_Bool *stored)
Definition: scip_sol.c:3014
SCIP_SOL ** SCIPgetPartialSols(SCIP *scip)
Definition: scip_sol.c:3354
SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize)
Definition: misc.c:2891
SCIP_EXPORT SCIP_VAR * SCIPvarGetProbvar(SCIP_VAR *var)
Definition: var.c:11712
int ncontvars
Definition: struct_prob.h:65
SCIP_RETCODE SCIPcreatePseudoSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip_sol.c:451
SCIP_Bool SCIPisNLPConstructed(SCIP *scip)
Definition: scip_nlp.c:209
SCIP_NLPSOLSTAT SCIPnlpGetSolstat(SCIP_NLP *nlp)
Definition: nlp.c:5982
SCIP_RETCODE SCIPsolIncVal(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_VAR *var, SCIP_Real incval)
Definition: sol.c:1223
SCIP_EXPORT SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
Definition: var.c:17362
void SCIPactivateSolViolationUpdates(SCIP *scip)
Definition: scip_sol.c:288
SCIP_RETCODE SCIPsolCreate(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_HEUR *heur)
Definition: sol.c:278
void SCIPsolResetViolations(SCIP_SOL *sol)
Definition: sol.c:2287
void SCIPmessagehdlrSetQuiet(SCIP_MESSAGEHDLR *messagehdlr, SCIP_Bool quiet)
Definition: message.c:401
SCIP_RETCODE SCIPcreateLPSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip_sol.c:361
SCIP_RETCODE SCIPsolRetransform(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *origprob, SCIP_PROB *transprob, SCIP_Bool *hasinfval)
Definition: sol.c:1820
SCIP_RETCODE SCIPsolMarkPartial(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_VAR **vars, int nvars)
Definition: sol.c:1534
SCIP_RETCODE SCIPcreateVar(SCIP *scip, SCIP_VAR **var, const char *name, SCIP_Real lb, SCIP_Real ub, SCIP_Real obj, SCIP_VARTYPE vartype, SCIP_Bool initial, SCIP_Bool removable, SCIP_DECL_VARDELORIG((*vardelorig)), SCIP_DECL_VARTRANS((*vartrans)), SCIP_DECL_VARDELTRANS((*vardeltrans)), SCIP_DECL_VARCOPY((*varcopy)), SCIP_VARDATA *vardata)
Definition: scip_var.c:104
void SCIPupdateSolLPRowViolation(SCIP *scip, SCIP_SOL *sol, SCIP_Real absviol, SCIP_Real relviol)
Definition: scip_sol.c:252
SCIP_RETCODE SCIPsolPrint(SCIP_SOL *sol, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_PROB *transprob, FILE *file, SCIP_Bool mipstart, SCIP_Bool printzeros)
Definition: sol.c:2042
SCIP_Real SCIPgetSolTime(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:1594
SCIP_SOL ** partialsols
Definition: struct_primal.h:49
methods for debugging
void SCIPsolUpdateConsViolation(SCIP_SOL *sol, SCIP_Real absviolcons, SCIP_Real relviolcons)
Definition: sol.c:2340
SCIP_Bool SCIPisDualSolAvailable(SCIP *scip, SCIP_Bool printreason)
Definition: scip_sol.c:2073
datastructures for block memory pools and memory buffers
SCIP_Bool SCIPconsIsTransformed(SCIP_CONS *cons)
Definition: cons.c:8385
SCIP_EXPORT SCIP_Bool SCIPsolIsPartial(SCIP_SOL *sol)
Definition: sol.c:2480
SCIP_Bool SCIPtreeHasCurrentNodeLP(SCIP_TREE *tree)
Definition: tree.c:8324
SCIP_RETCODE SCIPfixVar(SCIP *scip, SCIP_VAR *var, SCIP_Real fixedval, SCIP_Bool *infeasible, SCIP_Bool *fixed)
Definition: scip_var.c:8180
void SCIPsolUpdateBoundViolation(SCIP_SOL *sol, SCIP_Real absviolbounds, SCIP_Real relviolbounds)
Definition: sol.c:2314
Constraint handler for linear constraints in their most general form, .
SCIP_EXPORT SCIP_Real SCIPvarGetLbOriginal(SCIP_VAR *var)
Definition: var.c:17298
datastructures for problem statistics
SCIP_RETCODE SCIPaddVar(SCIP *scip, SCIP_VAR *var)
Definition: scip_prob.c:1667
SCIP_Bool SCIPsetIsFeasLT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6373
SCIP_EXPORT SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
Definition: var.c:17408
SCIP_RETCODE SCIPsolPrintRay(SCIP_SOL *sol, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_PROB *transprob, FILE *file, SCIP_Bool printzeros)
Definition: sol.c:2175
SCIP * scip
Definition: struct_var.h:201
SCIP_VAR * SCIPfindVar(SCIP *scip, const char *name)
Definition: scip_prob.c:2680
SCIP_RETCODE SCIPcheckSolOrig(SCIP *scip, SCIP_SOL *sol, SCIP_Bool *feasible, SCIP_Bool printreason, SCIP_Bool completely)
Definition: scip_sol.c:3460
void SCIPsolUpdateIntegralityViolation(SCIP_SOL *sol, SCIP_Real absviolintegrality)
Definition: sol.c:2303
SCIP_RETCODE SCIPsolAdjustImplicitSolVals(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_TREE *tree, SCIP_Bool uselprows)
Definition: sol.c:437
SCIP_EXPORT SCIP_Real SCIPsolGetOrigObj(SCIP_SOL *sol)
Definition: sol.c:2490
void SCIPprimalSetUpdateViolations(SCIP_PRIMAL *primal, SCIP_Bool updateviolations)
Definition: primal.c:1923
public methods for nonlinear relaxations
SCIP_RETCODE SCIPupdatePrimalRay(SCIP *scip, SCIP_SOL *primalray)
Definition: scip_sol.c:3543
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:1324
SCIP_EXPORT SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
Definition: var.c:17418
SCIP_RETCODE SCIPgetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
Definition: scip_sol.c:1389
SCIP_RETCODE SCIPsolLinkRelaxSol(SCIP_SOL *sol, SCIP_SET *set, SCIP_STAT *stat, SCIP_TREE *tree, SCIP_RELAXATION *relaxation)
Definition: sol.c:881
SCIP_EXPORT SCIP_Real SCIPsolGetTime(SCIP_SOL *sol)
Definition: sol.c:2513
SCIP_Bool misc_exactsolve
Definition: struct_set.h:361
general public methods
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:1214
BMS_BLKMEM * probmem
Definition: struct_mem.h:40
SCIP_Bool SCIPisFeasGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
public methods for solutions
SCIP_RETCODE SCIPchgVarObj(SCIP *scip, SCIP_VAR *var, SCIP_Real newobj)
Definition: scip_var.c:4451
SCIP_RETCODE SCIPcreateSolCopyOrig(SCIP *scip, SCIP_SOL **sol, SCIP_SOL *sourcesol)
Definition: scip_sol.c:649
const char * xmlGetAttrval(const XML_NODE *node, const char *name)
Definition: xmlparse.c:1325
void SCIPsolUpdateLPRowViolation(SCIP_SOL *sol, SCIP_Real absviollprows, SCIP_Real relviollprows)
Definition: sol.c:2327
SCIP_SOL ** SCIPgetSols(SCIP *scip)
Definition: scip_sol.c:2254
SCIP_RETCODE SCIPsolCreateLPSol(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_LP *lp, SCIP_HEUR *heur)
Definition: sol.c:572
SCIP_EXPORT SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
Definition: var.c:17352
SCIP_Bool SCIPisFeasLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_EXPORT SCIP_Longint SCIPsolGetNodenum(SCIP_SOL *sol)
Definition: sol.c:2533
int nconss
Definition: struct_prob.h:73
SCIP_SET * set
Definition: struct_scip.h:62
public methods for message output
SCIP_Real SCIPgetSolTransObj(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:1482
data structures for LP management
SCIP_RETCODE SCIPcreateUnknownSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip_sol.c:524
int SCIPconshdlrGetCheckPriority(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:5067
int SCIPsnprintf(char *t, int len, const char *s,...)
Definition: misc.c:10263
void SCIPmessageFPrintInfo(SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char *formatstr,...)
Definition: message.c:608
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:1146
SCIP_RETCODE SCIPprintSol(SCIP *scip, SCIP_SOL *sol, FILE *file, SCIP_Bool printzeros)
Definition: scip_sol.c:1766
void SCIPhashmapFree(SCIP_HASHMAP **hashmap)
Definition: misc.c:2925
const char * SCIPconsGetName(SCIP_CONS *cons)
Definition: cons.c:8076
SCIP_RETCODE SCIPreleaseVar(SCIP *scip, SCIP_VAR **var)
Definition: scip_var.c:1251
SCIP_MESSAGEHDLR * messagehdlr
Definition: struct_scip.h:65
#define SCIP_Real
Definition: def.h:164
SCIP_VAR ** vars
Definition: struct_prob.h:55
SCIP_Bool SCIPlpIsSolved(SCIP_LP *lp)
Definition: lp.c:17434
SCIP_Real SCIPretransformObj(SCIP *scip, SCIP_Real obj)
Definition: scip_sol.c:1567
SCIP_CONSHDLR * SCIPconsGetHdlr(SCIP_CONS *cons)
Definition: cons.c:8096
SCIP_Real SCIPgetDualsolLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPaddSol(SCIP *scip, SCIP_SOL *sol, SCIP_Bool *stored)
Definition: scip_sol.c:2924
SCIP_NLP * nlp
Definition: struct_scip.h:81
datastructures for collecting primal CIP solutions and primal informations
public methods for message handling
SCIP_RETCODE SCIPprintMIPStart(SCIP *scip, SCIP_SOL *sol, FILE *file)
Definition: scip_sol.c:1905
SCIP_CONS ** conss
Definition: struct_prob.h:59
#define SCIP_INVALID
Definition: def.h:184
internal methods for constraints and constraint handlers
SCIP_RETCODE SCIPretransformSol(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:2482
SCIP_Bool SCIPhasPrimalRay(SCIP *scip)
Definition: scip_sol.c:3498
void SCIPprintSysError(const char *message)
Definition: misc.c:10172
#define SCIP_Longint
Definition: def.h:149
const char * SCIPconshdlrGetName(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4191
SCIP_RETCODE SCIPsolCreateNLPSol(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_NLP *nlp, SCIP_HEUR *heur)
Definition: sol.c:595
SCIP_Bool SCIPsetIsFeasGT(SCIP_SET *set, SCIP_Real val1, SCIP_Real val2)
Definition: set.c:6417
SCIP_TREE * tree
Definition: struct_scip.h:84
declarations for XML parsing
void SCIPsolUpdateLPConsViolation(SCIP_SOL *sol, SCIP_Real absviol, SCIP_Real relviol)
Definition: sol.c:2353
SCIP_RELAXATION * relaxation
Definition: struct_scip.h:82
SCIP_RETCODE SCIPclearSol(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:1153
SCIP_Bool dualfeasible
Definition: struct_lp.h:355
SCIP_RETCODE SCIPaddCons(SCIP *scip, SCIP_CONS *cons)
Definition: scip_prob.c:2765
SCIP_RETCODE SCIPprintRay(SCIP *scip, SCIP_SOL *sol, FILE *file, SCIP_Bool printzeros)
Definition: scip_sol.c:2169
SCIP_Bool performpresol
Definition: struct_stat.h:264
SCIP_Real SCIPprobExternObjval(SCIP_PROB *transprob, SCIP_PROB *origprob, SCIP_SET *set, SCIP_Real objval)
Definition: prob.c:2074
int nconshdlrs
Definition: struct_set.h:102
SCIP_RETCODE SCIPsolCreatePseudoSol(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_PRIMAL *primal, SCIP_TREE *tree, SCIP_LP *lp, SCIP_HEUR *heur)
Definition: sol.c:638
SCIP_RETCODE SCIPfree(SCIP **scip)
Definition: scip_general.c:314
void xmlFreeNode(XML_NODE *node)
Definition: xmlparse.c:1263
SCIP_EXPORT SCIP_Real SCIPvarGetUbOriginal(SCIP_VAR *var)
Definition: var.c:17318
int SCIPfclose(SCIP_FILE *fp)
Definition: fileio.c:219
SCIP_RETCODE SCIPconshdlrCheck(SCIP_CONSHDLR *conshdlr, BMS_BLKMEM *blkmem, SCIP_SET *set, SCIP_STAT *stat, SCIP_SOL *sol, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool printreason, SCIP_Bool completely, SCIP_RESULT *result)
Definition: cons.c:3754
#define SCIP_CALL_ABORT(x)
Definition: def.h:344
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
Definition: scip_cons.c:1109
SCIP_RETCODE SCIPprimalUpdateRay(SCIP_PRIMAL *primal, SCIP_SET *set, SCIP_STAT *stat, SCIP_SOL *primalray, BMS_BLKMEM *blkmem)
Definition: primal.c:568
SCIP_RETCODE SCIPchgVarType(SCIP *scip, SCIP_VAR *var, SCIP_VARTYPE vartype, SCIP_Bool *infeasible)
Definition: scip_var.c:8084
SCIP_STAGE SCIPgetStage(SCIP *scip)
Definition: scip_general.c:355
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:3218
SCIP_LP * lp
Definition: struct_scip.h:80
#define SCIPABORT()
Definition: def.h:337
public methods for global and local (sub)problems
SCIP_VAR ** SCIPgetVarsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPgetVarSols(SCIP *scip, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
Definition: scip_var.c:2329
SCIP_RETCODE SCIPsolCheck(SCIP_SOL *sol, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, BMS_BLKMEM *blkmem, SCIP_STAT *stat, SCIP_PROB *prob, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *feasible)
Definition: sol.c:1599
SCIP_Bool SCIPnlpHasSolution(SCIP_NLP *nlp)
Definition: nlp.c:6019
datastructures for global SCIP settings
SCIP_SOL * SCIPgetBestSol(SCIP *scip)
Definition: scip_sol.c:2304
SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value)
Definition: scip_param.c:496
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:3403
SCIP_RETCODE SCIPgetOrigVarsData(SCIP *scip, SCIP_VAR ***vars, int *nvars, int *nbinvars, int *nintvars, int *nimplvars, int *ncontvars)
Definition: scip_prob.c:2352
SCIP_RETCODE SCIPconsCheck(SCIP_CONS *cons, SCIP_SET *set, SCIP_SOL *sol, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool printreason, SCIP_RESULT *result)
Definition: cons.c:7288
const XML_NODE * xmlNextSibl(const XML_NODE *node)
Definition: xmlparse.c:1437
SCIP_Bool SCIPconsIsModifiable(SCIP_CONS *cons)
Definition: cons.c:8325
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:1582
SCIP_RETCODE SCIPsolFree(SCIP_SOL **sol, BMS_BLKMEM *blkmem, SCIP_PRIMAL *primal)
Definition: sol.c:753
type definitions for specific NLP solver interfaces
SCIP_Real SCIPgetSolOrigObj(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:1435
memory allocation routines