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