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