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