Scippy

SCIP

Solving Constraint Integer Programs

heur_repair.c
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program and library */
4 /* SCIP --- Solving Constraint Integer Programs */
5 /* */
6 /* Copyright (C) 2002-2022 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SCIP; see the file COPYING. If not visit scipopt.org. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file heur_repair.c
17  * @ingroup DEFPLUGINS_HEUR
18  * @brief repair primal heuristic
19  * @author Gregor Hendel
20  * @author Thomas Nagel
21  *
22  */
23 
24 /* This heuristic takes an infeasible solution and tries to repair it.
25  * This can happen by variable fixing as long as the sum of all potential possible shiftings
26  * is higher than alpha*slack or slack variables with a strong penalty on the objective function.
27  * This heuristic cannot run if variable fixing and slack variables are turned off.
28  */
29 
30 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
31 
32 #include "blockmemshell/memory.h"
33 #include "scip/cons_linear.h"
34 #include "scip/cons_varbound.h"
35 #include "scip/heur_repair.h"
36 #include "scip/pub_heur.h"
37 #include "scip/pub_lp.h"
38 #include "scip/pub_message.h"
39 #include "scip/pub_misc.h"
40 #include "scip/pub_misc_sort.h"
41 #include "scip/pub_var.h"
42 #include "scip/scip_branch.h"
43 #include "scip/scip_cons.h"
44 #include "scip/scip_copy.h"
45 #include "scip/scip_general.h"
46 #include "scip/scip_heur.h"
47 #include "scip/scip_lp.h"
48 #include "scip/scip_mem.h"
49 #include "scip/scip_message.h"
50 #include "scip/scip_numerics.h"
51 #include "scip/scip_param.h"
52 #include "scip/scip_prob.h"
53 #include "scip/scip_sol.h"
54 #include "scip/scip_solve.h"
55 #include "scip/scip_solvingstats.h"
56 #include "scip/scip_timing.h"
57 #include "scip/scip_tree.h"
58 #include "scip/scip_var.h"
59 #include "scip/scipdefplugins.h"
60 #include <string.h>
61 
62 #define HEUR_NAME "repair"
63 #define HEUR_DESC "tries to repair a primal infeasible solution"
64 #define HEUR_DISPCHAR SCIP_HEURDISPCHAR_LNS
65 #define HEUR_PRIORITY -20
66 #define HEUR_FREQ -1
67 #define HEUR_FREQOFS 0
68 #define HEUR_MAXDEPTH -1
69 #define HEUR_TIMING SCIP_HEURTIMING_AFTERNODE
70 #define HEUR_USESSUBSCIP TRUE /**< does the heuristic use a secondary SCIP instance? */
71 #define DEFAULT_MINFIXINGRATE 0.3 /* minimum percentage of integer variables that have to be fixed */
72 
73 #define DEFAULT_NODESOFS 500 /* number of nodes added to the contingent of the total nodes */
74 #define DEFAULT_MAXNODES 5000 /* maximum number of nodes to regard in the subproblem */
75 #define DEFAULT_MINNODES 50 /* minimum number of nodes to regard in the subproblem */
76 #define DEFAULT_NODESQUOT 0.1 /* subproblem nodes in relation to nodes of the original problem */
77 
78 #define DEFAULT_FILENAME "-" /**< file name of a solution to be used as infeasible starting point */
79 #define DEFAULT_ROUNDIT TRUE /**< if it is TRUE : fractional variables which are not fractional in the given
80  * solution are rounded, if it is FALSE : solving process of this heuristic
81  * is stopped
82  */
83 #define DEFAULT_USEOBJFACTOR FALSE /**< should a scaled objective function for original variables be used in repair
84  * subproblem?
85  */
86 #define DEFAULT_USEVARFIX TRUE /**< should variable fixings be used in repair subproblem? */
87 #define DEFAULT_USESLACKVARS FALSE /**< should slack variables be used in repair subproblem? */
88 #define DEFAULT_ALPHA 2.0 /**< how many times the potential should be bigger than the slack? */
89 
90 /*
91  * Data structures
92  */
93 
94 
95 /** primal heuristic data */
96 struct SCIP_HeurData
97 {
98  SCIP_SOL* infsol; /**< infeasible solution to start with */
99  char* filename; /**< file name of a solution to be used as infeasible starting point */
100  SCIP_Longint usednodes; /**< number of already used nodes by repair */
101  SCIP_Longint subnodes; /**< number of nodes which were necessary to solve the sub-SCIP */
102  SCIP_Longint subiters; /**< contains total number of iterations used in primal and dual simplex
103  * and barrier algorithm to solve the sub-SCIP
104  */
105  SCIP_Real relvarfixed; /**< relative number of fixed variables */
106  SCIP_Real alpha; /**< how many times the potential should be bigger than the slack? */
107  SCIP_Real nodesquot; /**< subproblem nodes in relation to nodes of the original problem */
108  SCIP_Real minfixingrate; /**< minimum percentage of integer variables that have to be fixed */
109 #ifdef SCIP_STATISTIC
110  SCIP_Real relviolatedvars; /**< relative number of violated variables */
111  SCIP_Real subpresoltime; /**< time for presolving the sub-SCIP */
112  SCIP_Real relviolatedcons; /**< relative number of violated cons */
113  SCIP_Real originalsolval; /**< value of the solution find by repair, in the original Problem*/
114  SCIP_Real improvedoldsol; /**< value of the given solution after being improved by SCIP */
115  int nviolatedvars; /**< number of violated variables in the given solution */
116  int norigvars; /**< number of all variables in the given problem */
117  int nviolatedcons; /**< number of violated cons in the given solution */
118  int norcons; /**< number of all cons in the given problem */
119 #endif
120  int nvarfixed; /**< number of all variables fixed in the sub problem */
121  int runs; /**< number of branch and bound runs performed to solve the sub-SCIP */
122  int nodesofs; /**< number of nodes added to the contingent of the total nodes */
123  int maxnodes; /**< maximum number of nodes to regard in the subproblem */
124  int minnodes; /**< minimum number of nodes to regard in the subproblem */
125  SCIP_Bool roundit; /**< if it is TRUE : fractional variables which are not fractional in the
126  * given solution are rounded, if it is FALSE : solving process of this
127  * heuristic is stopped.
128  */
129  SCIP_Bool useobjfactor; /**< should a scaled objective function for original variables be used in
130  * repair subproblem?
131  */
132  SCIP_Bool usevarfix; /**< should variable fixings be used in repair subproblem? */
133  SCIP_Bool useslackvars; /**< should slack variables be used in repair subproblem? */
134 };
135 
136 
137 /*
138  * Local methods
139  */
140 
141 /** computes a factor, so that (factor) * (original objective upper bound) <= 1.*/
142 static
144  SCIP* scip, /**< SCIP data structure */
145  SCIP* subscip, /**< SCIP data structure */
146  SCIP_Real* factor, /**< SCIP_Real to save the factor for the old objective function*/
147  SCIP_Bool* success /**< SCIP_Bool: Is the factor real?*/
148  )
149 {
150  SCIP_VAR** vars;
151  SCIP_Real lprelaxobj;
152  SCIP_Real upperbound;
153  SCIP_Real objoffset;
154  int nvars;
155  int i;
156 
157  *success = TRUE;
158  *factor = 0.0;
159  upperbound = 0.0;
160 
161  lprelaxobj = SCIPgetLowerbound(scip);
162 
163  if( SCIPisInfinity(scip, -lprelaxobj) )
164  {
165  return SCIP_OKAY;
166  }
167 
168  if( !SCIPisInfinity(scip, SCIPgetUpperbound(scip)) )
169  {
170  upperbound = SCIPgetUpperbound(scip);
171  }
172  else
173  {
174  SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, NULL, NULL, NULL, NULL) );
175 
176  /* tries to find an upper bound for the original objective function, by compute the worst objective value of the
177  * LP-relaxation, which holds all variable bounds
178  */
179  for (i = 0; i < nvars; ++i)
180  {
181  upperbound = SCIPvarGetObj(vars[i]);
182  if( SCIPisInfinity(scip, upperbound) || SCIPisInfinity(scip, -upperbound) )
183  {
184  /* TODO fancy diving function to find a solution for the max problem */
185  *factor = 1 / SCIPinfinity(scip);
186  return SCIP_OKAY;
187  }
188  else if( SCIPisZero(scip, upperbound) )
189  {
190  continue;
191  }
192  else if( SCIPisGT(scip, 0.0, upperbound) )
193  {
194  *factor += upperbound * SCIPvarGetLbGlobal(vars[i]);
195  }
196  else
197  {
198  *factor += upperbound * SCIPvarGetUbGlobal(vars[i]);
199  }
200  }
201  }
202 
203  /* Ending-sequence */
204  *factor = upperbound - lprelaxobj;
205  if( !SCIPisZero(scip, *factor) )
206  {
207  *factor = 1.0 / *factor;
208  }
209 
210  /* set an offset which guarantees positive objective values */
211  objoffset = -lprelaxobj * (*factor);
212  SCIP_CALL( SCIPaddOrigObjoffset(subscip, -objoffset) );
213 
214  return SCIP_OKAY;
215 }
216 
217 /** returns the contributed potential for a variable */
218 static
220  SCIP* scip, /**< SCIP data structure */
221  SCIP_SOL* sol, /**< infeasible solution */
222  SCIP_VAR* var, /**< variable, which potential should be returned */
223  SCIP_Real coefficient, /**< variables coefficient in corresponding row */
224  int sgn /**< sign of the slack */
225  )
226 {
227  SCIP_Real potential;
228 
229  assert(NULL != scip);
230  assert(NULL != var);
231 
232  if( 0 > sgn * coefficient )
233  {
234  if( SCIPisInfinity(scip, -SCIPvarGetLbGlobal(var)) )
235  {
236  potential = SCIPinfinity(scip);
237  }
238  else
239  {
240  potential = coefficient * (SCIPgetSolVal(scip, sol, var) - SCIPvarGetLbGlobal(var));
241  }
242  }
243  else
244  {
245  if( SCIPisInfinity(scip, SCIPvarGetUbGlobal(var)) )
246  {
247  potential = -SCIPinfinity(scip);
248  }
249  else
250  {
251  potential = coefficient * (SCIPgetSolVal(scip, sol, var) - SCIPvarGetUbGlobal(var));
252  }
253  }
254 
255  if( SCIPisZero(scip, potential) )
256  {
257  potential = 0.0;
258  }
259  return potential;
260 }
261 
262 /** finds out if a variable can be fixed with respect to the potentials of all rows, if it is possible, the potentials
263  * of rows are adapted and TRUE is returned.
264  */
265 static
267  SCIP* scip, /**< SCIP data structure */
268  SCIP* subscip, /**< sub-SCIP data structure */
269  SCIP_SOL* sol, /**< solution data structure */
270  SCIP_Real* potential, /**< array with all potential values */
271  SCIP_Real* slack, /**< array with all slack values */
272  SCIP_VAR* var, /**< variable to be fixed? */
273  SCIP_VAR* subvar, /**< representative variable for var in the sub-SCIP */
274  int* inftycounter, /**< counters how many variables have an infinity potential in a row */
275  SCIP_HEURDATA* heurdata, /**< repairs heuristic data */
276  SCIP_Bool* fixed /**< pointer to store whether the fixing was performed (variable was unfixed) */
277  )
278 {
279  SCIP_ROW** rows;
280  SCIP_COL* col;
281  SCIP_Real* vals;
282  SCIP_Real alpha;
283  SCIP_Real solval;
284  SCIP_Bool infeasible;
285  int nrows;
286  int i;
287  int sgn;
288  int rowindex;
289 
290  assert(NULL != scip);
291  assert(NULL != potential);
292  assert(NULL != slack);
293  assert(NULL != var);
294  assert(NULL != inftycounter);
295  assert(NULL != heurdata);
296 
297  alpha = heurdata->alpha;
298  infeasible = TRUE;
299  *fixed = FALSE;
300 
301  solval = SCIPgetSolVal(scip, sol, var);
302 
303  if( SCIPisFeasLT(scip, solval, SCIPvarGetLbGlobal(var)) )
304  {
305  return SCIP_OKAY;
306  }
307  if( SCIPisFeasGT(scip, solval, SCIPvarGetUbGlobal(var)) )
308  {
309  return SCIP_OKAY;
310  }
311 
312  col = SCIPvarGetCol(var);
313  rows = SCIPcolGetRows(col);
314  nrows = SCIPcolGetNLPNonz(col);
315  vals = SCIPcolGetVals(col);
316 
317  if( NULL == rows )
318  {
319  SCIP_CALL( SCIPfixVar(subscip, subvar, solval,
320  &infeasible, fixed) );
321  assert(!infeasible && *fixed);
322  heurdata->nvarfixed++;
323  SCIPdebugMsg(scip,"Variable %s is fixed to %g\n",SCIPvarGetName(var), solval);
324  return SCIP_OKAY;
325  }
326  assert(NULL != rows);
327 
328  /* iterate over rows, where the variable coefficient is nonzero */
329  for( i = 0; i < nrows; ++i )
330  {
331  SCIP_Real contribution;
332  rowindex = SCIProwGetLPPos(rows[i]);
333  assert(rowindex >= 0);
334 
335  sgn = 1;
336 
337  if( SCIPisFeasZero(scip, slack[rowindex]) )
338  {
339  continue;
340  }
341  else if( SCIPisFeasGT(scip, 0.0 , slack[rowindex]) )
342  {
343  sgn = -1;
344  }
345 
346  contribution = getPotentialContributed(scip, sol, var, vals[i], sgn);
347 
348  if( !SCIPisInfinity(scip, REALABS(contribution)) )
349  {
350  potential[rowindex] -= contribution;
351  }
352  else
353  {
354  inftycounter[rowindex]--;
355  }
356 
357  assert(0 <= inftycounter[rowindex]);
358  if( 0 == inftycounter[rowindex] && REALABS(potential[rowindex]) < alpha * REALABS(slack[rowindex]) )
359  {
360  /* revert the changes before */
361  int j = i;
362  for( ; j >= 0; --j )
363  {
364  sgn = 1;
365  if( 0 == slack[rowindex] )
366  {
367  continue;
368  }
369  rowindex = SCIProwGetLPPos(rows[j]);
370  if( 0 > slack[rowindex])
371  {
372  sgn = -1;
373  }
374  contribution = getPotentialContributed(scip, sol, var, vals[j], sgn);
375  if( !SCIPisInfinity(scip, REALABS(contribution)) )
376  {
377  potential[rowindex] += contribution;
378  }
379  else
380  {
381  inftycounter[rowindex]++;
382  }
383  }
384  return SCIP_OKAY;
385  }
386  }
387 
388  SCIP_CALL( SCIPfixVar(subscip, subvar, solval, &infeasible, fixed) );
389  assert(!infeasible && *fixed);
390  heurdata->nvarfixed++;
391  SCIPdebugMsg(scip,"Variable %s is fixed to %g\n",SCIPvarGetName(var),
392  SCIPgetSolVal(scip, sol, var));
393 
394  return SCIP_OKAY;
395 }
396 
397 /** checks if all integral variables in the given solution are integral. */
398 static
400  SCIP* scip, /**< SCIP data structure */
401  SCIP_SOL* sol, /**< solution pointer to the to be checked solution */
402  SCIP_Bool roundit, /**< round fractional solution values of integer variables */
403  SCIP_Bool* success /**< pointer to store if all integral variables are integral or could
404  * be rounded
405  */
406  )
407 {
408  SCIP_VAR** vars;
409  int nvars;
410  int nfracvars;
411  int nbinvars;
412  int nintvars;
413  int i;
414 
415  assert(NULL != success);
416  assert(NULL != sol);
417 
418  *success = TRUE;
419 
420  /* get variable data */
421  SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, &nbinvars, &nintvars, NULL, NULL) );
422 
423  /* check if the candidates are fractional and round them if necessary */
424  nfracvars = nbinvars + nintvars;
425  for( i = 0; i < nfracvars; ++i)
426  {
427  SCIP_Real value = SCIPgetSolVal(scip, sol, vars[i]);
428 
429  if( SCIPisInfinity(scip, REALABS(value)) )
430  {
431  *success = FALSE;
432  SCIPdebugMsg(scip, "Variable with infinite solution value");
433 
434  return SCIP_OKAY;
435  }
436  if( !SCIPisFeasIntegral(scip, value) )
437  {
438  if( roundit )
439  {
440  SCIP_Real roundedvalue;
441 
443  {
444  roundedvalue = SCIPceil(scip, value - 1.0);
445  }
446  else
447  {
448  roundedvalue = SCIPfloor(scip, value + 1.0);
449  }
450 
451  SCIP_CALL( SCIPsetSolVal(scip, sol, vars[i], roundedvalue) );
452  }
453  else
454  {
455  *success = FALSE;
456  SCIPdebugMsg(scip, "Repair: All variables are integral.\n");
457  return SCIP_OKAY;
458  }
459  }
460  }
461 
462  /* ensure that no other variables have infinite LP solution values */
463  for( ; i < nvars; ++i )
464  {
465  if( SCIPisInfinity(scip, REALABS(SCIPgetSolVal(scip, sol, vars[i]))) )
466  {
467  *success = FALSE;
468  SCIPdebugMsg(scip, "Variable with infinite solution value");
469 
470  return SCIP_OKAY;
471  }
472  }
473 
474  SCIPdebugMsg(scip, "All variables rounded.\n");
475  return SCIP_OKAY;
476 }
477 
478 /** creates a new solution for the original problem by copying the solution of the subproblem */
479 static
481  SCIP* scip, /**< original SCIP data structure */
482  SCIP* subscip, /**< SCIP structure of the subproblem */
483  SCIP_VAR** subvars, /**< the variables of the subproblem */
484  SCIP_HEUR* heur, /**< Repair heuristic structure */
485  SCIP_SOL* subsol, /**< solution of the subproblem */
486  SCIP_Bool* success /**< used to store whether new solution was found or not */
487  )
488 {
489  SCIP_SOL* newsol; /* solution to be created for the original problem */
490 
491  assert(scip != NULL);
492  assert(subscip != NULL);
493  assert(subvars != NULL);
494  assert(subsol != NULL);
495 
496  SCIP_CALL( SCIPtranslateSubSol(scip, subscip, subsol, heur, subvars, &newsol) );
497 
498  /* try to add new solution to SCIP and free it immediately */
499  SCIP_CALL( SCIPtrySolFree(scip, &newsol, FALSE, FALSE, TRUE, TRUE, TRUE, success) );
500 
501 #ifdef SCIP_STATISTIC
502  {
503  SCIP_HEURDATA* heurdata;
504  heurdata = SCIPheurGetData(heur);
505 
506  if( *success )
507  {
508  heurdata->originalsolval = SCIPgetSolOrigObj(scip, newsol);
509  }
510  }
511 #endif
512 
513  return SCIP_OKAY;
514 }
515 
516 /** tries to fix variables as an approach to repair a solution. */
517 static
519  SCIP* scip, /**< SCIP data structure of the problem */
520  SCIP_HEUR* heur, /**< pointer to this heuristic instance */
521  SCIP_RESULT* result, /**< pointer to return the result status */
522  SCIP_Longint nnodes /**< nodelimit for sub-SCIP */
523  )
524 {
525  SCIP* subscip = NULL;
526  SCIP_VAR** vars = NULL;
527  SCIP_VAR** subvars = NULL;
528  SCIP_ROW** rows;
529  SCIP_CONS** subcons = NULL;
530  int* nviolatedrows = NULL;
531  int* permutation = NULL;
532  int* inftycounter = NULL;
533  SCIP_SOL* sol;
534  SCIP_SOL* subsol = NULL;
535  SCIP_HEURDATA* heurdata;
536  SCIP_Real* potential = NULL;
537  SCIP_Real* slacks = NULL;
538  SCIP_RETCODE retcode = SCIP_OKAY;
539  SCIP_Real timelimit;
540  SCIP_Real memorylimit;
541  SCIP_Real factor;
542  char probname[SCIP_MAXSTRLEN];
543  int i;
544  int nbinvars;
545  int nintvars;
546  int nvars;
547  int nrows;
548  int ndiscvars;
549  int nfixeddiscvars;
550  SCIP_Bool success;
551  SCIP_Bool avoidmemout;
552 
553  heurdata = SCIPheurGetData(heur);
554  sol = heurdata->infsol;
555 
556  /* initializes the sub-SCIP */
557  SCIP_CALL( SCIPcreate(&subscip) );
559  SCIP_CALL( SCIPcopyParamSettings(scip, subscip) );
560 
561  /* use inference branching */
562  if( SCIPfindBranchrule(subscip, "inference") != NULL && !SCIPisParamFixed(subscip, "branching/inference/priority") )
563  {
564  SCIP_CALL( SCIPsetIntParam(subscip, "branching/inference/priority", INT_MAX/4) );
565  }
566 
567  /* get name of the original problem and add the string "_repairsub" */
568  (void) SCIPsnprintf(probname, SCIP_MAXSTRLEN, "%s_repairsub", SCIPgetProbName(scip));
569 
570  SCIP_CALL( SCIPcreateProb(subscip, probname, NULL, NULL, NULL, NULL, NULL, NULL, NULL) );
571 
572  /* a trivial feasible solution can be constructed if violations are modeled with slack variables */
573  if( heurdata->useslackvars )
574  {
575  SCIP_CALL( SCIPcreateSol(subscip, &subsol, heur) );
576  }
577 
578  /* gets all original variables */
579  SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, &nbinvars, &nintvars, NULL, NULL) );
580  SCIP_CALL( SCIPallocBufferArray(scip, &subvars, nvars) );
581  SCIP_CALL( SCIPallocBufferArray(scip, &nviolatedrows, nvars) );
582  SCIP_CALL( SCIPallocBufferArray(scip, &permutation, nvars) );
583 
584  SCIPdebugMsg(scip,"\n\n Calling objective factor calculation \n\n");
585  if( heurdata->useobjfactor )
586  {
587  SCIP_CALL( getObjectiveFactor(scip, subscip, &factor, &success) );
588  }
589  else
590  {
591  factor = 0.0;
592  }
593 
594  /* adds all original variables */
595  ndiscvars = 0;
596  for( i = 0; i < nvars; ++i )
597  {
598  SCIP_CONS* cons;
599  SCIP_Real lb;
600  SCIP_Real ub;
601  SCIP_Real lborig;
602  SCIP_Real uborig;
603  SCIP_Real varslack;
604  SCIP_Real objval;
605  SCIP_Real value;
606  SCIP_VARTYPE vartype;
607  char varname[SCIP_MAXSTRLEN];
608  char slackvarname[SCIP_MAXSTRLEN];
609  char consvarname[SCIP_MAXSTRLEN];
610 
611 #ifdef SCIP_STATISTIC
612  heurdata->norigvars++;
613 #endif
614 
615  varslack = 0.0;
616  lborig = SCIPvarGetLbGlobal(vars[i]);
617  uborig = SCIPvarGetUbGlobal(vars[i]);
618  value = SCIPgetSolVal(scip, sol, vars[i]);
619  vartype = SCIPvarGetType(vars[i]);
620 
621  nviolatedrows[i] = 0;
622 
623  /* if the value of x is lower than the variables lower bound, sets the slack to a correcting value */
624  if( heurdata->useslackvars && SCIPisFeasLT(scip, value, lborig) )
625  {
626  lb = value;
627  varslack = lborig - value;
628  }
629  else
630  {
631  lb = lborig;
632  }
633 
634  /* if the value of x is bigger than the variables upper bound, sets the slack to a correcting value */
635  if( heurdata->useslackvars && SCIPisFeasGT(scip, value, uborig) )
636  {
637  ub = value;
638  varslack = uborig - value;
639  }
640  else
641  {
642  ub = uborig;
643  }
644 
645  if( heurdata->useobjfactor )
646  {
647  objval = SCIPvarGetObj(vars[i])*factor;
648 
649  if( SCIPisZero(scip, objval) )
650  {
651  objval = 0.0;
652  }
653  }
654  else
655  {
656  objval = SCIPvarGetObj(vars[i]);
657  }
658 
659  /* if a binary variable is out of bound, generalize it to an integer variable */
660  if( !SCIPisFeasZero(scip, varslack) && SCIP_VARTYPE_BINARY == vartype )
661  {
662  vartype = SCIP_VARTYPE_INTEGER;
663  }
664 
665  (void) SCIPsnprintf(varname, SCIP_MAXSTRLEN, "sub_%s", SCIPvarGetName(vars[i]));
666 
667  /* Adds the sub representing variable to the sub-SCIP. */
668  SCIP_CALL( SCIPcreateVarBasic(subscip, &subvars[i], varname, lb, ub, objval, vartype) );
669  SCIP_CALL( SCIPaddVar(subscip, subvars[i]) );
670 
671  /* a trivial feasible solution can be constructed if violations are modeled with slack variables */
672  if( heurdata->useslackvars )
673  {
674  SCIP_CALL( SCIPsetSolVal(subscip, subsol, subvars[i], value) );
675  }
676 
677  /* if necessary adds a constraint to represent the original bounds of x.*/
678  if( !SCIPisFeasEQ(scip, varslack, 0.0) )
679  {
680  SCIP_VAR* newvar;
681  (void) SCIPsnprintf(slackvarname, SCIP_MAXSTRLEN, "artificialslack_%s", SCIPvarGetName(vars[i]));
682  (void) SCIPsnprintf(consvarname, SCIP_MAXSTRLEN, "boundcons_%s", SCIPvarGetName(vars[i]));
683 
684  /* initialize and add an artificial slack variable */
685  if( heurdata->useobjfactor )
686  {
687  SCIP_CALL( SCIPcreateVarBasic(subscip, &newvar, slackvarname, 0.0, 1.0, 1.0, SCIP_VARTYPE_CONTINUOUS));
688  }
689  else
690  {
691  SCIP_CALL( SCIPcreateVarBasic(subscip, &newvar, slackvarname, 0.0, 1.0, 1.0, SCIP_VARTYPE_BINARY));
692  }
693  SCIP_CALL( SCIPaddVar(subscip, newvar) );
694 
695  /* set the value of the slack variable to 1 to punish the use of it.
696  * note that a trivial feasible solution can be only constructed if violations are modeled with slack variables
697  */
698  if( heurdata->useslackvars )
699  {
700  SCIP_CALL( SCIPsetSolVal(subscip, subsol, newvar, 1.0) );
701  }
702 
703  /* adds a linear constraint to represent the old bounds */
704  SCIP_CALL( SCIPcreateConsBasicVarbound(subscip, &cons, consvarname, subvars[i], newvar, varslack, lb, ub) );
705  SCIP_CALL( SCIPaddCons(subscip, cons) );
706  SCIP_CALL( SCIPreleaseVar(subscip, &newvar) );
707  SCIP_CALL( SCIPreleaseCons(subscip, &cons) );
708 
709  /* increases the counter for violated vars */
710 #ifdef SCIP_STATISTIC
711  heurdata->nviolatedvars++;
712 #endif
713  }
714 
715 #ifdef SCIP_STATISTIC
716  if( SCIPisFeasLT(scip, value, lb) || SCIPisFeasGT(scip, value, ub) )
717  {
718  heurdata->nviolatedvars++;
719  }
720 #endif
721  if( SCIP_VARTYPE_BINARY == vartype || SCIP_VARTYPE_INTEGER == vartype )
722  {
723  ndiscvars++;
724  }
725  }
726 
727  /* check solution for feasibility regarding the LP rows (SCIPgetRowSolActivity()) */
728  rows = SCIPgetLPRows(scip);
729  nrows = SCIPgetNLPRows(scip);
730 
731  SCIP_CALL( SCIPallocBufferArray(scip, &potential, nrows) );
732  SCIP_CALL( SCIPallocBufferArray(scip, &slacks, nrows) );
733  SCIP_CALL( SCIPallocBufferArray(scip, &subcons, nrows) );
734  SCIP_CALL( SCIPallocBufferArray(scip, &inftycounter, nrows) );
735 
736  /* Adds all original constraints and computes potentials and slacks */
737  for (i = 0; i < nrows; ++i)
738  {
739  SCIP_COL** cols;
740  SCIP_VAR** consvars;
741  SCIP_Real* vals;
742  SCIP_Real constant;
743  SCIP_Real lhs;
744  SCIP_Real rhs;
745  SCIP_Real rowsolact;
746  int nnonz;
747  int j;
748 
749 #ifdef SCIP_STATISTIC
750  heurdata->norcons++;
751 #endif
752 
753  /* gets the values to check the constraint */
754  constant = SCIProwGetConstant(rows[i]);
755  lhs = SCIPisInfinity(scip, -SCIProwGetLhs(rows[i])) ? SCIProwGetLhs(rows[i]) : SCIProwGetLhs(rows[i]) - constant;
756  rhs = SCIPisInfinity(scip, SCIProwGetRhs(rows[i])) ? SCIProwGetRhs(rows[i]) : SCIProwGetRhs(rows[i]) - constant;
757  rowsolact = SCIPgetRowSolActivity(scip, rows[i], sol) - constant;
758  vals = SCIProwGetVals(rows[i]);
759  potential[i] = 0.0;
760  inftycounter[i] = 0;
761 
762  assert(SCIPisFeasLE(scip, lhs, rhs));
763 
764  nnonz = SCIProwGetNNonz(rows[i]);
765  cols = SCIProwGetCols(rows[i]);
766  SCIP_CALL( SCIPallocBufferArray(subscip, &consvars, nnonz) );
767 
768  /* sets the slack if its necessary */
769  if( SCIPisFeasLT(scip, rowsolact, lhs) )
770  {
771  slacks[i] = lhs - rowsolact;
772 #ifdef SCIP_STATISTIC
773  heurdata->nviolatedcons++;
774 #endif
775  }
776  else if( SCIPisFeasGT(scip, rowsolact, rhs) )
777  {
778  slacks[i] = rhs - rowsolact;
779 #ifdef SCIP_STATISTIC
780  heurdata->nviolatedcons++;
781 #endif
782  }
783  else
784  {
785  slacks[i] = 0.0;
786  }
787 
788  /* translate all variables from the original SCIP to the sub-SCIP with sub-SCIP variables. */
789  for( j = 0; j < nnonz; ++j )
790  {
791  SCIP_Real contribution;
792  int pos;
793  int sgn = 1;
794 
795  /* negative slack represents a right hand side violation */
796  if( SCIPisFeasGT(scip, 0.0, slacks[i]) )
797  {
798  assert(!SCIPisInfinity(scip, rhs));
799  sgn = -1;
800  }
801  #ifndef NDEBUG
802  else
803  assert(!SCIPisInfinity(scip, lhs));
804  #endif
805 
806  pos = SCIPvarGetProbindex(SCIPcolGetVar(cols[j]));
807  consvars[j] = subvars[pos];
808  assert(pos >= 0);
809 
810  /* compute potentials */
811  contribution = getPotentialContributed(scip, sol, vars[pos], vals[j], sgn);
812  if( !SCIPisInfinity(scip, REALABS(contribution)) )
813  {
814  potential[i] += contribution;
815  }
816  else
817  {
818  inftycounter[i]++;
819  }
820 
821  if( !SCIPisZero(scip, slacks[i]) )
822  {
823  nviolatedrows[pos]++;
824  }
825  }
826 
827  /* create a new linear constraint, representing the old one */
828  SCIP_CALL( SCIPcreateConsBasicLinear(subscip, &subcons[i], SCIProwGetName(rows[i]),
829  nnonz, consvars, vals, lhs, rhs) );
830 
831  if( heurdata->useslackvars )
832  {
833  SCIP_VAR* newvar;
834  char varname[SCIP_MAXSTRLEN];
835 
836  /*if necessary adds a new artificial slack variable*/
837  if( !SCIPisFeasEQ(subscip, slacks[i], 0.0) )
838  {
839  (void) SCIPsnprintf(varname, SCIP_MAXSTRLEN, "artificialslack_%s", SCIProwGetName(rows[i]));
840  SCIP_CALL( SCIPcreateVarBasic(subscip, &newvar, varname, 0.0, 1.0, 1.0, SCIP_VARTYPE_CONTINUOUS) );
841  SCIP_CALL( SCIPaddVar(subscip, newvar) );
842 
843  /* a trivial feasible solution can be constructed if violations are modeled with slack variables */
844  SCIP_CALL( SCIPsetSolVal(subscip, subsol, newvar, 1.0) );
845  SCIP_CALL( SCIPaddCoefLinear(subscip, subcons[i], newvar, slacks[i]) );
846  SCIP_CALL( SCIPreleaseVar(subscip, &newvar) );
847  }
848  }
849 
850  /*Adds the Constraint and release it.*/
851  SCIP_CALL( SCIPaddCons(subscip, subcons[i]) );
852  SCIP_CALL( SCIPreleaseCons(subscip, &subcons[i]) );
853  SCIPfreeBufferArray(subscip, &consvars);
854  }
855 
856  if( heurdata->usevarfix )
857  {
858  /* get the greedy order */
859  for( i = 0; i < nvars; ++i )
860  {
861  permutation[i] = i;
862  }
863  SCIPsortIntInt(nviolatedrows, permutation, nvars);
864 
865  /* loops over variables and greedily fix variables, but preserve the cover property that enough slack is given to
866  * violated rows
867  */
868  nfixeddiscvars = 0;
869  heurdata->nvarfixed = 0;
870  for( i = 0; i < nvars; ++i )
871  {
872  SCIP_Bool fixed;
873 
874  /* continue if we have a loose variable */
875  if( SCIPvarGetStatus(vars[permutation[i]]) != SCIP_VARSTATUS_COLUMN )
876  continue;
877 
878  SCIP_CALL( tryFixVar(scip, subscip, sol, potential, slacks, vars[permutation[i]], subvars[permutation[i]], inftycounter, heurdata, &fixed) );
879 
880  if( fixed && (SCIP_VARTYPE_BINARY == SCIPvarGetType(subvars[permutation[i]])
881  || SCIP_VARTYPE_INTEGER == SCIPvarGetType(subvars[permutation[i]])) )
882  {
883  nfixeddiscvars++;
884  }
885  }
886  SCIPdebugMsg(scip,"fixings finished\n\n");
887  if( heurdata->minfixingrate > ((SCIP_Real)nfixeddiscvars/MAX((SCIP_Real)ndiscvars,1.0)) )
888  {
889  goto TERMINATE;
890  }
891  }
892 
893  /* a trivial feasible solution can be constructed if violations are modeled with slack variables */
894  if( heurdata->useslackvars )
895  {
896  SCIP_CALL( SCIPaddSolFree(subscip, &subsol, &success) );
897 
898  if( !success )
899  {
900  SCIPdebugMsg(scip, "Initial repair solution was not accepted.\n");
901  }
902  }
903 
904 #ifdef SCIP_STATISTIC
905  if( heurdata->useslackvars )
906  heurdata->improvedoldsol = SCIPgetSolOrigObj(subscip, subsol);
907 #endif
908 
909  /* check whether there is enough time and memory left */
910  SCIP_CALL( SCIPgetRealParam(scip, "limits/time", &timelimit) );
911  if( !SCIPisInfinity(scip, timelimit) )
912  timelimit -= SCIPgetSolvingTime(scip);
913  SCIP_CALL( SCIPgetRealParam(scip, "limits/memory", &memorylimit) );
914  SCIP_CALL( SCIPgetBoolParam(scip, "misc/avoidmemout", &avoidmemout) );
915 
916  /* subtract the memory already used by the main SCIP and the estimated memory usage of external software */
917  if( !SCIPisInfinity(scip, memorylimit) )
918  {
919  memorylimit -= SCIPgetMemUsed(scip) / 1048576.0;
920  memorylimit -= SCIPgetMemExternEstim(scip) / 1048576.0;
921  }
922 
923  /* abort if no time is left or not enough memory (we don't abort in this case if misc_avoidmemout == FALSE)
924  * to create a copy of SCIP, including external memory usage */
925  if( timelimit <= 0.0 || (avoidmemout && memorylimit <= 2.0 * SCIPgetMemExternEstim(scip) / 1048576.0) )
926  goto TERMINATE;
927 
928  /* set limits for the subproblem */
929  SCIP_CALL( SCIPsetLongintParam(subscip, "limits/nodes", nnodes) );
930  SCIP_CALL( SCIPsetRealParam(subscip, "limits/time", timelimit) );
931  SCIP_CALL( SCIPsetRealParam(subscip, "limits/memory", memorylimit) );
932  SCIP_CALL( SCIPsetObjlimit(subscip,1.0) );
933 
934  /* forbid recursive call of heuristics and separators solving sub-SCIPs */
935  SCIP_CALL( SCIPsetSubscipsOff(subscip, TRUE) );
936 
937  /* disable output to console */
938  SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", (int)SCIP_VERBLEVEL_NONE) );
939 
940 #ifdef SCIP_DEBUG
941  /* for debugging Repair, enable MIP output */
942  SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", (int)SCIP_VERBLEVEL_FULL) );
943  SCIP_CALL( SCIPsetIntParam(subscip, "display/freq", -1) );
944 #endif
945 
946  /* solve the subproblem */
947  retcode = SCIPsolve(subscip);
948 
949  /* errors in sub-SCIPs should not kill the overall solving process. Hence, we print a warning message. Only
950  * in debug mode, SCIP will stop
951  */
952  if( retcode != SCIP_OKAY )
953  {
954  SCIPwarningMessage(scip, "Error while solving subproblem in REPAIR heuristic; sub-SCIP terminated with code <%d>\n", retcode);
955  SCIPABORT(); /*lint --e{527}*/
956  goto TERMINATE;
957  }
958 
959  success = FALSE;
960 
961  /* if a solution is found, save its value and create a new solution instance for the original SCIP */
962  if( SCIPgetBestSol(subscip) != NULL )
963  {
964 #ifdef SCIP_STATISTIC
965  heurdata->improvedoldsol = SCIPgetSolOrigObj(subscip, SCIPgetBestSol(subscip));
966 #endif
967  /* print solving statistics of subproblem if we are in SCIP's debug mode */
969 
970  assert(SCIPgetNSols(subscip) > 0);
971  SCIP_CALL( createNewSol(scip, subscip, subvars, heur, SCIPgetBestSol(subscip), &success) );
972 
973  if( success )
974  {
975  *result = SCIP_FOUNDSOL;
976  }
977  }
978  else
979  {
980  SCIPdebugMsg(scip,"No solution found!\n");
981  }
982 
983  if( SCIPgetStage(subscip) >= SCIP_STAGE_SOLVED )
984  {
985  heurdata->subiters = SCIPgetNLPIterations(subscip);
986  heurdata->subnodes = SCIPgetNTotalNodes(subscip);
987 #ifdef SCIP_STATISTIC
988  heurdata->subpresoltime = SCIPgetPresolvingTime(subscip);
989 #endif
990  heurdata->runs = SCIPgetNRuns(subscip);
991  }
992 
993  /* terminates the solving process */
994 TERMINATE:
995  if( NULL != sol )
996  {
997  SCIP_CALL( SCIPfreeSol(scip, &sol) );
998  }
999  SCIPfreeBufferArrayNull(scip, &nviolatedrows);
1000  for( i = 0; i < nvars; ++i )
1001  {
1002  SCIP_CALL( SCIPreleaseVar(subscip, &subvars[i]) );
1003  }
1004  SCIPfreeBufferArrayNull(scip, &inftycounter);
1005  SCIPfreeBufferArrayNull(scip, &subcons);
1006  SCIPfreeBufferArrayNull(scip, &slacks);
1007  SCIPfreeBufferArrayNull(scip, &potential);
1008  SCIPfreeBufferArrayNull(scip, &permutation);
1009  SCIPfreeBufferArrayNull(scip, &subvars);
1010 
1011  if( NULL != subsol )
1012  {
1013  SCIP_CALL( SCIPfreeSol(subscip, &subsol) );
1014  }
1015 
1016  SCIP_CALL( SCIPfree(&subscip) );
1017 
1018  SCIPdebugMsg(scip, "repair finished\n");
1019  return SCIP_OKAY;
1020 }
1021 
1022 
1023 /*
1024  * Callback methods of primal heuristic
1025  */
1026 
1027 /** destructor of primal heuristic to free user data (called when SCIP is exiting) */
1028 static
1029 SCIP_DECL_HEURFREE(heurFreeRepair)
1030 { /*lint --e{715}*/
1031  SCIP_HEURDATA* heurdata;
1032 
1033  heurdata = SCIPheurGetData(heur);
1035  assert(heurdata != NULL);
1036  SCIPfreeMemory(scip, &heurdata);
1037 
1038  SCIPheurSetData(heur, NULL);
1039 
1040  return SCIP_OKAY;
1041 }
1042 
1043 
1044 /** initialization method of primal heuristic (called after problem was transformed) */
1045 static
1046 SCIP_DECL_HEURINIT(heurInitRepair)
1047 { /*lint --e{715}*/
1048  SCIP_HEURDATA* heurdata;
1049 
1050  heurdata = SCIPheurGetData(heur);
1052  heurdata->subiters = -1;
1053  heurdata->subnodes = -1;
1054  heurdata->runs = 0;
1055 
1056  heurdata->nvarfixed = 0;
1057  heurdata->relvarfixed = -1;
1058 
1059 #ifdef SCIP_STATISTIC
1060  heurdata->subpresoltime = 0;
1061 
1062  heurdata->nviolatedvars = 0;
1063  heurdata->norigvars = 0;
1064  heurdata->relviolatedvars = 0;
1065  heurdata->nviolatedcons = 0;
1066  heurdata->norcons = 0;
1067  heurdata->relviolatedcons = 0;
1068 
1069  heurdata->originalsolval = SCIP_INVALID;
1070 
1071  heurdata->improvedoldsol = SCIP_UNKNOWN;
1072 #endif
1073 
1074  heurdata->usednodes = 0;
1075 
1076  return SCIP_OKAY;
1077 }
1078 
1079 
1080 /** deinitialization method of primal heuristic (called before transformed problem is freed) */
1081 static
1082 SCIP_DECL_HEUREXIT(heurExitRepair)
1083 { /*lint --e{715}*/
1084 #ifdef SCIP_STATISTIC
1085  SCIP_HEURDATA* heurdata;
1086  SCIP_Real time;
1087  SCIP_Real relvars;
1088  SCIP_Real relcons;
1089  SCIP_Real relfixed;
1090  char solval[SCIP_MAXSTRLEN];
1091  int violateds;
1092  int ninvars;
1093  int ninvcons;
1094  int nvars;
1095  int ncons;
1096  int iterations;
1097  int nodes;
1098  int runs;
1099 
1100  heurdata = SCIPheurGetData(heur);
1101  violateds = heurdata->nviolatedvars+heurdata->nviolatedcons;
1102  ninvars = heurdata->nviolatedvars;
1103  ninvcons = heurdata->nviolatedcons;
1104  nvars = heurdata->norigvars;
1105  ncons = heurdata->norcons;
1106  iterations = heurdata->subiters;
1107  nodes = heurdata->subnodes;
1108  time = heurdata->subpresoltime;
1109  runs = heurdata->runs;
1110 
1111  if( SCIP_INVALID == heurdata->originalsolval )
1112  {
1113  (void) SCIPsnprintf(solval, SCIP_MAXSTRLEN ,"--");
1114  }
1115  else
1116  {
1117  (void) SCIPsnprintf(solval, SCIP_MAXSTRLEN, "%15.9g", heurdata->originalsolval);
1118  }
1119 
1120  heurdata->relviolatedvars = MAX((SCIP_Real)heurdata->norigvars, 1.0);
1121  heurdata->relviolatedvars = heurdata->nviolatedvars/heurdata->relviolatedvars;
1122  heurdata->relviolatedcons = MAX((SCIP_Real)heurdata->norcons, 1.0);
1123  heurdata->relviolatedcons = heurdata->nviolatedcons/heurdata->relviolatedcons;
1124 
1125  heurdata->relvarfixed = MAX((SCIP_Real)heurdata->norigvars, 1.0);
1126  heurdata->relvarfixed = heurdata->nvarfixed/heurdata->relvarfixed;
1127  relvars = heurdata->relviolatedvars;
1128  relcons = heurdata->relviolatedcons;
1129  relfixed = heurdata->relvarfixed;
1130 
1131  /* prints all statistic data for a user*/
1132  SCIPstatistic(
1133  SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, "<repair> \n total violations : %10d\n", violateds);
1134  SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, " violated variables : %10d\n", ninvars);
1135  SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, " total variables : %10d\n", nvars);
1136  SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, " relative violated variables : %10.2f%%\n", 100 * relvars);
1137  SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, " violated constraints : %10d\n", ninvcons);
1138  SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, " total constraints : %10d\n", ncons);
1139  SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, " relative violated constraints: %10.2f%%\n", 100* relcons);
1140  SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, " fixed variables : %10d\n", heurdata->nvarfixed);
1141  SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, " relative fixed variables : %10.2f%%\n\n", 100* relfixed);
1142  SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, " iterations : %10d\n", iterations);
1143  SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, " nodes : %10d\n", nodes);
1144  SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, " number of runs : %10d\n", runs);
1145  SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, " presolve time : %10.2f\n", time);
1146  SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, "</repair>\n\n");
1147  SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, " value of best solution : %10g\n", solval);
1148  SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, " improved orig. solval : %10g\n", heurdata->improvedoldsol);
1149  )
1150 
1151 #endif
1152  return SCIP_OKAY;
1153 }
1154 
1155 /** execution method of primal heuristic. Repair needs an incorrect solution, in which all variables are in their bound. */
1156 static
1157 SCIP_DECL_HEUREXEC(heurExecRepair)
1158 { /*lint --e{715}*/
1159  SCIP_HEURDATA* heurdata;
1160  SCIP_RETCODE retcode;
1161  SCIP_Bool success;
1162  SCIP_Bool error;
1164 
1165  heurdata = SCIPheurGetData(heur);
1166  SCIPdebugMsg(scip, "%s\n", heurdata->filename);
1167 
1168  /* checks the result pointer */
1169  assert(result != NULL);
1170  *result = SCIP_DIDNOTRUN;
1171 
1172  /* if repair already ran or neither variable fixing nor slack variables are enabled, stop */
1173  if( 0 < SCIPheurGetNCalls(heur) || !(heurdata->usevarfix || heurdata->useslackvars) )
1174  return SCIP_OKAY;
1175 
1176  /* do not run if the neither the LP is constructed nor a user given solution exists */
1177  if( SCIPgetLPSolstat(scip) != SCIP_LPSOLSTAT_OPTIMAL && strcmp(heurdata->filename, DEFAULT_FILENAME) == 0 )
1178  return SCIP_OKAY;
1179 
1180  /* calculate the maximal number of branching nodes until heuristic is aborted */
1181  nnodes = (SCIP_Longint)(heurdata->nodesquot * SCIPgetNNodes(scip));
1182 
1183  /* reward REPAIR if it succeeded often */
1184  nnodes = (SCIP_Longint)(nnodes * 3.0 * (SCIPheurGetNBestSolsFound(heur)+1.0)/(SCIPheurGetNCalls(heur) + 1.0));
1185  nnodes -= (SCIP_Longint)(100.0 * SCIPheurGetNCalls(heur)); /* count the setup costs for the sub-MIP as 100 nodes */
1186  nnodes += heurdata->nodesofs;
1187 
1188  /* determine the node limit for the current process */
1189  nnodes -= heurdata->usednodes;
1190  nnodes = MIN(nnodes, heurdata->maxnodes);
1191 
1192  /* check whether we have enough nodes left to call subproblem solving */
1193  if( nnodes < heurdata->minnodes )
1194  return SCIP_OKAY;
1195 
1196  if( !SCIPhasCurrentNodeLP(scip) )
1197  return SCIP_OKAY;
1198 
1199  if( !SCIPisLPConstructed(scip) )
1200  {
1201  SCIP_Bool cutoff;
1202 
1203  SCIP_CALL( SCIPconstructLP(scip, &cutoff) );
1204 
1205  /* manually cut off the node if the LP construction detected infeasibility (heuristics cannot return such a result) */
1206  if( cutoff )
1207  {
1209  return SCIP_OKAY;
1210  }
1211  }
1212 
1213  /* create original solution */
1214  SCIP_CALL( SCIPcreateOrigSol(scip, &(heurdata->infsol), heur) );
1215 
1216  /* use read method to enter solution from a file */
1217  if( strcmp(heurdata->filename, DEFAULT_FILENAME) == 0 )
1218  {
1219  retcode = SCIPlinkLPSol(scip, heurdata->infsol);
1220  }
1221  else
1222  {
1223  error = FALSE;
1224  retcode = SCIPreadSolFile(scip, heurdata->filename, heurdata->infsol, FALSE, NULL, &error);
1225  }
1226 
1227  if( SCIP_NOFILE == retcode )
1228  {
1229  assert(strcmp(heurdata->filename, DEFAULT_FILENAME) != 0);
1230  SCIPwarningMessage(scip, "cannot open file <%s> for reading\n", heurdata->filename);
1231 
1232  SCIP_CALL( SCIPfreeSol(scip, &(heurdata->infsol)) );
1233  return SCIP_OKAY;
1234  }
1235  else if( retcode != SCIP_OKAY )
1236  {
1237  SCIPwarningMessage(scip, "cannot run repair, unknown return status <%d>\n", retcode);
1238  SCIP_CALL( SCIPfreeSol(scip, &(heurdata->infsol)) );
1239  return SCIP_OKAY;
1240  }
1241  SCIPdebugMsg(scip, "Repair: Solution file read.\n");
1242 
1243  /* checks the integrality of all discrete variable */
1244  SCIP_CALL( checkCands(scip, heurdata->infsol, heurdata->roundit, &success) );
1245  if( !success )
1246  {
1247  SCIPdebugMsg(scip,"Given solution is not integral, repair terminates.\n");
1248  SCIP_CALL( SCIPfreeSol(scip, &(heurdata->infsol)) );
1249  return SCIP_OKAY;
1250  }
1251 
1252  *result = SCIP_DIDNOTFIND;
1253 
1254  SCIP_CALL( SCIPtrySol(scip, heurdata->infsol, FALSE, FALSE, TRUE, TRUE, TRUE, &success) );
1255 
1256  /* the solution is not feasible for the original problem; we will try to repair it */
1257  if( !success )
1258  {
1259  assert(NULL != heurdata->infsol);
1260  assert(heurdata->usevarfix || heurdata->useslackvars);
1261  SCIP_CALL( applyRepair(scip, heur, result, nnodes) );
1262  }
1263  else
1264  {
1265  SCIP_CALL( SCIPfreeSol(scip, &(heurdata->infsol)) );
1266  }
1267 
1268  return SCIP_OKAY;
1269 }
1270 
1271 /* primal heuristic specific interface methods */
1272 
1273 /** creates the repair primal heuristic and includes it in SCIP */
1275  SCIP* scip /**< SCIP data structure */
1276  )
1277 {
1278  SCIP_HEURDATA* heurdata;
1279  SCIP_HEUR* heur;
1280 
1281  /* create repair primal heuristic data */
1282  heurdata = NULL;
1283 
1284  SCIP_CALL( SCIPallocMemory(scip ,&heurdata) );
1285 
1286  heur = NULL;
1287 
1288  /* include primal heuristic */
1289  SCIP_CALL( SCIPincludeHeurBasic(scip, &heur,
1291  HEUR_MAXDEPTH, HEUR_TIMING, HEUR_USESSUBSCIP, heurExecRepair, heurdata) );
1292 
1293  assert(heur != NULL);
1294  assert(heurdata != NULL);
1295 
1296  /* set non fundamental callbacks via setter functions */
1297  SCIP_CALL( SCIPsetHeurFree(scip, heur, heurFreeRepair) );
1298  SCIP_CALL( SCIPsetHeurInit(scip, heur, heurInitRepair) );
1299  SCIP_CALL( SCIPsetHeurExit(scip, heur, heurExitRepair) );
1300 
1301  /* add repair primal heuristic parameters */
1302 
1303  heurdata->filename = NULL;
1304  /* add string parameter for filename containing a solution */
1305  SCIP_CALL( SCIPaddStringParam(scip, "heuristics/" HEUR_NAME "/filename",
1306  "file name of a solution to be used as infeasible starting point, [-] if not available",
1307  &heurdata->filename, FALSE, DEFAULT_FILENAME, NULL, NULL) );
1308 
1309  /* add bool parameter for decision how to deal with unfractional cands */
1310  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/" HEUR_NAME "/roundit",
1311  "True : fractional variables which are not fractional in the given solution are rounded, "
1312  "FALSE : solving process of this heuristic is stopped. ",
1313  &heurdata->roundit, FALSE, DEFAULT_ROUNDIT, NULL, NULL));
1314 
1315  /* add bool parameter for decision how the objective function should be */
1316  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/" HEUR_NAME "/useobjfactor",
1317  "should a scaled objective function for original variables be used in repair subproblem?",
1318  &heurdata->useobjfactor, FALSE, DEFAULT_USEOBJFACTOR, NULL, NULL));
1319 
1320  /* add bool parameter for decision if variable fixings should be used */
1321  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/" HEUR_NAME "/usevarfix",
1322  "should variable fixings be used in repair subproblem?",
1323  &heurdata->usevarfix, FALSE, DEFAULT_USEVARFIX, NULL, NULL));
1324 
1325  /* add bool parameter for decision how the objective function should be */
1326  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/" HEUR_NAME "/useslackvars",
1327  "should slack variables be used in repair subproblem?",
1328  &heurdata->useslackvars, FALSE, DEFAULT_USESLACKVARS, NULL, NULL));
1329 
1330  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/alpha", "factor for the potential of var fixings",
1331  &heurdata->alpha, TRUE, DEFAULT_ALPHA, 0.0, 100.00, NULL, NULL) );
1332 
1333  SCIP_CALL( SCIPaddIntParam(scip, "heuristics/" HEUR_NAME "/nodesofs",
1334  "number of nodes added to the contingent of the total nodes",
1335  &heurdata->nodesofs, FALSE, DEFAULT_NODESOFS, 0, INT_MAX, NULL, NULL) );
1336 
1337  SCIP_CALL( SCIPaddIntParam(scip, "heuristics/" HEUR_NAME "/maxnodes",
1338  "maximum number of nodes to regard in the subproblem",
1339  &heurdata->maxnodes, TRUE, DEFAULT_MAXNODES, 0, INT_MAX, NULL, NULL) );
1340 
1341  SCIP_CALL( SCIPaddIntParam(scip, "heuristics/" HEUR_NAME "/minnodes",
1342  "minimum number of nodes required to start the subproblem",
1343  &heurdata->minnodes, TRUE, DEFAULT_MINNODES, 0, INT_MAX, NULL, NULL) );
1344 
1345  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/nodesquot",
1346  "contingent of sub problem nodes in relation to the number of nodes of the original problem",
1347  &heurdata->nodesquot, FALSE, DEFAULT_NODESQUOT, 0.0, 1.0, NULL, NULL) );
1348 
1349  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/minfixingrate",
1350  "minimum percentage of integer variables that have to be fixed",
1351  &heurdata->minfixingrate, FALSE, DEFAULT_MINFIXINGRATE, 0.0, 1.0, NULL, NULL) );
1352 
1353  return SCIP_OKAY;
1354 }
enum SCIP_Result SCIP_RESULT
Definition: type_result.h:52
SCIP_ROW ** SCIPgetLPRows(SCIP *scip)
Definition: scip_lp.c:596
SCIP_Bool SCIPisFeasZero(SCIP *scip, SCIP_Real val)
static SCIP_DECL_HEUREXIT(heurExitRepair)
Definition: heur_repair.c:1087
SCIP_RETCODE SCIPlinkLPSol(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:1017
SCIP_Real SCIPgetSolvingTime(SCIP *scip)
Definition: scip_timing.c:369
SCIP_Bool SCIPisFeasEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
public methods for SCIP parameter handling
int SCIPvarGetNLocksDownType(SCIP_VAR *var, SCIP_LOCKTYPE locktype)
Definition: var.c:3289
#define HEUR_DISPCHAR
Definition: heur_repair.c:64
SCIP_NODE * SCIPgetCurrentNode(SCIP *scip)
Definition: scip_tree.c:82
SCIP_STAGE SCIPgetStage(SCIP *scip)
Definition: scip_general.c:356
SCIP_RETCODE SCIPincludeHeurRepair(SCIP *scip)
Definition: heur_repair.c:1279
SCIP_Longint SCIPgetNLPIterations(SCIP *scip)
static SCIP_RETCODE createNewSol(SCIP *scip, SCIP *subscip, SCIP_VAR **subvars, SCIP_HEUR *heur, SCIP_SOL *subsol, SCIP_Bool *success)
Definition: heur_repair.c:485
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)
Constraint handler for variable bound constraints .
public methods for memory management
static SCIP_Real getPotentialContributed(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var, SCIP_Real coefficient, int sgn)
Definition: heur_repair.c:224
SCIP_RETCODE SCIPaddOrigObjoffset(SCIP *scip, SCIP_Real addval)
Definition: scip_prob.c:1289
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
Definition: var.c:17910
SCIP_RETCODE SCIPgetRealParam(SCIP *scip, const char *name, SCIP_Real *value)
Definition: scip_param.c:298
#define SCIP_MAXSTRLEN
Definition: def.h:293
int SCIPvarGetNLocksUpType(SCIP_VAR *var, SCIP_LOCKTYPE locktype)
Definition: var.c:3347
SCIP_Longint SCIPheurGetNBestSolsFound(SCIP_HEUR *heur)
Definition: heur.c:1587
SCIP_RETCODE SCIPaddSolFree(SCIP *scip, SCIP_SOL **sol, SCIP_Bool *stored)
Definition: scip_sol.c:3015
SCIP_RETCODE SCIPcreateProb(SCIP *scip, const char *name, SCIP_DECL_PROBDELORIG((*probdelorig)), SCIP_DECL_PROBTRANS((*probtrans)), SCIP_DECL_PROBDELTRANS((*probdeltrans)), SCIP_DECL_PROBINITSOL((*probinitsol)), SCIP_DECL_PROBEXITSOL((*probexitsol)), SCIP_DECL_PROBCOPY((*probcopy)), SCIP_PROBDATA *probdata)
Definition: scip_prob.c:108
SCIP_Real * SCIPcolGetVals(SCIP_COL *col)
Definition: lp.c:17094
SCIP_RETCODE SCIPsetHeurExit(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEUREXIT((*heurexit)))
Definition: scip_heur.c:201
int SCIProwGetNNonz(SCIP_ROW *row)
Definition: lp.c:17146
#define DEFAULT_USEOBJFACTOR
Definition: heur_repair.c:86
public solving methods
public methods for timing
const char * SCIProwGetName(SCIP_ROW *row)
Definition: lp.c:17284
SCIP_RETCODE SCIPreleaseVar(SCIP *scip, SCIP_VAR **var)
Definition: scip_var.c:1245
static SCIP_DECL_HEURINIT(heurInitRepair)
Definition: heur_repair.c:1051
SCIP_RETCODE SCIPgetVarsData(SCIP *scip, SCIP_VAR ***vars, int *nvars, int *nbinvars, int *nintvars, int *nimplvars, int *ncontvars)
Definition: scip_prob.c:1865
SCIP_Real SCIProwGetLhs(SCIP_ROW *row)
Definition: lp.c:17225
#define FALSE
Definition: def.h:87
SCIP_RETCODE SCIPcutoffNode(SCIP *scip, SCIP_NODE *node)
Definition: scip_tree.c:425
SCIP_Real SCIPinfinity(SCIP *scip)
int SCIPsnprintf(char *t, int len, const char *s,...)
Definition: misc.c:10755
#define TRUE
Definition: def.h:86
#define SCIPdebug(x)
Definition: pub_message.h:84
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:54
SCIP_BRANCHRULE * SCIPfindBranchrule(SCIP *scip, const char *name)
Definition: scip_branch.c:288
SCIP_RETCODE SCIPtranslateSubSol(SCIP *scip, SCIP *subscip, SCIP_SOL *subsol, SCIP_HEUR *heur, SCIP_VAR **subvars, SCIP_SOL **newsol)
Definition: scip_copy.c:1399
int SCIPvarGetProbindex(SCIP_VAR *var)
Definition: var.c:17600
SCIP_RETCODE SCIPcreateVarBasic(SCIP *scip, SCIP_VAR **var, const char *name, SCIP_Real lb, SCIP_Real ub, SCIP_Real obj, SCIP_VARTYPE vartype)
Definition: scip_var.c:185
static SCIP_RETCODE applyRepair(SCIP *scip, SCIP_HEUR *heur, SCIP_RESULT *result, SCIP_Longint nnodes)
Definition: heur_repair.c:523
struct SCIP_HeurData SCIP_HEURDATA
Definition: type_heur.h:67
public methods for problem variables
SCIP_RETCODE SCIPincludeHeurBasic(SCIP *scip, SCIP_HEUR **heur, const char *name, const char *desc, char dispchar, int priority, int freq, int freqofs, int maxdepth, SCIP_HEURTIMING timingmask, SCIP_Bool usessubscip, SCIP_DECL_HEUREXEC((*heurexec)), SCIP_HEURDATA *heurdata)
Definition: scip_heur.c:108
SCIP_RETCODE SCIPaddStringParam(SCIP *scip, const char *name, const char *desc, char **valueptr, SCIP_Bool isadvanced, const char *defaultvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip_param.c:185
SCIP_RETCODE SCIPconstructLP(SCIP *scip, SCIP_Bool *cutoff)
Definition: scip_lp.c:115
#define SCIPfreeBufferArray(scip, ptr)
Definition: scip_mem.h:127
SCIP_RETCODE SCIPcreate(SCIP **scip)
Definition: scip_general.c:283
void SCIPheurSetData(SCIP_HEUR *heur, SCIP_HEURDATA *heurdata)
Definition: heur.c:1362
public methods for SCIP variables
SCIP_RETCODE SCIPcreateConsBasicVarbound(SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_VAR *var, SCIP_VAR *vbdvar, SCIP_Real vbdcoef, SCIP_Real lhs, SCIP_Real rhs)
SCIP_RETCODE SCIPsetRealParam(SCIP *scip, const char *name, SCIP_Real value)
Definition: scip_param.c:594
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
Definition: scip_message.c:111
#define SCIPdebugMsg
Definition: scip_message.h:69
SCIP_RETCODE SCIPaddIntParam(SCIP *scip, const char *name, const char *desc, int *valueptr, SCIP_Bool isadvanced, int defaultvalue, int minvalue, int maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip_param.c:74
static SCIP_RETCODE checkCands(SCIP *scip, SCIP_SOL *sol, SCIP_Bool roundit, SCIP_Bool *success)
Definition: heur_repair.c:404
SCIP_RETCODE SCIPcopyParamSettings(SCIP *sourcescip, SCIP *targetscip)
Definition: scip_copy.c:2550
SCIP_Real SCIPgetPresolvingTime(SCIP *scip)
Definition: scip_timing.c:433
SCIP_RETCODE SCIPprintStatistics(SCIP *scip, FILE *file)
SCIP_RETCODE SCIPaddCoefLinear(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real val)
SCIP_RETCODE SCIPcreateOrigSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip_sol.c:556
public methods for numerical tolerances
public methods for querying solving statistics
const char * SCIPgetProbName(SCIP *scip)
Definition: scip_prob.c:1066
public methods for the branch-and-bound tree
SCIP_Bool SCIPisLPConstructed(SCIP *scip)
Definition: scip_lp.c:92
#define DEFAULT_MINFIXINGRATE
Definition: heur_repair.c:71
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
Definition: var.c:17920
SCIP_RETCODE SCIPsolve(SCIP *scip)
Definition: scip_solve.c:2613
#define HEUR_TIMING
Definition: heur_repair.c:69
SCIP_Bool SCIPisParamFixed(SCIP *scip, const char *name)
Definition: scip_param.c:210
SCIP_RETCODE SCIPaddCons(SCIP *scip, SCIP_CONS *cons)
Definition: scip_prob.c:2769
void SCIPsortIntInt(int *intarray1, int *intarray2, int len)
SCIP_RETCODE SCIPsetHeurFree(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURFREE((*heurfree)))
Definition: scip_heur.c:169
SCIP_ROW ** SCIPcolGetRows(SCIP_COL *col)
Definition: lp.c:17084
#define DEFAULT_USEVARFIX
Definition: heur_repair.c:91
#define SCIPfreeBufferArrayNull(scip, ptr)
Definition: scip_mem.h:128
#define DEFAULT_MAXNODES
Definition: heur_repair.c:74
const char * SCIPvarGetName(SCIP_VAR *var)
Definition: var.c:17251
SCIP_RETCODE SCIPgetBoolParam(SCIP *scip, const char *name, SCIP_Bool *value)
Definition: scip_param.c:241
#define DEFAULT_USESLACKVARS
Definition: heur_repair.c:92
#define NULL
Definition: lpi_spx1.cpp:155
#define REALABS(x)
Definition: def.h:201
int SCIPgetNLPRows(SCIP *scip)
Definition: scip_lp.c:617
public methods for problem copies
#define HEUR_DESC
Definition: heur_repair.c:63
#define DEFAULT_ALPHA
Definition: heur_repair.c:93
#define SCIP_CALL(x)
Definition: def.h:384
SCIP_Real SCIPgetLowerbound(SCIP *scip)
SCIP_Longint SCIPgetNTotalNodes(SCIP *scip)
SCIP_Bool SCIPisFeasGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisFeasLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Real SCIProwGetRhs(SCIP_ROW *row)
Definition: lp.c:17235
void SCIPverbMessage(SCIP *scip, SCIP_VERBLEVEL msgverblevel, FILE *file, const char *formatstr,...)
Definition: scip_message.c:216
SCIP_Longint SCIPheurGetNCalls(SCIP_HEUR *heur)
Definition: heur.c:1567
#define HEUR_FREQ
Definition: heur_repair.c:66
SCIP_COL ** SCIProwGetCols(SCIP_ROW *row)
Definition: lp.c:17171
repair primal heuristic
SCIP_Bool SCIPhasCurrentNodeLP(SCIP *scip)
Definition: scip_lp.c:74
public methods for primal heuristic plugins and divesets
public methods for constraint handler plugins and constraints
#define SCIPallocBufferArray(scip, ptr, num)
Definition: scip_mem.h:115
#define SCIP_UNKNOWN
Definition: def.h:198
SCIP_RETCODE SCIPsetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var, SCIP_Real val)
Definition: scip_sol.c:1212
SCIP_Real * SCIProwGetVals(SCIP_ROW *row)
Definition: lp.c:17181
public data structures and miscellaneous methods
#define DEFAULT_NODESQUOT
Definition: heur_repair.c:76
#define SCIP_Bool
Definition: def.h:84
SCIP_RETCODE SCIPincludeDefaultPlugins(SCIP *scip)
SCIP_LPSOLSTAT SCIPgetLPSolstat(SCIP *scip)
Definition: scip_lp.c:159
SCIP_RETCODE SCIPsetObjlimit(SCIP *scip, SCIP_Real objlimit)
Definition: scip_prob.c:1421
#define MAX(x, y)
Definition: tclique_def.h:83
SCIP_RETCODE SCIPtrySolFree(SCIP *scip, SCIP_SOL **sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored)
Definition: scip_sol.c:3231
SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value)
Definition: scip_param.c:478
public methods for LP management
SCIP_RETCODE SCIPfreeSol(SCIP *scip, SCIP_SOL **sol)
Definition: scip_sol.c:976
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
Definition: var.c:17758
int SCIPgetNSols(SCIP *scip)
Definition: scip_sol.c:2205
#define HEUR_PRIORITY
Definition: heur_repair.c:65
SCIP_RETCODE SCIPfixVar(SCIP *scip, SCIP_VAR *var, SCIP_Real fixedval, SCIP_Bool *infeasible, SCIP_Bool *fixed)
Definition: scip_var.c:8273
int SCIPgetNRuns(SCIP *scip)
SCIP_COL * SCIPvarGetCol(SCIP_VAR *var)
Definition: var.c:17621
SCIP_Real SCIPgetSolOrigObj(SCIP *scip, SCIP_SOL *sol)
Definition: scip_sol.c:1435
Constraint handler for linear constraints in their most general form, .
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
SCIP_Real SCIPgetRowSolActivity(SCIP *scip, SCIP_ROW *row, SCIP_SOL *sol)
Definition: scip_lp.c:2129
SCIP_RETCODE SCIPtrySol(SCIP *scip, SCIP_SOL *sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored)
Definition: scip_sol.c:3125
static SCIP_DECL_HEURFREE(heurFreeRepair)
Definition: heur_repair.c:1034
public methods for the LP relaxation, rows and columns
#define DEFAULT_MINNODES
Definition: heur_repair.c:75
#define SCIPfreeMemory(scip, ptr)
Definition: scip_mem.h:69
methods for sorting joint arrays of various types
#define DEFAULT_NODESOFS
Definition: heur_repair.c:73
SCIP_Real SCIProwGetConstant(SCIP_ROW *row)
Definition: lp.c:17191
public methods for branching rule plugins and branching
#define HEUR_MAXDEPTH
Definition: heur_repair.c:68
#define HEUR_FREQOFS
Definition: heur_repair.c:67
general public methods
SCIP_RETCODE SCIPreadSolFile(SCIP *scip, const char *filename, SCIP_SOL *sol, SCIP_Bool xml, SCIP_Bool *partial, SCIP_Bool *error)
Definition: scip_sol.c:2885
SCIP_SOL * SCIPgetBestSol(SCIP *scip)
Definition: scip_sol.c:2304
SCIP_Bool SCIPisGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
#define DEFAULT_ROUNDIT
Definition: heur_repair.c:79
SCIP_VAR * SCIPcolGetVar(SCIP_COL *col)
Definition: lp.c:16975
public methods for solutions
SCIP_Longint SCIPgetMemUsed(SCIP *scip)
Definition: scip_mem.c:91
SCIP_RETCODE SCIPaddVar(SCIP *scip, SCIP_VAR *var)
Definition: scip_prob.c:1667
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
Definition: scip_cons.c:1110
static SCIP_RETCODE getObjectiveFactor(SCIP *scip, SCIP *subscip, SCIP_Real *factor, SCIP_Bool *success)
Definition: heur_repair.c:148
public methods for message output
SCIP_RETCODE SCIPsetHeurInit(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURINIT((*heurinit)))
Definition: scip_heur.c:185
SCIP_Longint SCIPgetMemExternEstim(SCIP *scip)
Definition: scip_mem.c:117
SCIP_VARSTATUS SCIPvarGetStatus(SCIP_VAR *var)
Definition: var.c:17370
#define HEUR_USESSUBSCIP
Definition: heur_repair.c:70
int SCIProwGetLPPos(SCIP_ROW *row)
Definition: lp.c:17434
#define SCIPstatistic(x)
Definition: pub_message.h:111
#define SCIP_Real
Definition: def.h:177
public methods for message handling
#define SCIP_INVALID
Definition: def.h:197
#define HEUR_NAME
Definition: heur_repair.c:62
#define DEFAULT_FILENAME
Definition: heur_repair.c:78
#define SCIP_Longint
Definition: def.h:162
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
Definition: var.c:17416
static DPSUBSOL ** subsol
static SCIP_RETCODE tryFixVar(SCIP *scip, SCIP *subscip, SCIP_SOL *sol, SCIP_Real *potential, SCIP_Real *slack, SCIP_VAR *var, SCIP_VAR *subvar, int *inftycounter, SCIP_HEURDATA *heurdata, SCIP_Bool *fixed)
Definition: heur_repair.c:271
#define SCIPallocMemory(scip, ptr)
Definition: scip_mem.h:51
SCIP_Bool SCIPisZero(SCIP *scip, SCIP_Real val)
enum SCIP_Vartype SCIP_VARTYPE
Definition: type_var.h:60
static SCIP_DECL_HEUREXEC(heurExecRepair)
Definition: heur_repair.c:1162
#define nnodes
Definition: gastrans.c:65
SCIP_Bool SCIPisFeasIntegral(SCIP *scip, SCIP_Real val)
SCIP_Real SCIPgetUpperbound(SCIP *scip)
public methods for primal heuristics
SCIP_Real SCIPceil(SCIP *scip, SCIP_Real val)
SCIP_HEURDATA * SCIPheurGetData(SCIP_HEUR *heur)
Definition: heur.c:1352
SCIP_Longint SCIPgetNNodes(SCIP *scip)
#define SCIPABORT()
Definition: def.h:356
public methods for global and local (sub)problems
int SCIPcolGetNLPNonz(SCIP_COL *col)
Definition: lp.c:17073
SCIP_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var)
Definition: scip_sol.c:1352
default SCIP plugins
SCIP_RETCODE SCIPaddRealParam(SCIP *scip, const char *name, const char *desc, SCIP_Real *valueptr, SCIP_Bool isadvanced, SCIP_Real defaultvalue, SCIP_Real minvalue, SCIP_Real maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip_param.c:130
SCIP_RETCODE SCIPsetSubscipsOff(SCIP *scip, SCIP_Bool quiet)
Definition: scip_param.c:874
SCIP_Real SCIPfloor(SCIP *scip, SCIP_Real val)
SCIP_RETCODE SCIPsetLongintParam(SCIP *scip, const char *name, SCIP_Longint value)
Definition: scip_param.c:536
SCIP_RETCODE SCIPaddBoolParam(SCIP *scip, const char *name, const char *desc, SCIP_Bool *valueptr, SCIP_Bool isadvanced, SCIP_Bool defaultvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip_param.c:48
SCIP_RETCODE SCIPfree(SCIP **scip)
Definition: scip_general.c:315
SCIP_RETCODE SCIPcreateSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip_sol.c:319
memory allocation routines