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 a 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, /**< SCIP 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  int nrows;
262  int i;
263  int sgn;
264  int rowindex;
265 
266  assert(NULL != scip);
267  assert(NULL != potential);
268  assert(NULL != slack);
269  assert(NULL != var);
270  assert(NULL != inftycounter);
271  assert(NULL != heurdata);
272 
273  alpha = heurdata->alpha;
274  *infeasible = TRUE;
275  *fixed = FALSE;
276 
277  if( SCIPisFeasLT(scip, SCIPgetSolVal(scip, sol, var), SCIPvarGetLbGlobal(var)) )
278  {
279  return SCIP_OKAY;
280  }
281  if( SCIPisFeasGT(scip, SCIPgetSolVal(scip, sol, var), SCIPvarGetUbGlobal(var)) )
282  {
283  return SCIP_OKAY;
284  }
285 
286  col = SCIPvarGetCol(var);
287  rows = SCIPcolGetRows(col);
288  nrows = SCIPcolGetNLPNonz(col);
289  vals = SCIPcolGetVals(col);
290 
291  if( NULL == rows )
292  {
293  SCIP_CALL( SCIPfixVar(subscip, subvar, SCIPgetSolVal(scip, sol, var),
294  infeasible, fixed) );
295  assert(!*infeasible && *fixed);
296  heurdata->nvarfixed++;
297  SCIPdebugMsg(scip,"Variable %s is fixed to %g\n",SCIPvarGetName(var), SCIPgetSolVal(scip, sol, var));
298  return SCIP_OKAY;
299  }
300  assert(NULL != rows);
301 
302  /* iterate over rows, where the variable coefficient is nonzero */
303  for( i = 0; i < nrows; ++i )
304  {
305  SCIP_Real contribution;
306  rowindex = SCIProwGetLPPos(rows[i]);
307  assert(rowindex >= 0);
308 
309  sgn = 1;
310 
311  if( SCIPisFeasZero(scip, slack[rowindex]) )
312  {
313  continue;
314  }
315  else if( SCIPisFeasGT(scip, 0.0 , slack[rowindex]) )
316  {
317  sgn = -1;
318  }
319 
320  contribution = getPotentialContributed(scip, sol, var, vals[i], sgn);
321 
322  if( !SCIPisInfinity(scip, REALABS(contribution)) )
323  {
324  potential[rowindex] -= contribution;
325  }
326  else
327  {
328  inftycounter[rowindex]--;
329  }
330 
331  assert(0 <= inftycounter[rowindex]);
332  if( 0 == inftycounter[rowindex] && REALABS(potential[rowindex]) < alpha * REALABS(slack[rowindex]) )
333  {
334  /* revert the changes before */
335  int j = i;
336  for( ; j >= 0; --j )
337  {
338  sgn = 1;
339  if( 0 == slack[rowindex] )
340  {
341  continue;
342  }
343  rowindex = SCIProwGetLPPos(rows[j]);
344  if( 0 > slack[rowindex])
345  {
346  sgn = -1;
347  }
348  contribution = getPotentialContributed(scip, sol, var, vals[j], sgn);
349  if( !SCIPisInfinity(scip, REALABS(contribution)) )
350  {
351  potential[rowindex] += contribution;
352  }
353  else
354  {
355  inftycounter[rowindex]++;
356  }
357  }
358  return SCIP_OKAY;
359  }
360  }
361 
362  SCIP_CALL( SCIPfixVar(subscip, subvar, SCIPgetSolVal(scip, sol, var),
363  infeasible, fixed) );
364  assert(!*infeasible && *fixed);
365  heurdata->nvarfixed++;
366  SCIPdebugMsg(scip,"Variable %s is fixed to %g\n",SCIPvarGetName(var),
367  SCIPgetSolVal(scip, sol, var));
368 
369  return SCIP_OKAY;
370 }
371 
372 /** checks if all integral variables in the given solution are integral. */
373 static
375  SCIP* scip, /**< SCIP data structure */
376  SCIP_SOL* sol, /**< solution pointer to the to be checked solution */
377  SCIP_Bool roundit, /**< round fractional solution values of integer variables */
378  SCIP_Bool* success /**< pointer to store if all integral variables are integral or could
379  * be rounded
380  */
381  )
382 {
383  SCIP_VAR** vars;
384  int nvars;
385  int nfracvars;
386  int nbinvars;
387  int nintvars;
388  int i;
389 
390  assert(NULL != success);
391  assert(NULL != sol);
392 
393  *success = TRUE;
394 
395  /* get variable data */
396  SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, &nbinvars, &nintvars, NULL, NULL) );
397 
398  /* check if the candidates are fractional and round them if necessary */
399  nfracvars = nbinvars + nintvars;
400  for( i = 0; i < nfracvars; ++i)
401  {
402  SCIP_Real value = SCIPgetSolVal(scip, sol, vars[i]);
403  if( !SCIPisFeasIntegral(scip, value) )
404  {
405  if( roundit )
406  {
407  SCIP_Real roundedvalue;
408 
409  if( SCIPvarGetNLocksUp(vars[i]) > SCIPvarGetNLocksDown(vars[i]) )
410  {
411  roundedvalue = SCIPceil(scip, value - 1.0);
412  }
413  else
414  {
415  roundedvalue = SCIPfloor(scip, value + 1.0);
416  }
417 
418  SCIP_CALL( SCIPsetSolVal(scip, sol, vars[i], roundedvalue) );
419  }
420  else
421  {
422  *success = FALSE;
423  SCIPdebugMsg(scip, "Repair: All variables are integral.\n");
424  return SCIP_OKAY;
425  }
426  }
427  }
428  SCIPdebugMsg(scip, "All variables rounded.\n");
429  return SCIP_OKAY;
430 }
431 
432 /** creates a new solution for the original problem by copying the solution of the subproblem */
433 static
435  SCIP* scip, /**< original SCIP data structure */
436  SCIP* subscip, /**< SCIP structure of the subproblem */
437  SCIP_VAR** subvars, /**< the variables of the subproblem */
438  SCIP_HEUR* heur, /**< Repair heuristic structure */
439  SCIP_SOL* subsol, /**< solution of the subproblem */
440  SCIP_Bool* success /**< used to store whether new solution was found or not */
441  )
442 {
443  SCIP_VAR** vars; /* the original problem's variables */
444  int nvars; /* the original problem's number of variables */
445  SCIP_Real* subsolvals; /* solution values of the subproblem */
446  SCIP_SOL* newsol; /* solution to be created for the original problem */
447 
448  assert(scip != NULL);
449  assert(subscip != NULL);
450  assert(subvars != NULL);
451  assert(subsol != NULL);
452 
453  /* get variables' data */
454  SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, NULL, NULL, NULL, NULL) );
455 
456  /* sub-SCIP may have more variables than the number of active (transformed) variables in the main SCIP
457  * since constraint copying may have required the copy of variables that are fixed in the main SCIP
458  */
459  assert(nvars <= SCIPgetNOrigVars(subscip));
460 
461  SCIP_CALL( SCIPallocBufferArray(scip, &subsolvals, nvars) );
462 
463  /* copy the solution */
464  SCIP_CALL( SCIPgetSolVals(subscip, subsol, nvars, subvars, subsolvals) );
465 
466  /* create new solution for the original problem */
467  SCIP_CALL( SCIPcreateSol(scip, &newsol, heur) );
468  SCIP_CALL( SCIPsetSolVals(scip, newsol, nvars, vars, subsolvals) );
469  /* try to add new solution to SCIP and free it immediately */
470  SCIP_CALL( SCIPtrySolFree(scip, &newsol, FALSE, FALSE, TRUE, TRUE, TRUE, success) );
471 
472 #ifdef SCIP_STATISTICS
473  {
474  SCIP_HEURDATA* heurdata;
475  heurdata = SCIPheurGetData(heur);
476 
477  if( *success )
478  {
479  heurdata->originalsolval = SCIPgetSolOrigObj(scip, newsol);
480  }
481  }
482 #endif
483 
484  SCIPfreeBufferArray(scip, &subsolvals);
485 
486  return SCIP_OKAY;
487 }
488 
489 /** tries to fix variables as an approach to repair a solution. */
490 static
492  SCIP* scip, /**< SCIP data structure of the problem */
493  SCIP_HEUR* heur, /**< pointer to this heuristic instance */
494  SCIP_RESULT* result, /**< pointer to return the result status */
495  SCIP_Longint nnodes /**< nodelimit for sub-SCIP */
496  )
497 {
498  SCIP* subscip = NULL;
499  SCIP_VAR** vars = NULL;
500  SCIP_VAR** subvars = NULL;
501  SCIP_ROW** rows;
502  SCIP_CONS** subcons = NULL;
503  int* nviolatedrows = NULL;
504  int* permutation = NULL;
505  int* inftycounter = NULL;
506  SCIP_SOL* sol;
507  SCIP_SOL* subsol = NULL;
508  SCIP_HEURDATA* heurdata;
509  SCIP_Real* potential = NULL;
510  SCIP_Real* slacks = NULL;
511  SCIP_RETCODE retcode = SCIP_OKAY;
512  SCIP_Real timelimit;
513  SCIP_Real memorylimit;
514  SCIP_Real factor;
515  char probname[SCIP_MAXSTRLEN];
516  int i;
517  int nbinvars;
518  int nintvars;
519  int nvars;
520  int nrows;
521  int ndiscvars;
522  int nfixeddiscvars;
523  SCIP_Bool success;
524 
525  heurdata = SCIPheurGetData(heur);
526  sol = heurdata->infsol;
527 
528  /* initializes the sub-SCIP */
529  SCIP_CALL( SCIPcreate(&subscip) );
531  SCIP_CALL( SCIPcopyParamSettings(scip, subscip) );
532 
533  /* use inference branching */
534  if( SCIPfindBranchrule(subscip, "inference") != NULL && !SCIPisParamFixed(subscip, "branching/inference/priority") )
535  {
536  SCIP_CALL( SCIPsetIntParam(subscip, "branching/inference/priority", INT_MAX/4) );
537  }
538 
539  /* get name of the original problem and add the string "_repairsub" */
540  (void) SCIPsnprintf(probname, SCIP_MAXSTRLEN, "%s_repairsub", SCIPgetProbName(scip));
541 
542  SCIP_CALL( SCIPcreateProb(subscip, probname, NULL, NULL, NULL, NULL, NULL, NULL, NULL) );
543 
544  /* a trivial feasible solution can be constructed if violations are modeled with slack variables */
545  if( heurdata->useslackvars )
546  {
547  SCIP_CALL( SCIPcreateSol(subscip, &subsol, heur) );
548  }
549 
550  /* gets all original variables */
551  SCIP_CALL( SCIPgetVarsData(scip, &vars, &nvars, &nbinvars, &nintvars, NULL, NULL) );
552  SCIP_CALL( SCIPallocBufferArray(scip, &subvars, nvars) );
553  SCIP_CALL( SCIPallocBufferArray(scip, &nviolatedrows, nvars) );
554  SCIP_CALL( SCIPallocBufferArray(scip, &permutation, nvars) );
555 
556  SCIPdebugMsg(scip,"\n\n Calling objective factor calculation \n\n");
557  if( heurdata->useobjfactor )
558  {
559  SCIP_CALL( getObjectiveFactor(scip, subscip, &factor, &success) );
560  }
561  else
562  {
563  factor = 0.0;
564  }
565 
566  /* adds all original variables */
567  ndiscvars = 0;
568  for( i = 0; i < nvars; ++i )
569  {
570  SCIP_CONS* cons;
571  SCIP_Real lb;
572  SCIP_Real ub;
573  SCIP_Real lborig;
574  SCIP_Real uborig;
575  SCIP_Real varslack;
576  SCIP_Real objval;
577  SCIP_Real value;
578  SCIP_VARTYPE vartype;
579  char varname[SCIP_MAXSTRLEN];
580  char slackvarname[SCIP_MAXSTRLEN];
581  char consvarname[SCIP_MAXSTRLEN];
582 
583 #ifdef SCIP_STATISTIC
584  heurdata->norigvars++;
585 #endif
586 
587  varslack = 0.0;
588  lborig = SCIPvarGetLbGlobal(vars[i]);
589  uborig = SCIPvarGetUbGlobal(vars[i]);
590  value = SCIPgetSolVal(scip, sol, vars[i]);
591  vartype = SCIPvarGetType(vars[i]);
592 
593  nviolatedrows[i] = 0;
594 
595  /* if the value of x is lower than the variables lower bound, sets the slack to a correcting value */
596  if( heurdata->useslackvars && SCIPisFeasLT(scip, value, lborig) )
597  {
598  lb = value;
599  varslack = lborig - value;
600  SCIP_CALL( SCIPchgVarLbGlobal(subscip, subvars[i], lb) );
601  }
602  else
603  {
604  lb = lborig;
605  }
606 
607  /* if the value of x is bigger than the variables upper bound, sets the slack to a correcting value */
608  if( heurdata->useslackvars && SCIPisFeasGT(scip, value, uborig) )
609  {
610  ub = value;
611  varslack = uborig - value;
612  SCIP_CALL( SCIPchgVarUbGlobal(subscip, subvars[i], ub) );
613  }
614  else
615  {
616  ub = uborig;
617  }
618 
619  if( heurdata->useobjfactor )
620  {
621  objval = SCIPvarGetObj(vars[i])*factor;
622 
623  if( SCIPisZero(scip, objval) )
624  {
625  objval = 0.0;
626  }
627  }
628  else
629  {
630  objval = SCIPvarGetObj(vars[i]);
631  }
632 
633  /* if a binary variable is out of bound, generalize it to an integer variable */
634  if( !SCIPisFeasZero(scip, varslack) && SCIP_VARTYPE_BINARY == vartype )
635  {
636  vartype = SCIP_VARTYPE_INTEGER;
637  SCIP_CALL( SCIPchgVarType(subscip, subvars[i], vartype, &success) );
638  }
639 
640  (void) SCIPsnprintf(varname, SCIP_MAXSTRLEN, "sub_%s", SCIPvarGetName(vars[i]));
641 
642  /* Adds the sub representing variable to the sub-SCIP. */
643  SCIP_CALL( SCIPcreateVarBasic(subscip, &subvars[i], varname, lb, ub, objval, vartype) );
644  SCIP_CALL( SCIPaddVar(subscip, subvars[i]) );
645 
646  /* a trivial feasible solution can be constructed if violations are modeled with slack variables */
647  if( heurdata->useslackvars )
648  {
649  SCIP_CALL( SCIPsetSolVal(subscip, subsol, subvars[i], value) );
650  }
651 
652  /* if necessary adds a constraint to represent the original bounds of x.*/
653  if( !SCIPisFeasEQ(scip, varslack, 0.0) )
654  {
655  SCIP_VAR* newvar;
656  (void) SCIPsnprintf(slackvarname, SCIP_MAXSTRLEN, "artificialslack_%s", SCIPvarGetName(vars[i]));
657  (void) SCIPsnprintf(consvarname, SCIP_MAXSTRLEN, "boundcons_%s", SCIPvarGetName(vars[i]));
658 
659  /* initialize and add an artificial slack variable */
660  if( heurdata->useobjfactor )
661  {
662  SCIP_CALL( SCIPcreateVarBasic(subscip, &newvar, slackvarname, 0.0, 1.0, 1.0, SCIP_VARTYPE_CONTINUOUS));
663  }
664  else
665  {
666  SCIP_CALL( SCIPcreateVarBasic(subscip, &newvar, slackvarname, 0.0, 1.0, 1.0, SCIP_VARTYPE_BINARY));
667  }
668  SCIP_CALL( SCIPaddVar(subscip, newvar) );
669 
670  /* set the value of the slack variable to 1 to punish the use of it.
671  * note that a trivial feasible solution can be only constructed if violations are modeled with slack variables
672  */
673  if( heurdata->useslackvars )
674  {
675  SCIP_CALL( SCIPsetSolVal(subscip, subsol, newvar, 1.0) );
676  }
677 
678  /* adds a linear constraint to represent the old bounds */
679  SCIP_CALL( SCIPcreateConsBasicVarbound(subscip, &cons, consvarname, subvars[i], newvar, varslack, lb, ub) );
680  SCIP_CALL( SCIPaddCons(subscip, cons) );
681  SCIP_CALL( SCIPreleaseVar(subscip, &newvar) );
682  SCIP_CALL( SCIPreleaseCons(subscip, &cons) );
683 
684  /* increases the counter for violated vars */
685 #ifdef SCIP_STATISTIC
686  heurdata->nviolatedvars++;
687 #endif
688  }
689 
690 
691 #ifdef SCIP_STATISTIC
692  if( SCIPisFeasLT(scip, value, lb) || SCIPisFeasGT(scip, value, ub) )
693  {
694  heurdata->nviolatedvars++;
695  }
696 #endif
697  if( SCIP_VARTYPE_BINARY == vartype || SCIP_VARTYPE_INTEGER == vartype )
698  {
699  ndiscvars++;
700  }
701  }
702 
703  /* check solution for feasibility regarding the LP rows (SCIPgetRowSolActivity()) */
704  rows = SCIPgetLPRows(scip);
705  nrows = SCIPgetNLPRows(scip);
706 
707  SCIP_CALL( SCIPallocBufferArray(scip, &potential, nrows) );
708  SCIP_CALL( SCIPallocBufferArray(scip, &slacks, nrows) );
709  SCIP_CALL( SCIPallocBufferArray(scip, &subcons, nrows) );
710  SCIP_CALL( SCIPallocBufferArray(scip, &inftycounter, nrows) );
711 
712  /* Adds all original constraints and computes potentials and slacks */
713  for (i = 0; i < nrows; ++i)
714  {
715  SCIP_COL** cols;
716  SCIP_VAR** consvars;
717  SCIP_Real* vals;
718  SCIP_Real constant;
719  SCIP_Real lhs;
720  SCIP_Real rhs;
721  SCIP_Real rowsolact;
722  int nnonz;
723  int j;
724 
725 #ifdef SCIP_STATISTIC
726  heurdata->norcons++;
727 #endif
728 
729  /* gets the values to check the constraint */
730  constant = SCIProwGetConstant(rows[i]);
731  lhs = SCIPisInfinity(scip, -SCIProwGetLhs(rows[i])) ? SCIProwGetLhs(rows[i]) : SCIProwGetLhs(rows[i]) - constant;
732  rhs = SCIPisInfinity(scip, SCIProwGetRhs(rows[i])) ? SCIProwGetRhs(rows[i]) : SCIProwGetRhs(rows[i]) - constant;
733  rowsolact = SCIPgetRowSolActivity(scip, rows[i], sol) - constant;
734  vals = SCIProwGetVals(rows[i]);
735  potential[i] = 0.0;
736  inftycounter[i] = 0;
737 
738  assert(SCIPisFeasLE(scip, lhs, rhs));
739 
740  nnonz = SCIProwGetNNonz(rows[i]);
741  cols = SCIProwGetCols(rows[i]);
742  SCIP_CALL( SCIPallocBufferArray(subscip, &consvars, nnonz) );
743 
744  /* sets the slack if its necessary */
745  if( SCIPisFeasLT(scip, rowsolact, lhs) )
746  {
747  slacks[i] = lhs - rowsolact;
748 #ifdef SCIP_STATISTIC
749  heurdata->nviolatedcons++;
750 #endif
751  }
752  else if( SCIPisFeasGT(scip, rowsolact, rhs) )
753  {
754  slacks[i] = rhs - rowsolact;
755 #ifdef SCIP_STATISTIC
756  heurdata->nviolatedcons++;
757 #endif
758  }
759  else
760  {
761  slacks[i] = 0.0;
762  }
763 
764  /* translate all variables from the original SCIP to the sub-SCIP with sub-SCIP variables. */
765  for( j = 0; j < nnonz; ++j )
766  {
767  SCIP_Real contribution;
768  int pos;
769  int sgn = 1;
770 
771  /* negative slack represents a right hand side violation */
772  if( SCIPisFeasGT(scip, 0.0, slacks[i]) )
773  {
774  assert(!SCIPisInfinity(scip, rhs));
775  sgn = -1;
776  }
777  #ifndef NDEBUG
778  else
779  assert(!SCIPisInfinity(scip, lhs));
780  #endif
781 
782  pos = SCIPvarGetProbindex(SCIPcolGetVar(cols[j]));
783  consvars[j] = subvars[pos];
784  assert(pos >= 0);
785 
786  /* compute potentials */
787  contribution = getPotentialContributed(scip, sol, vars[pos], vals[j], sgn);
788  if( !SCIPisInfinity(scip, REALABS(contribution)) )
789  {
790  potential[i] += contribution;
791  }
792  else
793  {
794  inftycounter[i]++;
795  }
796 
797  if( !SCIPisZero(scip, slacks[i]) )
798  {
799  nviolatedrows[pos]++;
800  }
801  }
802 
803 
804  /* create a new linear constraint, representing the old one */
805  SCIP_CALL( SCIPcreateConsBasicLinear(subscip, &subcons[i], SCIProwGetName(rows[i]),
806  nnonz, consvars, vals, lhs, rhs) );
807 
808  if( heurdata->useslackvars )
809  {
810  SCIP_VAR* newvar;
811  char varname[SCIP_MAXSTRLEN];
812 
813  /*if necessary adds a new artificial slack variable*/
814  if( !SCIPisFeasEQ(subscip, slacks[i], 0.0) )
815  {
816  (void) SCIPsnprintf(varname, SCIP_MAXSTRLEN, "artificialslack_%s", SCIProwGetName(rows[i]));
817  SCIP_CALL( SCIPcreateVarBasic(subscip, &newvar, varname, 0.0, 1.0, 1.0, SCIP_VARTYPE_CONTINUOUS) );
818  SCIP_CALL( SCIPaddVar(subscip, newvar) );
819 
820  /* a trivial feasible solution can be constructed if violations are modeled with slack variables */
821  SCIP_CALL( SCIPsetSolVal(subscip, subsol, newvar, 1.0) );
822  SCIP_CALL( SCIPaddCoefLinear(subscip, subcons[i], newvar, slacks[i]) );
823  SCIP_CALL( SCIPreleaseVar(subscip, &newvar) );
824  }
825  }
826 
827  /*Adds the Constraint and release it.*/
828  SCIP_CALL( SCIPaddCons(subscip, subcons[i]) );
829  SCIP_CALL( SCIPreleaseCons(subscip, &subcons[i]) );
830  SCIPfreeBufferArray(subscip, &consvars);
831  }
832 
833  if( heurdata->usevarfix )
834  {
835  /* get the greedy order */
836  for( i = 0; i < nvars; ++i )
837  {
838  permutation[i] = i;
839  }
840  SCIPsortIntInt(nviolatedrows, permutation, nvars);
841 
842  /* loops over variables and greedily fix variables, but preserve the cover property that enough slack is given to
843  * violated rows
844  */
845  nfixeddiscvars = 0;
846  heurdata->nvarfixed = 0;
847  for( i = 0; i < nvars; ++i )
848  {
849  SCIP_Bool infeasible = FALSE;
850  SCIP_Bool fixed = TRUE;
851 
852  SCIP_CALL( tryFixVar(scip, subscip, sol, potential, slacks, vars[permutation[i]], subvars[permutation[i]], inftycounter, heurdata, &infeasible, &fixed) );
853 
854  if( fixed && (SCIP_VARTYPE_BINARY == SCIPvarGetType(subvars[permutation[i]])
855  || SCIP_VARTYPE_INTEGER == SCIPvarGetType(subvars[permutation[i]])) )
856  {
857  nfixeddiscvars++;
858  }
859  }
860  SCIPdebugMsg(scip,"fixings finished\n\n");
861  if( heurdata->minfixingrate > ((SCIP_Real)nfixeddiscvars/MAX((SCIP_Real)ndiscvars,1.0)) )
862  {
863  goto TERMINATE;
864  }
865  }
866 
867  /* a trivial feasible solution can be constructed if violations are modeled with slack variables */
868  if( heurdata->useslackvars )
869  {
870  SCIP_CALL( SCIPaddSolFree(subscip, &subsol, &success) );
871 
872  if( !success )
873  {
874  SCIPdebugMsg(scip, "Initial repair solution was not accepted.\n");
875  }
876  }
877 
878 #ifdef SCIP_STATISTIC
879  if( heurdata->useslackvars )
880  heurdata->improvedoldsol = SCIPgetSolOrigObj(subscip, subsol);
881 #endif
882 
883  /* check whether there is enough time and memory left */
884  SCIP_CALL( SCIPgetRealParam(scip, "limits/time", &timelimit) );
885  if( !SCIPisInfinity(scip, timelimit) )
886  timelimit -= SCIPgetSolvingTime(scip);
887  SCIP_CALL( SCIPgetRealParam(scip, "limits/memory", &memorylimit) );
888 
889  /* subtract the memory already used by the main SCIP and the estimated memory usage of external software */
890  if( !SCIPisInfinity(scip, memorylimit) )
891  {
892  memorylimit -= SCIPgetMemUsed(scip) / 1048576.0;
893  memorylimit -= SCIPgetMemExternEstim(scip) / 1048576.0;
894  }
895 
896  /* abort if no time is left or not enough memory to create a copy of SCIP, including external memory usage */
897  if( timelimit <= 0.0 || memorylimit <= 2.0 * SCIPgetMemExternEstim(scip) / 1048576.0 )
898  goto TERMINATE;
899 
900  /* set limits for the subproblem */
901  SCIP_CALL( SCIPsetLongintParam(subscip, "limits/nodes", nnodes) );
902  SCIP_CALL( SCIPsetRealParam(subscip, "limits/time", timelimit) );
903  SCIP_CALL( SCIPsetRealParam(subscip, "limits/memory", memorylimit) );
904  SCIP_CALL( SCIPsetObjlimit(subscip,1.0) );
905 
906  /* forbid recursive call of heuristics and separators solving sub-SCIPs */
907  SCIP_CALL( SCIPsetSubscipsOff(subscip, TRUE) );
908 
909  /* disable output to console */
910  SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", (int)SCIP_VERBLEVEL_NONE) );
911 
912 #ifdef SCIP_DEBUG
913  /* for debugging Repair, enable MIP output */
914  SCIP_CALL( SCIPsetIntParam(subscip, "display/verblevel", (int)SCIP_VERBLEVEL_FULL) );
915  SCIP_CALL( SCIPsetIntParam(subscip, "display/freq", -1) );
916 #endif
917 
918  /* solve the subproblem */
919  retcode = SCIPsolve(subscip);
920 
921  /* errors in sub-SCIPs should not kill the overall solving process. Hence, we print a warning message. Only
922  * in debug mode, SCIP will stop
923  */
924  if( retcode != SCIP_OKAY )
925  {
926  SCIPwarningMessage(scip, "Error while solving subproblem in REPAIR heuristic; sub-SCIP terminated with code <%d>\n", retcode);
927  SCIPABORT(); /*lint --e{527}*/
928  goto TERMINATE;
929  }
930 
931  success = FALSE;
932 
933  /* if a solution is found, save its value and create a new solution instance for the original SCIP */
934  if( SCIPgetBestSol(subscip) != NULL )
935  {
936 #ifdef SCIP_STATISTIC
937  heurdata->improvedoldsol = SCIPgetSolOrigObj(subscip, SCIPgetBestSol(subscip));
938 #endif
939  /* print solving statistics of subproblem if we are in SCIP's debug mode */
941 
942  assert(SCIPgetNSols(subscip) > 0);
943  SCIP_CALL( createNewSol(scip, subscip, subvars, heur, SCIPgetBestSol(subscip), &success) );
944 
945  if( success )
946  {
947  *result = SCIP_FOUNDSOL;
948  }
949  }
950  else
951  {
952  SCIPdebugMsg(scip,"No solution found!\n");
953  }
954 
955  if( SCIPgetStage(subscip) >= SCIP_STAGE_SOLVED )
956  {
957  heurdata->subiters = SCIPgetNLPIterations(subscip);
958  heurdata->subnodes = SCIPgetNTotalNodes(subscip);
959 #ifdef SCIP_STATISTIC
960  heurdata->subpresoltime = SCIPgetPresolvingTime(subscip);
961 #endif
962  heurdata->runs = SCIPgetNRuns(subscip);
963  }
964 
965  /* terminates the solving process */
966 TERMINATE:
967  if( NULL != sol )
968  {
969  SCIP_CALL( SCIPfreeSol(scip, &sol) );
970  }
971  SCIPfreeBufferArrayNull(scip, &nviolatedrows);
972  for( i = 0; i < nvars; ++i )
973  {
974  SCIP_CALL( SCIPreleaseVar(subscip, &subvars[i]) );
975  }
976  SCIPfreeBufferArrayNull(scip, &inftycounter);
977  SCIPfreeBufferArrayNull(scip, &subcons);
978  SCIPfreeBufferArrayNull(scip, &slacks);
979  SCIPfreeBufferArrayNull(scip, &potential);
980  SCIPfreeBufferArrayNull(scip, &permutation);
981  SCIPfreeBufferArrayNull(scip, &subvars);
982 
983  if( NULL != subsol )
984  {
985  SCIP_CALL( SCIPfreeSol(subscip, &subsol) );
986  }
987 
988  SCIP_CALL( SCIPfree(&subscip) );
989 
990  SCIPdebugMsg(scip, "repair finished\n");
991  return SCIP_OKAY;
992 }
993 
994 
995 /*
996  * Callback methods of primal heuristic
997  */
998 
999 /** destructor of primal heuristic to free user data (called when SCIP is exiting) */
1000 static
1001 SCIP_DECL_HEURFREE(heurFreeRepair)
1002 { /*lint --e{715}*/
1003  SCIP_HEURDATA* heurdata;
1004 
1005  heurdata = SCIPheurGetData(heur);
1007  assert(heurdata != NULL);
1008  SCIPfreeMemory(scip, &heurdata);
1009 
1010  SCIPheurSetData(heur, NULL);
1011 
1012  return SCIP_OKAY;
1013 }
1014 
1015 
1016 /** initialization method of primal heuristic (called after problem was transformed) */
1017 static
1018 SCIP_DECL_HEURINIT(heurInitRepair)
1019 { /*lint --e{715}*/
1020 
1021  SCIP_HEURDATA* heurdata;
1022 
1023  heurdata = SCIPheurGetData(heur);
1024 
1025  heurdata->subiters = -1;
1026  heurdata->subnodes = -1;
1027  heurdata->runs = 0;
1028 
1029  heurdata->nvarfixed = 0;
1030  heurdata->relvarfixed = -1;
1031 
1032 #ifdef SCIP_STATISTIC
1033  heurdata->subpresoltime = 0;
1034 
1035  heurdata->nviolatedvars = 0;
1036  heurdata->norigvars = 0;
1037  heurdata->relviolatedvars = 0;
1038  heurdata->nviolatedcons = 0;
1039  heurdata->norcons = 0;
1040  heurdata->relviolatedcons = 0;
1041 
1042  heurdata->originalsolval = SCIP_INVALID;
1043 
1044  heurdata->improvedoldsol = SCIP_UNKNOWN;
1045 #endif
1046 
1047  heurdata->usednodes = 0;
1048 
1049  return SCIP_OKAY;
1050 }
1051 
1052 
1053 /** deinitialization method of primal heuristic (called before transformed problem is freed) */
1054 static
1055 SCIP_DECL_HEUREXIT(heurExitRepair)
1056 { /*lint --e{715}*/
1057 #ifdef SCIP_STATISTIC
1058  SCIP_HEURDATA* heurdata;
1059  SCIP_Real time;
1060  SCIP_Real relvars;
1061  SCIP_Real relcons;
1062  SCIP_Real relfixed;
1063  char solval[SCIP_MAXSTRLEN];
1064  int violateds;
1065  int ninvars;
1066  int ninvcons;
1067  int nvars;
1068  int ncons;
1069  int iterations;
1070  int nodes;
1071  int runs;
1072 
1073  heurdata = SCIPheurGetData(heur);
1074  violateds = heurdata->nviolatedvars+heurdata->nviolatedcons;
1075  ninvars = heurdata->nviolatedvars;
1076  ninvcons = heurdata->nviolatedcons;
1077  nvars = heurdata->norigvars;
1078  ncons = heurdata->norcons;
1079  iterations = heurdata->subiters;
1080  nodes = heurdata->subnodes;
1081  time = heurdata->subpresoltime;
1082  runs = heurdata->runs;
1083 
1084  if( SCIP_INVALID == heurdata->originalsolval )
1085  {
1086  (void) SCIPsnprintf(solval, SCIP_MAXSTRLEN ,"--");
1087  }
1088  else
1089  {
1090  (void) SCIPsnprintf(solval, SCIP_MAXSTRLEN, "%15.9g", heurdata->originalsolval);
1091  }
1092 
1093  heurdata->relviolatedvars = MAX((SCIP_Real)heurdata->norigvars, 1.0);
1094  heurdata->relviolatedvars = heurdata->nviolatedvars/heurdata->relviolatedvars;
1095  heurdata->relviolatedcons = MAX((SCIP_Real)heurdata->norcons, 1.0);
1096  heurdata->relviolatedcons = heurdata->nviolatedcons/heurdata->relviolatedcons;
1097 
1098  heurdata->relvarfixed = MAX((SCIP_Real)heurdata->norigvars, 1.0);
1099  heurdata->relvarfixed = heurdata->nvarfixed/heurdata->relvarfixed;
1100  relvars = heurdata->relviolatedvars;
1101  relcons = heurdata->relviolatedcons;
1102  relfixed = heurdata->relvarfixed;
1103 
1104  /* prints all statistic data for a user*/
1105  SCIPstatistic(
1106  SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, "<repair> \n total violations : %10d\n", violateds);
1107  SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, " violated variables : %10d\n", ninvars);
1108  SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, " total variables : %10d\n", nvars)
1109  SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, " relative violated variables : %10.2f%%\n", 100 * relvars);
1110  SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, " violated constraints : %10d\n", ninvcons);
1111  SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, " total constraints : %10d\n", ncons);
1112  SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, " relative violated constraints: %10.2f%%\n", 100* relcons);
1113  SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, " fixed variables : %10d\n", heurdata->nvarfixed);
1114  SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, " relative fixed variables : %10.2f%%\n\n", 100* relfixed);
1115  SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, " iterations : %10d\n", iterations);
1116  SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, " nodes : %10d\n", nodes);
1117  SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, " number of runs : %10d\n", runs);
1118  SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, " presolve time : %10.2f\n", time);
1119  SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, "</repair>\n\n");
1120  SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, " value of best solution : %10g\n", solval);
1121  SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, " improved orig. solval : %10g\n", heurdata->improvedoldsol);
1122  SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, message);
1123  )
1124 
1125 #endif
1126  return SCIP_OKAY;
1127 }
1128 
1129 /** execution method of primal heuristic. Repair needs an incorrect solution, in which all variables are in their bound. */
1130 static
1131 SCIP_DECL_HEUREXEC(heurExecRepair)
1132 { /*lint --e{715}*/
1133  SCIP_HEURDATA* heurdata;
1134  SCIP_RETCODE retcode;
1135  SCIP_Bool success;
1136  SCIP_Bool error;
1138 
1139  heurdata = SCIPheurGetData(heur);
1140  SCIPdebugMsg(scip, "%s\n", heurdata->filename);
1141 
1142  /* checks the result pointer */
1143  assert(result != NULL);
1144  *result = SCIP_DIDNOTRUN;
1145 
1146  /* if repair already ran or neither variable fixing nor slack variables are enabled, stop */
1147  if( 0 < SCIPheurGetNCalls(heur) || !(heurdata->usevarfix || heurdata->useslackvars) )
1148  return SCIP_OKAY;
1149 
1150  /* do not run if the neither the LP is constructed nor a user given solution exists */
1151  if( SCIPgetLPSolstat(scip) != SCIP_LPSOLSTAT_OPTIMAL && strcmp(heurdata->filename, DEFAULT_FILENAME) == 0 )
1152  return SCIP_OKAY;
1153 
1154  /* calculate the maximal number of branching nodes until heuristic is aborted */
1155  nnodes = (SCIP_Longint)(heurdata->nodesquot * SCIPgetNNodes(scip));
1156 
1157  /* reward REPAIR if it succeeded often */
1158  nnodes = (SCIP_Longint)(nnodes * 3.0 * (SCIPheurGetNBestSolsFound(heur)+1.0)/(SCIPheurGetNCalls(heur) + 1.0));
1159  nnodes -= (SCIP_Longint)(100.0 * SCIPheurGetNCalls(heur)); /* count the setup costs for the sub-MIP as 100 nodes */
1160  nnodes += heurdata->nodesofs;
1161 
1162  /* determine the node limit for the current process */
1163  nnodes -= heurdata->usednodes;
1164  nnodes = MIN(nnodes, heurdata->maxnodes);
1165 
1166  /* check whether we have enough nodes left to call subproblem solving */
1167  if( nnodes < heurdata->minnodes )
1168  return SCIP_OKAY;
1169 
1170  if( !SCIPhasCurrentNodeLP(scip) )
1171  return SCIP_OKAY;
1172 
1173  if( !SCIPisLPConstructed(scip) )
1174  {
1175  SCIP_Bool cutoff;
1176 
1177  SCIP_CALL( SCIPconstructLP(scip, &cutoff) );
1178 
1179  /* manually cut off the node if the LP construction detected infeasibility (heuristics cannot return such a result) */
1180  if( cutoff )
1181  {
1183  return SCIP_OKAY;
1184  }
1185  }
1186 
1187  /* create original solution */
1188  SCIP_CALL( SCIPcreateOrigSol(scip, &(heurdata->infsol), heur) );
1189 
1190  /* use read method to enter solution from a file */
1191  if( strcmp(heurdata->filename, DEFAULT_FILENAME) == 0 )
1192  {
1193  retcode = SCIPlinkLPSol(scip, heurdata->infsol);
1194  }
1195  else
1196  {
1197  error = FALSE;
1198  retcode = SCIPreadSolFile(scip, heurdata->filename, heurdata->infsol, FALSE, NULL, &error);
1199  assert(error || SCIP_OKAY == retcode);
1200  }
1201 
1202  if( SCIP_NOFILE == retcode )
1203  {
1204  assert(strcmp(heurdata->filename, DEFAULT_FILENAME) != 0);
1205  SCIPwarningMessage(scip, "cannot open file <%s> for reading\n", heurdata->filename);
1206 
1207  SCIP_CALL( SCIPfreeSol(scip, &(heurdata->infsol)) );
1208  return SCIP_OKAY;
1209  }
1210  else if( retcode != SCIP_OKAY )
1211  {
1212  SCIPwarningMessage(scip, "cannot run repair, unknown return status <%d>\n", retcode);
1213  SCIP_CALL( SCIPfreeSol(scip, &(heurdata->infsol)) );
1214  return SCIP_OKAY;
1215  }
1216  SCIPdebugMsg(scip, "Repair: Solution file read.\n");
1217 
1218  /* checks the integrality of all discrete variable */
1219  SCIP_CALL( checkCands(scip, heurdata->infsol, heurdata->roundit, &success) );
1220  if( !success )
1221  {
1222  SCIPdebugMsg(scip,"Given solution is not integral, repair terminates.\n");
1223  SCIP_CALL( SCIPfreeSol(scip, &(heurdata->infsol)) );
1224  return SCIP_OKAY;
1225  }
1226 
1227  *result = SCIP_DIDNOTFIND;
1228 
1229  SCIP_CALL( SCIPtrySol(scip, heurdata->infsol, FALSE, FALSE, TRUE, TRUE, TRUE, &success) );
1230 
1231  /* the solution is not feasible for the original problem; we will try to repair it */
1232  if( !success )
1233  {
1234  assert(NULL != heurdata->infsol);
1235  assert(heurdata->usevarfix || heurdata->useslackvars);
1236  SCIP_CALL( applyRepair(scip, heur, result, nnodes) );
1237  }
1238  else
1239  {
1240  SCIP_CALL( SCIPfreeSol(scip, &(heurdata->infsol)) );
1241  }
1242 
1243  return SCIP_OKAY;
1244 }
1245 
1246 /* primal heuristic specific interface methods */
1247 
1248 /** creates the repair primal heuristic and includes it in SCIP */
1250  SCIP* scip /**< SCIP data structure */
1251  )
1252 {
1253  SCIP_HEURDATA* heurdata;
1254  SCIP_HEUR* heur;
1255 
1256  /* create repair primal heuristic data */
1257  heurdata = NULL;
1258 
1259  SCIP_CALL( SCIPallocMemory(scip ,&heurdata) );
1260 
1261  heur = NULL;
1262 
1263  /* include primal heuristic */
1264  SCIP_CALL( SCIPincludeHeurBasic(scip, &heur,
1266  HEUR_MAXDEPTH, HEUR_TIMING, HEUR_USESSUBSCIP, heurExecRepair, heurdata) );
1267 
1268  assert(heur != NULL);
1269  assert(heurdata != NULL);
1270 
1271  /* set non fundamental callbacks via setter functions */
1272  SCIP_CALL( SCIPsetHeurFree(scip, heur, heurFreeRepair) );
1273  SCIP_CALL( SCIPsetHeurInit(scip, heur, heurInitRepair) );
1274  SCIP_CALL( SCIPsetHeurExit(scip, heur, heurExitRepair) );
1275 
1276  /* add repair primal heuristic parameters */
1277 
1278  heurdata->filename = NULL;
1279  /* add string parameter for filename containing a solution */
1280  SCIP_CALL( SCIPaddStringParam(scip, "heuristics/"HEUR_NAME"/filename",
1281  "file name of a solution to be used as infeasible starting point, [-] if not available",
1282  &heurdata->filename, FALSE, DEFAULT_FILENAME, NULL, NULL) );
1283 
1284  /* add bool parameter for decision how to deal with unfractional cands */
1285  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/"HEUR_NAME"/roundit",
1286  "True : fractional variables which are not fractional in the given solution are rounded, "
1287  "FALSE : solving process of this heuristic is stopped. ",
1288  &heurdata->roundit, FALSE, DEFAULT_ROUNDIT, NULL, NULL));
1289 
1290  /* add bool parameter for decision how the objective function should be */
1291  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/"HEUR_NAME"/useobjfactor",
1292  "should a scaled objective function for original variables be used in repair subproblem?",
1293  &heurdata->useobjfactor, FALSE, DEFAULT_USEOBJFACTOR, NULL, NULL));
1294 
1295  /* add bool parameter for decision if variable fixings should be used */
1296  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/"HEUR_NAME"/usevarfix",
1297  "should variable fixings be used in repair subproblem?",
1298  &heurdata->usevarfix, FALSE, DEFAULT_USEVARFIX, NULL, NULL));
1299 
1300  /* add bool parameter for decision how the objective function should be */
1301  SCIP_CALL( SCIPaddBoolParam(scip, "heuristics/"HEUR_NAME"/useslackvars",
1302  "should slack variables be used in repair subproblem?",
1303  &heurdata->useslackvars, FALSE, DEFAULT_USESLACKVARS, NULL, NULL));
1304 
1305  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/alpha", "factor for the potential of var fixings",
1306  &heurdata->alpha, TRUE, DEFAULT_ALPHA, 0.0, 100.00, NULL, NULL) );
1307 
1308  SCIP_CALL( SCIPaddIntParam(scip, "heuristics/" HEUR_NAME "/nodesofs",
1309  "number of nodes added to the contingent of the total nodes",
1310  &heurdata->nodesofs, FALSE, DEFAULT_NODESOFS, 0, INT_MAX, NULL, NULL) );
1311 
1312  SCIP_CALL( SCIPaddIntParam(scip, "heuristics/" HEUR_NAME "/maxnodes",
1313  "maximum number of nodes to regard in the subproblem",
1314  &heurdata->maxnodes, TRUE, DEFAULT_MAXNODES, 0, INT_MAX, NULL, NULL) );
1315 
1316  SCIP_CALL( SCIPaddIntParam(scip, "heuristics/" HEUR_NAME "/minnodes",
1317  "minimum number of nodes required to start the subproblem",
1318  &heurdata->minnodes, TRUE, DEFAULT_MINNODES, 0, INT_MAX, NULL, NULL) );
1319 
1320  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/nodesquot",
1321  "contingent of sub problem nodes in relation to the number of nodes of the original problem",
1322  &heurdata->nodesquot, FALSE, DEFAULT_NODESQUOT, 0.0, 1.0, NULL, NULL) );
1323 
1324 
1325  SCIP_CALL( SCIPaddRealParam(scip, "heuristics/" HEUR_NAME "/minfixingrate",
1326  "minimum percentage of integer variables that have to be fixed",
1327  &heurdata->minfixingrate, FALSE, DEFAULT_MINFIXINGRATE, 0.0, 1.0, NULL, NULL) );
1328 
1329  return SCIP_OKAY;
1330 }
enum SCIP_Result SCIP_RESULT
Definition: type_result.h:52
SCIP_ROW ** SCIPgetLPRows(SCIP *scip)
Definition: scip.c:29200
SCIP_Bool SCIPisFeasZero(SCIP *scip, SCIP_Real val)
Definition: scip.c:46151
static SCIP_DECL_HEUREXIT(heurExitRepair)
Definition: heur_repair.c:1060
SCIP_RETCODE SCIPchgVarLbGlobal(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
Definition: scip.c:21877
SCIP_RETCODE SCIPlinkLPSol(SCIP *scip, SCIP_SOL *sol)
Definition: scip.c:37672
SCIP_Real SCIPgetSolvingTime(SCIP *scip)
Definition: scip.c:45137
SCIP_Bool SCIPisFeasEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
Definition: scip.c:46086
#define HEUR_DISPCHAR
Definition: heur_repair.c:41
SCIP_NODE * SCIPgetCurrentNode(SCIP *scip)
Definition: scip.c:40453
SCIP_STAGE SCIPgetStage(SCIP *scip)
Definition: scip.c:814
SCIP_RETCODE SCIPincludeHeurRepair(SCIP *scip)
Definition: heur_repair.c:1254
SCIP_Longint SCIPgetNLPIterations(SCIP *scip)
Definition: scip.c:41382
static SCIP_RETCODE createNewSol(SCIP *scip, SCIP *subscip, SCIP_VAR **subvars, SCIP_HEUR *heur, SCIP_SOL *subsol, SCIP_Bool *success)
Definition: heur_repair.c:439
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:46099
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:10946
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
Definition: var.c:17166
SCIP_RETCODE SCIPgetRealParam(SCIP *scip, const char *name, SCIP_Real *value)
Definition: scip.c:4426
#define SCIP_MAXSTRLEN
Definition: def.h:215
SCIP_Longint SCIPheurGetNBestSolsFound(SCIP_HEUR *heur)
Definition: heur.c:1327
SCIP_RETCODE SCIPaddSolFree(SCIP *scip, SCIP_SOL **sol, SCIP_Bool *stored)
Definition: scip.c:39639
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:9778
SCIP_Real * SCIPcolGetVals(SCIP_COL *col)
Definition: lp.c:16190
SCIP_RETCODE SCIPsetHeurExit(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEUREXIT((*heurexit)))
Definition: scip.c:8092
int SCIProwGetNNonz(SCIP_ROW *row)
Definition: lp.c:16232
int SCIPgetNOrigVars(SCIP *scip)
Definition: scip.c:12071
#define DEFAULT_USEOBJFACTOR
Definition: heur_repair.c:63
const char * SCIProwGetName(SCIP_ROW *row)
Definition: lp.c:16370
SCIP_RETCODE SCIPreleaseVar(SCIP *scip, SCIP_VAR **var)
Definition: scip.c:18384
static SCIP_DECL_HEURINIT(heurInitRepair)
Definition: heur_repair.c:1023
SCIP_RETCODE SCIPgetVarsData(SCIP *scip, SCIP_VAR ***vars, int *nvars, int *nbinvars, int *nintvars, int *nimplvars, int *ncontvars)
Definition: scip.c:11505
SCIP_Real SCIProwGetLhs(SCIP_ROW *row)
Definition: lp.c:16311
#define FALSE
Definition: def.h:64
SCIP_RETCODE SCIPcutoffNode(SCIP *scip, SCIP_NODE *node)
Definition: scip.c:40796
SCIP_Real SCIPinfinity(SCIP *scip)
Definition: scip.c:45816
int SCIPsnprintf(char *t, int len, const char *s,...)
Definition: misc.c:9340
#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:9184
int SCIPvarGetProbindex(SCIP_VAR *var)
Definition: var.c:16859
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:17317
static SCIP_RETCODE applyRepair(SCIP *scip, SCIP_HEUR *heur, SCIP_RESULT *result, SCIP_Longint nnodes)
Definition: heur_repair.c:496
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:7999
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:4313
SCIP_RETCODE SCIPconstructLP(SCIP *scip, SCIP_Bool *cutoff)
Definition: scip.c:28810
#define SCIPfreeBufferArray(scip, ptr)
Definition: scip.h:21937
SCIP_RETCODE SCIPcreate(SCIP **scip)
Definition: scip.c:696
void SCIPheurSetData(SCIP_HEUR *heur, SCIP_HEURDATA *heurdata)
Definition: heur.c:1102
SCIP_RETCODE SCIPsetRealParam(SCIP *scip, const char *name, SCIP_Real value)
Definition: scip.c:4741
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
Definition: scip.c:1260
SCIP_RETCODE SCIPchgVarUbGlobal(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound)
Definition: scip.c:21964
#define SCIPdebugMsg
Definition: scip.h:451
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:4202
static SCIP_RETCODE checkCands(SCIP *scip, SCIP_SOL *sol, SCIP_Bool roundit, SCIP_Bool *success)
Definition: heur_repair.c:379
SCIP_RETCODE SCIPcopyParamSettings(SCIP *sourcescip, SCIP *targetscip)
Definition: scip.c:3492
SCIP_Real SCIPgetPresolvingTime(SCIP *scip)
Definition: scip.c:45201
SCIP_RETCODE SCIPprintStatistics(SCIP *scip, FILE *file)
Definition: scip.c:44425
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:37242
const char * SCIPgetProbName(SCIP *scip)
Definition: scip.c:10724
SCIP_Bool SCIPisLPConstructed(SCIP *scip)
Definition: scip.c:28787
#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:25045
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
Definition: var.c:17176
SCIP_RETCODE SCIPsolve(SCIP *scip)
Definition: scip.c:15777
#define HEUR_TIMING
Definition: heur_repair.c:46
#define SCIPallocMemory(scip, ptr)
Definition: scip.h:21856
SCIP_Bool SCIPisParamFixed(SCIP *scip, const char *name)
Definition: scip.c:4338
SCIP_RETCODE SCIPaddCons(SCIP *scip, SCIP_CONS *cons)
Definition: scip.c:12410
void SCIPsortIntInt(int *intarray1, int *intarray2, int len)
SCIP_RETCODE SCIPsetHeurFree(SCIP *scip, SCIP_HEUR *heur, SCIP_DECL_HEURFREE((*heurfree)))
Definition: scip.c:8060
SCIP_ROW ** SCIPcolGetRows(SCIP_COL *col)
Definition: lp.c:16180
#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:38044
#define SCIPfreeBufferArrayNull(scip, ptr)
Definition: scip.h:21938
#define DEFAULT_MAXNODES
Definition: heur_repair.c:51
const char * SCIPvarGetName(SCIP_VAR *var)
Definition: var.c:16552
#define DEFAULT_USESLACKVARS
Definition: heur_repair.c:69
#define NULL
Definition: lpi_spx1.cpp:137
#define REALABS(x)
Definition: def.h:159
int SCIPgetNLPRows(SCIP *scip)
Definition: scip.c:29221
#define HEUR_DESC
Definition: heur_repair.c:40
#define DEFAULT_ALPHA
Definition: heur_repair.c:70
#define SCIP_CALL(x)
Definition: def.h:306
SCIP_Real SCIPgetLowerbound(SCIP *scip)
Definition: scip.c:42323
SCIP_Longint SCIPgetNTotalNodes(SCIP *scip)
Definition: scip.c:41209
SCIP_Bool SCIPisFeasGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
Definition: scip.c:46125
SCIP_Bool SCIPisFeasLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
Definition: scip.c:46112
SCIP_Real SCIProwGetRhs(SCIP_ROW *row)
Definition: lp.c:16321
void SCIPverbMessage(SCIP *scip, SCIP_VERBLEVEL msgverblevel, FILE *file, const char *formatstr,...)
Definition: scip.c:1353
SCIP_Longint SCIPheurGetNCalls(SCIP_HEUR *heur)
Definition: heur.c:1307
#define HEUR_FREQ
Definition: heur_repair.c:43
SCIP_COL ** SCIProwGetCols(SCIP_ROW *row)
Definition: lp.c:16257
repair primal heuristic
SCIP_Bool SCIPhasCurrentNodeLP(SCIP *scip)
Definition: scip.c:28769
#define SCIPallocBufferArray(scip, ptr, num)
Definition: scip.h:21925
#define SCIP_UNKNOWN
Definition: def.h:156
SCIP_RETCODE SCIPsetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var, SCIP_Real val)
Definition: scip.c:37867
SCIP_Real * SCIProwGetVals(SCIP_ROW *row)
Definition: lp.c:16267
#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:28854
SCIP_RETCODE SCIPsetObjlimit(SCIP *scip, SCIP_Real objlimit)
Definition: scip.c:11078
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:39843
SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value)
Definition: scip.c:4625
SCIP_RETCODE SCIPfreeSol(SCIP *scip, SCIP_SOL **sol)
Definition: scip.c:37631
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
Definition: var.c:17014
int SCIPgetNSols(SCIP *scip)
Definition: scip.c:38832
#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:25141
int SCIPgetNRuns(SCIP *scip)
Definition: scip.c:41099
SCIP_COL * SCIPvarGetCol(SCIP_VAR *var)
Definition: var.c:16880
SCIP_Real SCIPgetSolOrigObj(SCIP *scip, SCIP_SOL *sol)
Definition: scip.c:38090
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:45827
SCIP_Real SCIPgetRowSolActivity(SCIP *scip, SCIP_ROW *row, SCIP_SOL *sol)
Definition: scip.c:30713
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:39749
static SCIP_DECL_HEURFREE(heurFreeRepair)
Definition: heur_repair.c:1006
#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:16277
#define HEUR_MAXDEPTH
Definition: heur_repair.c:45
#define SCIPfreeMemory(scip, ptr)
Definition: scip.h:21872
#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:39509
int SCIPvarGetNLocksDown(SCIP_VAR *var)
Definition: var.c:3162
SCIP_SOL * SCIPgetBestSol(SCIP *scip)
Definition: scip.c:38931
SCIP_Bool SCIPisGT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
Definition: scip.c:45790
#define DEFAULT_ROUNDIT
Definition: heur_repair.c:56
SCIP_VAR * SCIPcolGetVar(SCIP_COL *col)
Definition: lp.c:16081
SCIP_Longint SCIPgetMemUsed(SCIP *scip)
Definition: scip.c:45562
SCIP_RETCODE SCIPaddVar(SCIP *scip, SCIP_VAR *var)
Definition: scip.c:11311
SCIP_RETCODE SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
Definition: scip.c:27323
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:8076
SCIP_Longint SCIPgetMemExternEstim(SCIP *scip)
Definition: scip.c:45588
#define HEUR_USESSUBSCIP
Definition: heur_repair.c:47
int SCIProwGetLPPos(SCIP_ROW *row)
Definition: lp.c:16500
#define SCIPstatistic(x)
Definition: pub_message.h:101
#define SCIP_Real
Definition: def.h:135
#define MIN(x, y)
Definition: memory.c:75
#define SCIP_INVALID
Definition: def.h:155
#define HEUR_NAME
Definition: heur_repair.c:39
#define DEFAULT_FILENAME
Definition: heur_repair.c:55
#define SCIP_Longint
Definition: def.h:120
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
Definition: var.c:16717
SCIP_RETCODE SCIPsetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
Definition: scip.c:37909
SCIP_Bool SCIPisZero(SCIP *scip, SCIP_Real val)
Definition: scip.c:45864
enum SCIP_Vartype SCIP_VARTYPE
Definition: type_var.h:60
static SCIP_DECL_HEUREXEC(heurExecRepair)
Definition: heur_repair.c:1136
#define nnodes
Definition: gastrans.c:65
SCIP_Bool SCIPisFeasIntegral(SCIP *scip, SCIP_Real val)
Definition: scip.c:46187
SCIP_Real SCIPgetUpperbound(SCIP *scip)
Definition: scip.c:42472
SCIP_Real SCIPceil(SCIP *scip, SCIP_Real val)
Definition: scip.c:45949
SCIP_HEURDATA * SCIPheurGetData(SCIP_HEUR *heur)
Definition: heur.c:1092
SCIP_Longint SCIPgetNNodes(SCIP *scip)
Definition: scip.c:41182
#define SCIPABORT()
Definition: def.h:278
int SCIPcolGetNLPNonz(SCIP_COL *col)
Definition: lp.c:16169
SCIP_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var)
Definition: scip.c:38007
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:4258
SCIP_RETCODE SCIPsetSubscipsOff(SCIP *scip, SCIP_Bool quiet)
Definition: scip.c:5020
SCIP_Real SCIPfloor(SCIP *scip, SCIP_Real val)
Definition: scip.c:45937
SCIP_RETCODE SCIPsetLongintParam(SCIP *scip, const char *name, SCIP_Longint value)
Definition: scip.c:4683
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:4176
SCIP_RETCODE SCIPfree(SCIP **scip)
Definition: scip.c:774
SCIP_RETCODE SCIPcreateSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
Definition: scip.c:37005
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