Scippy

SCIP

Solving Constraint Integer Programs

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