Scippy

SCIP

Solving Constraint Integer Programs

cons_samediff.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-2018 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SCIP; see the file COPYING. If not visit scip.zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file cons_samediff.c
17  * @brief Constraint handler stores the local branching decision data
18  * @author Timo Berthold
19  * @author Stefan Heinz
20  *
21  * This constraint handler is used to store the branching decision of the \ref BINPACKING_BRANCHING "Ryan/Foster branching rule"
22  * which is implemented in \ref branch_ryanfoster.c.
23  */
24 
25 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
26 
27 #include <assert.h>
28 #include <string.h>
29 
30 #include "cons_samediff.h"
31 #include "probdata_binpacking.h"
32 #include "vardata_binpacking.h"
33 
34 
35 /**@name Constraint handler properties
36  *
37  * @{
38  */
39 
40 #define CONSHDLR_NAME "samediff"
41 #define CONSHDLR_DESC "stores the local branching decisions"
42 #define CONSHDLR_ENFOPRIORITY 0 /**< priority of the constraint handler for constraint enforcing */
43 #define CONSHDLR_CHECKPRIORITY 9999999 /**< priority of the constraint handler for checking feasibility */
44 #define CONSHDLR_PROPFREQ 1 /**< frequency for propagating domains; zero means only preprocessing propagation */
45 #define CONSHDLR_EAGERFREQ 1 /**< frequency for using all instead of only the useful constraints in separation,
46  * propagation and enforcement, -1 for no eager evaluations, 0 for first only */
47 #define CONSHDLR_DELAYPROP FALSE /**< should propagation method be delayed, if other propagators found reductions? */
48 #define CONSHDLR_NEEDSCONS TRUE /**< should the constraint handler be skipped, if no constraints are available? */
49 
50 #define CONSHDLR_PROP_TIMING SCIP_PROPTIMING_BEFORELP
51 
52 /**@} */
53 
54 /*
55  * Data structures
56  */
57 
58 /** Constraint data for \ref cons_samediff.c "SameDiff" constraints */
59 struct SCIP_ConsData
60 {
61  int itemid1; /**< item id one */
62  int itemid2; /**< item id two */
63  CONSTYPE type; /**< stores whether the items have to be in the SAME or DIFFER packing */
64  int npropagatedvars; /**< number of variables that existed, the last time, the related node was
65  * propagated, used to determine whether the constraint should be
66  * repropagated*/
67  int npropagations; /**< stores the number propagations runs of this constraint */
68  unsigned int propagated:1; /**< is constraint already propagated? */
69  SCIP_NODE* node; /**< the node in the B&B-tree at which the cons is sticking */
70 };
71 
72 /**@name Local methods
73  *
74  * @{
75  */
76 
77 /** create constraint data */
78 static
80  SCIP* scip, /**< SCIP data structure */
81  SCIP_CONSDATA** consdata, /**< pointer to store the constraint data */
82  int itemid1, /**< item id one */
83  int itemid2, /**< item id two */
84  CONSTYPE type, /**< stores whether the items have to be in the SAME or DIFFER packing */
85  SCIP_NODE* node /**< the node in the B&B-tree at which the cons is sticking */
86  )
87 {
88  assert( scip != NULL );
89  assert( consdata != NULL );
90  assert( itemid1 >= 0 );
91  assert( itemid2 >= 0 );
92  assert( type == DIFFER || type == SAME );
93 
94  SCIP_CALL( SCIPallocBlockMemory(scip, consdata) );
95 
96  (*consdata)->itemid1 = itemid1;
97  (*consdata)->itemid2 = itemid2;
98  (*consdata)->type = type;
99  (*consdata)->npropagatedvars = 0;
100  (*consdata)->npropagations = 0;
101  (*consdata)->propagated = FALSE;
102  (*consdata)->node = node;
103 
104  return SCIP_OKAY;
105 }
106 
107 /** display constraints */
108 static
109 void consdataPrint(
110  SCIP* scip, /**< SCIP data structure */
111  SCIP_CONSDATA* consdata, /**< constraint data */
112  FILE* file /**< file stream */
113  )
114 {
115  SCIP_PROBDATA* probdata;
116  int* ids;
117 
118  probdata = SCIPgetProbData(scip);
119  assert(probdata != NULL);
120 
121  ids = SCIPprobdataGetIds(probdata);
122  assert(ids != NULL);
123 
124  SCIPinfoMessage(scip, file, "%s(%d,%d) at node %d\n",
125  consdata->type == SAME ? "same" : "diff",
126  ids[consdata->itemid1], ids[consdata->itemid2], SCIPnodeGetNumber(consdata->node) );
127 }
128 
129 /** fixes a variable to zero if the corresponding packings are not valid for this constraint/node (due to branching) */
130 static
132  SCIP* scip, /**< SCIP data structure */
133  SCIP_CONSDATA* consdata, /**< constraint data */
134  SCIP_VAR* var, /**< variables to check */
135  int* nfixedvars, /**< pointer to store the number of fixed variables */
136  SCIP_Bool* cutoff /**< pointer to store if a cutoff was detected */
137  )
138 {
139  SCIP_VARDATA* vardata;
140  int* consids;
141  int nconsids;
142 
143  SCIP_Bool existid1;
144  SCIP_Bool existid2;
145  CONSTYPE type;
146 
147  SCIP_Bool fixed;
148  SCIP_Bool infeasible;
149 
150  int pos;
151 
152  assert(scip != NULL);
153  assert(consdata != NULL);
154  assert(var != NULL);
155  assert(nfixedvars != NULL);
156  assert(cutoff != NULL);
157 
158  /* if variables is locally fixed to zero continue */
159  if( SCIPvarGetUbLocal(var) < 0.5 )
160  return SCIP_OKAY;
161 
162  /* check if the packing which corresponds to the variable is feasible for this constraint */
163  vardata = SCIPvarGetData(var);
164 
165  nconsids = SCIPvardataGetNConsids(vardata);
166  consids = SCIPvardataGetConsids(vardata);
167 
168  existid1 = SCIPsortedvecFindInt(consids, consdata->itemid1, nconsids, &pos);
169  existid2 = SCIPsortedvecFindInt(consids, consdata->itemid2, nconsids, &pos);
170  type = consdata->type;
171 
172  if( (type == SAME && existid1 != existid2) || (type == DIFFER && existid1 && existid2) )
173  {
174  SCIP_CALL( SCIPfixVar(scip, var, 0.0, &infeasible, &fixed) );
175 
176  if( infeasible )
177  {
178  assert( SCIPvarGetLbLocal(var) > 0.5 );
179  SCIPdebugMsg(scip, "-> cutoff\n");
180  (*cutoff) = TRUE;
181  }
182  else
183  {
184  assert(fixed);
185  (*nfixedvars)++;
186  }
187  }
188 
189  return SCIP_OKAY;
190 }
191 
192 /** fixes variables to zero if the corresponding packings are not valid for this sonstraint/node (due to branching) */
193 static
195  SCIP* scip, /**< SCIP data structure */
196  SCIP_CONSDATA* consdata, /**< constraint data */
197  SCIP_VAR** vars, /**< generated variables */
198  int nvars, /**< number of generated variables */
199  SCIP_RESULT* result /**< pointer to store the result of the fixing */
200  )
201 {
202  int nfixedvars;
203  int v;
204  SCIP_Bool cutoff;
205 
206  nfixedvars = 0;
207  cutoff = FALSE;
208 
209  SCIPdebugMsg(scip, "check variables %d to %d\n", consdata->npropagatedvars, nvars);
210 
211  for( v = consdata->npropagatedvars; v < nvars && !cutoff; ++v )
212  {
213  SCIP_CALL( checkVariable(scip, consdata, vars[v], &nfixedvars, &cutoff) );
214  }
215 
216  SCIPdebugMsg(scip, "fixed %d variables locally\n", nfixedvars);
217 
218  if( cutoff )
219  *result = SCIP_CUTOFF;
220  else if( nfixedvars > 0 )
221  *result = SCIP_REDUCEDDOM;
222 
223  return SCIP_OKAY;
224 }
225 
226 
227 /** check if all variables are valid for the given consdata */
228 #ifndef NDEBUG
229 static
231  SCIP* scip, /**< SCIP data structure */
232  SCIP_PROBDATA* probdata, /**< problem data */
233  SCIP_CONSDATA* consdata, /**< constraint data */
234  SCIP_Bool beforeprop /**< is this check performed before propagation? */
235  )
236 {
237  SCIP_VAR** vars;
238  int nvars;
239 
240  SCIP_VARDATA* vardata;
241  SCIP_VAR* var;
242 
243  int* consids;
244  int nconsids;
245  SCIP_Bool existid1;
246  SCIP_Bool existid2;
247  CONSTYPE type;
248 
249  int pos;
250  int v;
251 
252  vars = SCIPprobdataGetVars(probdata);
253  nvars = (beforeprop ? consdata->npropagatedvars : SCIPprobdataGetNVars(probdata));
254  assert(nvars <= SCIPprobdataGetNVars(probdata));
255 
256  for( v = 0; v < nvars; ++v )
257  {
258  var = vars[v];
259 
260  /* if variables is locally fixed to zero continue */
261  if( SCIPvarGetUbLocal(var) < 0.5 )
262  continue;
263 
264  /* check if the packing which corresponds to the variable is feasible for this constraint */
265  vardata = SCIPvarGetData(var);
266 
267  nconsids = SCIPvardataGetNConsids(vardata);
268  consids = SCIPvardataGetConsids(vardata);
269 
270  existid1 = SCIPsortedvecFindInt(consids, consdata->itemid1, nconsids, &pos);
271  existid2 = SCIPsortedvecFindInt(consids, consdata->itemid2, nconsids, &pos);
272  type = consdata->type;
273 
274  if( (type == SAME && existid1 != existid2) || (type == DIFFER && existid1 && existid2) )
275  {
276  SCIPdebug( SCIPvardataPrint(scip, vardata, NULL) );
277  SCIPdebug( consdataPrint(scip, consdata, NULL) );
278  SCIPdebug( SCIPprintVar(scip, var, NULL) );
279  return FALSE;
280  }
281 
282  }
283 
284  return TRUE;
285 }
286 #endif
287 
288 /** frees samediff constraint data */
289 static
291  SCIP* scip, /**< SCIP data structure */
292  SCIP_CONSDATA** consdata /**< pointer to the constraint data */
293  )
294 {
295  assert(consdata != NULL);
296  assert(*consdata != NULL);
297 
298  SCIPfreeBlockMemory(scip, consdata);
299 
300  return SCIP_OKAY;
301 }
302 
303 /**@} */
304 
305 
306 /**@name Callback methods
307  *
308  * @{
309  */
310 
311 /** frees specific constraint data */
312 static
313 SCIP_DECL_CONSDELETE(consDeleteSamediff)
314 { /*lint --e{715}*/
315  assert(conshdlr != NULL);
316  assert(strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0);
317  assert(consdata != NULL);
318  assert(*consdata != NULL);
319 
320  /* free samediff constraint */
321  SCIP_CALL( consdataFree(scip, consdata) );
322 
323  return SCIP_OKAY;
324 }
325 
326 /** transforms constraint data into data belonging to the transformed problem */
327 static
328 SCIP_DECL_CONSTRANS(consTransSamediff)
329 { /*lint --e{715}*/
330  SCIP_CONSDATA* sourcedata;
331  SCIP_CONSDATA* targetdata;
332 
333  assert(conshdlr != NULL);
334  assert(strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0);
335  assert(SCIPgetStage(scip) == SCIP_STAGE_TRANSFORMING);
336  assert(sourcecons != NULL);
337  assert(targetcons != NULL);
338 
339  sourcedata = SCIPconsGetData(sourcecons);
340  assert(sourcedata != NULL);
341 
342  /* create constraint data for target constraint */
343  SCIP_CALL( consdataCreate(scip, &targetdata,
344  sourcedata->itemid1, sourcedata->itemid2, sourcedata->type, sourcedata->node) );
345 
346  /* create target constraint */
347  SCIP_CALL( SCIPcreateCons(scip, targetcons, SCIPconsGetName(sourcecons), conshdlr, targetdata,
348  SCIPconsIsInitial(sourcecons), SCIPconsIsSeparated(sourcecons), SCIPconsIsEnforced(sourcecons),
349  SCIPconsIsChecked(sourcecons), SCIPconsIsPropagated(sourcecons),
350  SCIPconsIsLocal(sourcecons), SCIPconsIsModifiable(sourcecons),
351  SCIPconsIsDynamic(sourcecons), SCIPconsIsRemovable(sourcecons), SCIPconsIsStickingAtNode(sourcecons)) );
352 
353  return SCIP_OKAY;
354 }
355 
356 /** constraint enforcing method of constraint handler for LP solutions */
357 #define consEnfolpSamediff NULL
359 /** constraint enforcing method of constraint handler for pseudo solutions */
360 #define consEnfopsSamediff NULL
362 /** feasibility check method of constraint handler for integral solutions */
363 #define consCheckSamediff NULL
365 /** domain propagation method of constraint handler */
366 static
367 SCIP_DECL_CONSPROP(consPropSamediff)
368 { /*lint --e{715}*/
369  SCIP_PROBDATA* probdata;
370  SCIP_CONSDATA* consdata;
371 
372  SCIP_VAR** vars;
373  int nvars;
374  int c;
375 
376  assert(scip != NULL);
377  assert(strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0);
378  assert(result != NULL);
379 
380  SCIPdebugMsg(scip, "propagation constraints of constraint handler <"CONSHDLR_NAME">\n");
381 
382  probdata = SCIPgetProbData(scip);
383  assert(probdata != NULL);
384 
385  vars = SCIPprobdataGetVars(probdata);
386  nvars = SCIPprobdataGetNVars(probdata);
387 
388  *result = SCIP_DIDNOTFIND;
389 
390  for( c = 0; c < nconss; ++c )
391  {
392  consdata = SCIPconsGetData(conss[c]);
393 
394  /* check if all previously generated variables are valid for this constraint */
395  assert( consdataCheck(scip, probdata, consdata, TRUE) );
396 
397 #ifndef NDEBUG
398  {
399  /* check if there are no equal consdatas */
400  SCIP_CONSDATA* consdata2;
401  int i;
402 
403  for( i = c+1; i < nconss; ++i )
404  {
405  consdata2 = SCIPconsGetData(conss[i]);
406  assert( !(consdata->itemid1 == consdata2->itemid1
407  && consdata->itemid2 == consdata2->itemid2
408  && consdata->type == consdata2->type) );
409  assert( !(consdata->itemid1 == consdata2->itemid2
410  && consdata->itemid2 == consdata2->itemid1
411  && consdata->type == consdata2->type) );
412  }
413  }
414 #endif
415 
416  if( !consdata->propagated )
417  {
418  SCIPdebugMsg(scip, "propagate constraint <%s> ", SCIPconsGetName(conss[c]));
419  SCIPdebug( consdataPrint(scip, consdata, NULL) );
420 
421  SCIP_CALL( consdataFixVariables(scip, consdata, vars, nvars, result) );
422  consdata->npropagations++;
423 
424  if( *result != SCIP_CUTOFF )
425  {
426  consdata->propagated = TRUE;
427  consdata->npropagatedvars = nvars;
428  }
429  else
430  break;
431  }
432 
433  /* check if constraint is completely propagated */
434  assert( consdataCheck(scip, probdata, consdata, FALSE) );
435  }
436 
437  return SCIP_OKAY;
438 }
439 
440 /** variable rounding lock method of constraint handler */
441 #define consLockSamediff NULL
443 /** constraint activation notification method of constraint handler */
444 static
445 SCIP_DECL_CONSACTIVE(consActiveSamediff)
446 { /*lint --e{715}*/
447  SCIP_CONSDATA* consdata;
448  SCIP_PROBDATA* probdata;
449 
450  assert(scip != NULL);
451  assert(strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0);
452  assert(cons != NULL);
453 
454  probdata = SCIPgetProbData(scip);
455  assert(probdata != NULL);
456 
457  consdata = SCIPconsGetData(cons);
458  assert(consdata != NULL);
459  assert(consdata->npropagatedvars <= SCIPprobdataGetNVars(probdata));
460 
461  SCIPdebugMsg(scip, "activate constraint <%s> at node <%"SCIP_LONGINT_FORMAT"> in depth <%d>: ",
462  SCIPconsGetName(cons), SCIPnodeGetNumber(consdata->node), SCIPnodeGetDepth(consdata->node));
463  SCIPdebug( consdataPrint(scip, consdata, NULL) );
464 
465  if( consdata->npropagatedvars != SCIPprobdataGetNVars(probdata) )
466  {
467  SCIPdebugMsg(scip, "-> mark constraint to be repropagated\n");
468  consdata->propagated = FALSE;
469  SCIP_CALL( SCIPrepropagateNode(scip, consdata->node) );
470  }
471 
472  return SCIP_OKAY;
473 }
474 
475 /** constraint deactivation notification method of constraint handler */
476 static
477 SCIP_DECL_CONSDEACTIVE(consDeactiveSamediff)
478 { /*lint --e{715}*/
479  SCIP_CONSDATA* consdata;
480  SCIP_PROBDATA* probdata;
481 
482  assert(scip != NULL);
483  assert(strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0);
484  assert(cons != NULL);
485 
486  consdata = SCIPconsGetData(cons);
487  assert(consdata != NULL);
488  assert(consdata->propagated || SCIPgetNChildren(scip) == 0);
489 
490  probdata = SCIPgetProbData(scip);
491  assert(probdata != NULL);
492 
493  SCIPdebugMsg(scip, "deactivate constraint <%s> at node <%"SCIP_LONGINT_FORMAT"> in depth <%d>: ",
494  SCIPconsGetName(cons), SCIPnodeGetNumber(consdata->node), SCIPnodeGetDepth(consdata->node));
495  SCIPdebug( consdataPrint(scip, consdata, NULL) );
496 
497  /* set the number of propagated variables to current number of variables is SCIP */
498  consdata->npropagatedvars = SCIPprobdataGetNVars(probdata);
499 
500  return SCIP_OKAY;
501 }
502 
503 /** constraint display method of constraint handler */
504 static
505 SCIP_DECL_CONSPRINT(consPrintSamediff)
506 { /*lint --e{715}*/
507  SCIP_CONSDATA* consdata;
508 
509  consdata = SCIPconsGetData(cons);
510  assert(consdata != NULL);
511 
512  consdataPrint(scip, consdata, file);
513 
514  return SCIP_OKAY;
515 }
516 
517 /**@} */
518 
519 /**@name Interface methods
520  *
521  * @{
522  */
523 
524 /** creates the handler for samediff constraints and includes it in SCIP */
526  SCIP* scip /**< SCIP data structure */
527  )
528 {
529  SCIP_CONSHDLRDATA* conshdlrdata = NULL;
530  SCIP_CONSHDLR* conshdlr = NULL;
531 
532  /* include constraint handler */
536  conshdlrdata) );
537  assert(conshdlr != NULL);
538 
539  SCIP_CALL( SCIPsetConshdlrDelete(scip, conshdlr, consDeleteSamediff) );
540  SCIP_CALL( SCIPsetConshdlrTrans(scip, conshdlr, consTransSamediff) );
541  SCIP_CALL( SCIPsetConshdlrProp(scip, conshdlr, consPropSamediff, CONSHDLR_PROPFREQ, CONSHDLR_DELAYPROP,
543  SCIP_CALL( SCIPsetConshdlrActive(scip, conshdlr, consActiveSamediff) );
544  SCIP_CALL( SCIPsetConshdlrDeactive(scip, conshdlr, consDeactiveSamediff) );
545  SCIP_CALL( SCIPsetConshdlrPrint(scip, conshdlr, consPrintSamediff) );
546 
547  return SCIP_OKAY;
548 }
549 
550 /** creates and captures a samediff constraint */
552  SCIP* scip, /**< SCIP data structure */
553  SCIP_CONS** cons, /**< pointer to hold the created constraint */
554  const char* name, /**< name of constraint */
555  int itemid1, /**< item id one */
556  int itemid2, /**< item id two */
557  CONSTYPE type, /**< stores whether the items have to be in the SAME or DIFFER packing */
558  SCIP_NODE* node, /**< the node in the B&B-tree at which the cons is sticking */
559  SCIP_Bool local /**< is constraint only valid locally? */
560  )
561 {
562  SCIP_CONSHDLR* conshdlr;
563  SCIP_CONSDATA* consdata;
564 
565  /* find the samediff constraint handler */
566  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
567  if( conshdlr == NULL )
568  {
569  SCIPerrorMessage("samediff constraint handler not found\n");
570  return SCIP_PLUGINNOTFOUND;
571  }
572 
573  /* create the constraint specific data */
574  SCIP_CALL( consdataCreate(scip, &consdata, itemid1, itemid2, type, node) );
575 
576  /* create constraint */
577  SCIP_CALL( SCIPcreateCons(scip, cons, name, conshdlr, consdata, FALSE, FALSE, FALSE, FALSE, TRUE,
578  local, FALSE, FALSE, FALSE, TRUE) );
579 
580  SCIPdebugMsg(scip, "created constraint: ");
581  SCIPdebug( consdataPrint(scip, consdata, NULL) );
582 
583  return SCIP_OKAY;
584 }
585 
586 /** returns item id one */
588  SCIP* scip, /**< SCIP data structure */
589  SCIP_CONS* cons /**< samediff constraint */
590  )
591 {
592  SCIP_CONSDATA* consdata;
593 
594  assert(cons != NULL);
595 
596  consdata = SCIPconsGetData(cons);
597  assert(consdata != NULL);
598 
599  return consdata->itemid1;
600 }
601 
602 /** returns item id two */
604  SCIP* scip, /**< SCIP data structure */
605  SCIP_CONS* cons /**< samediff constraint */
606  )
607 {
608  SCIP_CONSDATA* consdata;
609 
610  assert(cons != NULL);
611 
612  consdata = SCIPconsGetData(cons);
613  assert(consdata != NULL);
614 
615  return consdata->itemid2;
616 }
617 
618 /** return constraint type SAME or DIFFER */
620  SCIP* scip, /**< SCIP data structure */
621  SCIP_CONS* cons /**< samediff constraint */
622  )
623 {
624  SCIP_CONSDATA* consdata;
625 
626  assert(cons != NULL);
627 
628  consdata = SCIPconsGetData(cons);
629  assert(consdata != NULL);
630 
631  return consdata->type;
632 }
633 
634 /**@} */
enum SCIP_Result SCIP_RESULT
Definition: type_result.h:52
SCIP_RETCODE SCIPsetConshdlrDelete(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSDELETE((*consdelete)))
Definition: scip_cons.c:640
#define NULL
Definition: def.h:239
static SCIP_DECL_CONSDELETE(consDeleteSamediff)
SCIP_STAGE SCIPgetStage(SCIP *scip)
Definition: scip_general.c:412
void SCIPvardataPrint(SCIP *scip, SCIP_VARDATA *vardata, FILE *file)
SCIP_Bool SCIPconsIsDynamic(SCIP_CONS *cons)
Definition: cons.c:8335
SCIP_RETCODE SCIPsetConshdlrTrans(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSTRANS((*constrans)))
Definition: scip_cons.c:663
SCIP_CONSHDLR * SCIPfindConshdlr(SCIP *scip, const char *name)
Definition: scip_cons.c:954
SCIP_VAR ** SCIPprobdataGetVars(SCIP *scip)
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
Definition: var.c:17399
static SCIP_DECL_CONSDEACTIVE(consDeactiveSamediff)
SCIP_RETCODE SCIPsetConshdlrDeactive(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSDEACTIVE((*consdeactive)))
Definition: scip_cons.c:755
static SCIP_RETCODE checkVariable(SCIP *scip, SCIP_CONSDATA *consdata, SCIP_VAR *var, int *nfixedvars, SCIP_Bool *cutoff)
Constraint handler stores the local branching decision data.
CONSTYPE
Definition: reader_osil.c:59
SCIP_RETCODE SCIPcreateConsSamediff(SCIP *scip, SCIP_CONS **cons, const char *name, int itemid1, int itemid2, CONSTYPE type, SCIP_NODE *node, SCIP_Bool local)
#define consEnfolpSamediff
#define FALSE
Definition: def.h:65
struct SCIP_VarData SCIP_VARDATA
Definition: type_var.h:107
SCIP_RETCODE SCIPincludeConshdlrBasic(SCIP *scip, SCIP_CONSHDLR **conshdlrptr, const char *name, const char *desc, int enfopriority, int chckpriority, int eagerfreq, SCIP_Bool needscons, SCIP_DECL_CONSENFOLP((*consenfolp)), SCIP_DECL_CONSENFOPS((*consenfops)), SCIP_DECL_CONSCHECK((*conscheck)), SCIP_DECL_CONSLOCK((*conslock)), SCIP_CONSHDLRDATA *conshdlrdata)
Definition: scip_cons.c:243
#define TRUE
Definition: def.h:64
#define SCIPdebug(x)
Definition: pub_message.h:74
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:53
static void consdataPrint(SCIP *scip, SCIP_CONSDATA *consdata, FILE *file)
SCIP_Bool SCIPconsIsStickingAtNode(SCIP_CONS *cons)
Definition: cons.c:8355
int SCIPprobdataGetNVars(SCIP *scip)
#define CONSHDLR_NAME
Definition: cons_samediff.c:40
Variable data containing the ids of constraints in which the variable appears.
#define SCIPfreeBlockMemory(scip, ptr)
Definition: scip_mem.h:114
int SCIPnodeGetDepth(SCIP_NODE *node)
Definition: tree.c:7354
int * SCIPvardataGetConsids(SCIP_VARDATA *vardata)
#define SCIPallocBlockMemory(scip, ptr)
Definition: scip_mem.h:97
SCIP_Bool SCIPconsIsRemovable(SCIP_CONS *cons)
Definition: cons.c:8345
#define SCIPdebugMsg
Definition: scip_message.h:88
void SCIPinfoMessage(SCIP *scip, FILE *file, const char *formatstr,...)
Definition: scip_message.c:279
SCIP_RETCODE SCIPcreateCons(SCIP *scip, SCIP_CONS **cons, const char *name, SCIP_CONSHDLR *conshdlr, SCIP_CONSDATA *consdata, SCIP_Bool initial, SCIP_Bool separate, SCIP_Bool enforce, SCIP_Bool check, SCIP_Bool propagate, SCIP_Bool local, SCIP_Bool modifiable, SCIP_Bool dynamic, SCIP_Bool removable, SCIP_Bool stickingatnode)
Definition: scip_cons.c:1011
SCIP_RETCODE SCIPrepropagateNode(SCIP *scip, SCIP_NODE *node)
Definition: scip_tree.c:522
#define CONSHDLR_DELAYPROP
Definition: cons_samediff.c:48
SCIP_Longint SCIPnodeGetNumber(SCIP_NODE *node)
Definition: tree.c:7344
#define CONSHDLR_PROP_TIMING
Definition: cons_samediff.c:51
#define CONSHDLR_ENFOPRIORITY
Definition: cons_samediff.c:42
#define CONSHDLR_NEEDSCONS
Definition: cons_samediff.c:49
#define SCIPerrorMessage
Definition: pub_message.h:45
const char * SCIPconshdlrGetName(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4191
int SCIPgetItemid2Samediff(SCIP *scip, SCIP_CONS *cons)
const char * SCIPconsGetName(SCIP_CONS *cons)
Definition: cons.c:8076
int SCIPgetNChildren(SCIP *scip)
Definition: scip_tree.c:255
SCIP_Bool SCIPconsIsPropagated(SCIP_CONS *cons)
Definition: cons.c:8295
#define SCIP_CALL(x)
Definition: def.h:351
#define consEnfopsSamediff
SCIP_Bool SCIPconsIsLocal(SCIP_CONS *cons)
Definition: cons.c:8315
struct SCIP_ConsData SCIP_CONSDATA
Definition: type_cons.h:51
SCIP_Bool SCIPsortedvecFindInt(int *intarray, int val, int len, int *pos)
int * SCIPprobdataGetIds(SCIP_PROBDATA *probdata)
#define CONSHDLR_EAGERFREQ
Definition: cons_samediff.c:45
static SCIP_RETCODE consdataCreate(SCIP *scip, SCIP_CONSDATA **consdata, int itemid1, int itemid2, CONSTYPE type, SCIP_NODE *node)
Definition: cons_samediff.c:80
#define SCIP_Bool
Definition: def.h:62
SCIP_RETCODE SCIPincludeConshdlrSamediff(SCIP *scip)
Problem data for binpacking problem.
CONSTYPE SCIPgetTypeSamediff(SCIP *scip, SCIP_CONS *cons)
static SCIP_Bool consdataCheck(SCIP *scip, SCIP_PROBDATA *probdata, SCIP_CONSDATA *consdata, SCIP_Bool beforeprop)
SCIP_VARDATA * SCIPvarGetData(SCIP_VAR *var)
Definition: var.c:16749
SCIP_Bool SCIPconsIsChecked(SCIP_CONS *cons)
Definition: cons.c:8275
SCIP_Bool SCIPconsIsInitial(SCIP_CONS *cons)
Definition: cons.c:8245
SCIP_RETCODE SCIPfixVar(SCIP *scip, SCIP_VAR *var, SCIP_Real fixedval, SCIP_Bool *infeasible, SCIP_Bool *fixed)
Definition: scip_var.c:8168
#define CONSHDLR_DESC
Definition: cons_samediff.c:41
static SCIP_RETCODE consdataFixVariables(SCIP *scip, SCIP_CONSDATA *consdata, SCIP_VAR **vars, int nvars, SCIP_RESULT *result)
SCIP_RETCODE SCIPsetConshdlrPrint(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSPRINT((*consprint)))
Definition: scip_cons.c:847
int SCIPgetItemid1Samediff(SCIP *scip, SCIP_CONS *cons)
static SCIP_DECL_CONSPRINT(consPrintSamediff)
#define consCheckSamediff
#define CONSHDLR_PROPFREQ
Definition: cons_samediff.c:44
#define SCIP_LONGINT_FORMAT
Definition: def.h:142
static SCIP_DECL_CONSTRANS(consTransSamediff)
struct SCIP_ProbData SCIP_PROBDATA
Definition: type_prob.h:44
SCIP_CONSDATA * SCIPconsGetData(SCIP_CONS *cons)
Definition: cons.c:8106
SCIP_PROBDATA * SCIPgetProbData(SCIP *scip)
Definition: scip_prob.c:1020
static SCIP_RETCODE consdataFree(SCIP *scip, SCIP_CONSDATA **consdata)
int SCIPvardataGetNConsids(SCIP_VARDATA *vardata)
SCIP_Bool SCIPconsIsModifiable(SCIP_CONS *cons)
Definition: cons.c:8325
SCIP_Bool SCIPconsIsEnforced(SCIP_CONS *cons)
Definition: cons.c:8265
SCIP_Bool SCIPconsIsSeparated(SCIP_CONS *cons)
Definition: cons.c:8255
#define consLockSamediff
#define CONSHDLR_CHECKPRIORITY
Definition: cons_samediff.c:43
struct SCIP_ConshdlrData SCIP_CONSHDLRDATA
Definition: type_cons.h:50
static SCIP_DECL_CONSPROP(consPropSamediff)
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
Definition: var.c:17409
SCIP_RETCODE SCIPsetConshdlrActive(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSACTIVE((*consactive)))
Definition: scip_cons.c:732
static SCIP_DECL_CONSACTIVE(consActiveSamediff)
SCIP_RETCODE SCIPprintVar(SCIP *scip, SCIP_VAR *var, FILE *file)
Definition: scip_var.c:9684
SCIP_RETCODE SCIPsetConshdlrProp(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSPROP((*consprop)), int propfreq, SCIP_Bool delayprop, SCIP_PROPTIMING proptiming)
Definition: scip_cons.c:343