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-2022 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SCIP; see the file COPYING. If not visit scipopt.org. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file 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 %" SCIP_LONGINT_FORMAT "\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  return TRUE;
284 }
285 #endif
286 
287 /** frees samediff constraint data */
288 static
290  SCIP* scip, /**< SCIP data structure */
291  SCIP_CONSDATA** consdata /**< pointer to the constraint data */
292  )
293 {
294  assert(consdata != NULL);
295  assert(*consdata != NULL);
296 
297  SCIPfreeBlockMemory(scip, consdata);
298 
299  return SCIP_OKAY;
300 }
301 
302 /**@} */
303 
304 
305 /**@name Callback methods
306  *
307  * @{
308  */
309 
310 /** frees specific constraint data */
311 static
312 SCIP_DECL_CONSDELETE(consDeleteSamediff)
313 { /*lint --e{715}*/
314  assert(conshdlr != NULL);
315  assert(strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0);
316  assert(consdata != NULL);
317  assert(*consdata != NULL);
318 
319  /* free samediff constraint */
320  SCIP_CALL( consdataFree(scip, consdata) );
321 
322  return SCIP_OKAY;
323 }
324 
325 /** transforms constraint data into data belonging to the transformed problem */
326 static
327 SCIP_DECL_CONSTRANS(consTransSamediff)
328 { /*lint --e{715}*/
329  SCIP_CONSDATA* sourcedata;
330  SCIP_CONSDATA* targetdata;
331 
332  assert(conshdlr != NULL);
333  assert(strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0);
334  assert(SCIPgetStage(scip) == SCIP_STAGE_TRANSFORMING);
335  assert(sourcecons != NULL);
336  assert(targetcons != NULL);
337 
338  sourcedata = SCIPconsGetData(sourcecons);
339  assert(sourcedata != NULL);
340 
341  /* create constraint data for target constraint */
342  SCIP_CALL( consdataCreate(scip, &targetdata,
343  sourcedata->itemid1, sourcedata->itemid2, sourcedata->type, sourcedata->node) );
344 
345  /* create target constraint */
346  SCIP_CALL( SCIPcreateCons(scip, targetcons, SCIPconsGetName(sourcecons), conshdlr, targetdata,
347  SCIPconsIsInitial(sourcecons), SCIPconsIsSeparated(sourcecons), SCIPconsIsEnforced(sourcecons),
348  SCIPconsIsChecked(sourcecons), SCIPconsIsPropagated(sourcecons),
349  SCIPconsIsLocal(sourcecons), SCIPconsIsModifiable(sourcecons),
350  SCIPconsIsDynamic(sourcecons), SCIPconsIsRemovable(sourcecons), SCIPconsIsStickingAtNode(sourcecons)) );
351 
352  return SCIP_OKAY;
353 }
354 
355 /** constraint enforcing method of constraint handler for LP solutions */
356 #define consEnfolpSamediff NULL
358 /** constraint enforcing method of constraint handler for pseudo solutions */
359 #define consEnfopsSamediff NULL
361 /** feasibility check method of constraint handler for integral solutions */
362 #define consCheckSamediff NULL
364 /** domain propagation method of constraint handler */
365 static
366 SCIP_DECL_CONSPROP(consPropSamediff)
367 { /*lint --e{715}*/
368  SCIP_PROBDATA* probdata;
369  SCIP_CONSDATA* consdata;
370 
371  SCIP_VAR** vars;
372  int nvars;
373  int c;
374 
375  assert(scip != NULL);
376  assert(strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0);
377  assert(result != NULL);
378 
379  SCIPdebugMsg(scip, "propagation constraints of constraint handler <"CONSHDLR_NAME">\n");
380 
381  probdata = SCIPgetProbData(scip);
382  assert(probdata != NULL);
383 
384  vars = SCIPprobdataGetVars(probdata);
385  nvars = SCIPprobdataGetNVars(probdata);
386 
387  *result = SCIP_DIDNOTFIND;
388 
389  for( c = 0; c < nconss; ++c )
390  {
391  consdata = SCIPconsGetData(conss[c]);
392 
393  /* check if all previously generated variables are valid for this constraint */
394  assert( consdataCheck(scip, probdata, consdata, TRUE) );
395 
396 #ifndef NDEBUG
397  {
398  /* check if there are no equal consdatas */
399  SCIP_CONSDATA* consdata2;
400  int i;
401 
402  for( i = c+1; i < nconss; ++i )
403  {
404  consdata2 = SCIPconsGetData(conss[i]);
405  assert( !(consdata->itemid1 == consdata2->itemid1
406  && consdata->itemid2 == consdata2->itemid2
407  && consdata->type == consdata2->type) );
408  assert( !(consdata->itemid1 == consdata2->itemid2
409  && consdata->itemid2 == consdata2->itemid1
410  && consdata->type == consdata2->type) );
411  }
412  }
413 #endif
414 
415  if( !consdata->propagated )
416  {
417  SCIPdebugMsg(scip, "propagate constraint <%s> ", SCIPconsGetName(conss[c]));
418  SCIPdebug( consdataPrint(scip, consdata, NULL) );
419 
420  SCIP_CALL( consdataFixVariables(scip, consdata, vars, nvars, result) );
421  consdata->npropagations++;
422 
423  if( *result != SCIP_CUTOFF )
424  {
425  consdata->propagated = TRUE;
426  consdata->npropagatedvars = nvars;
427  }
428  else
429  break;
430  }
431 
432  /* check if constraint is completely propagated */
433  assert( consdataCheck(scip, probdata, consdata, FALSE) );
434  }
435 
436  return SCIP_OKAY;
437 }
438 
439 /** variable rounding lock method of constraint handler */
440 #define consLockSamediff NULL
442 /** constraint activation notification method of constraint handler */
443 static
444 SCIP_DECL_CONSACTIVE(consActiveSamediff)
445 { /*lint --e{715}*/
446  SCIP_CONSDATA* consdata;
447  SCIP_PROBDATA* probdata;
448 
449  assert(scip != NULL);
450  assert(strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0);
451  assert(cons != NULL);
452 
453  probdata = SCIPgetProbData(scip);
454  assert(probdata != NULL);
455 
456  consdata = SCIPconsGetData(cons);
457  assert(consdata != NULL);
458  assert(consdata->npropagatedvars <= SCIPprobdataGetNVars(probdata));
459 
460  SCIPdebugMsg(scip, "activate constraint <%s> at node <%"SCIP_LONGINT_FORMAT"> in depth <%d>: ",
461  SCIPconsGetName(cons), SCIPnodeGetNumber(consdata->node), SCIPnodeGetDepth(consdata->node));
462  SCIPdebug( consdataPrint(scip, consdata, NULL) );
463 
464  if( consdata->npropagatedvars != SCIPprobdataGetNVars(probdata) )
465  {
466  SCIPdebugMsg(scip, "-> mark constraint to be repropagated\n");
467  consdata->propagated = FALSE;
468  SCIP_CALL( SCIPrepropagateNode(scip, consdata->node) );
469  }
470 
471  return SCIP_OKAY;
472 }
473 
474 /** constraint deactivation notification method of constraint handler */
475 static
476 SCIP_DECL_CONSDEACTIVE(consDeactiveSamediff)
477 { /*lint --e{715}*/
478  SCIP_CONSDATA* consdata;
479  SCIP_PROBDATA* probdata;
480 
481  assert(scip != NULL);
482  assert(strcmp(SCIPconshdlrGetName(conshdlr), CONSHDLR_NAME) == 0);
483  assert(cons != NULL);
484 
485  consdata = SCIPconsGetData(cons);
486  assert(consdata != NULL);
487  assert(consdata->propagated || SCIPgetNChildren(scip) == 0);
488 
489  probdata = SCIPgetProbData(scip);
490  assert(probdata != NULL);
491 
492  SCIPdebugMsg(scip, "deactivate constraint <%s> at node <%"SCIP_LONGINT_FORMAT"> in depth <%d>: ",
493  SCIPconsGetName(cons), SCIPnodeGetNumber(consdata->node), SCIPnodeGetDepth(consdata->node));
494  SCIPdebug( consdataPrint(scip, consdata, NULL) );
495 
496  /* set the number of propagated variables to current number of variables is SCIP */
497  consdata->npropagatedvars = SCIPprobdataGetNVars(probdata);
498 
499  return SCIP_OKAY;
500 }
501 
502 /** constraint display method of constraint handler */
503 static
504 SCIP_DECL_CONSPRINT(consPrintSamediff)
505 { /*lint --e{715}*/
506  SCIP_CONSDATA* consdata;
507 
508  consdata = SCIPconsGetData(cons);
509  assert(consdata != NULL);
510 
511  consdataPrint(scip, consdata, file);
512 
513  return SCIP_OKAY;
514 }
515 
516 /**@} */
517 
518 /**@name Interface methods
519  *
520  * @{
521  */
522 
523 /** creates the handler for samediff constraints and includes it in SCIP */
525  SCIP* scip /**< SCIP data structure */
526  )
527 {
528  SCIP_CONSHDLRDATA* conshdlrdata = NULL;
529  SCIP_CONSHDLR* conshdlr = NULL;
530 
531  /* include constraint handler */
535  conshdlrdata) );
536  assert(conshdlr != NULL);
537 
538  SCIP_CALL( SCIPsetConshdlrDelete(scip, conshdlr, consDeleteSamediff) );
539  SCIP_CALL( SCIPsetConshdlrTrans(scip, conshdlr, consTransSamediff) );
540  SCIP_CALL( SCIPsetConshdlrProp(scip, conshdlr, consPropSamediff, CONSHDLR_PROPFREQ, CONSHDLR_DELAYPROP,
542  SCIP_CALL( SCIPsetConshdlrActive(scip, conshdlr, consActiveSamediff) );
543  SCIP_CALL( SCIPsetConshdlrDeactive(scip, conshdlr, consDeactiveSamediff) );
544  SCIP_CALL( SCIPsetConshdlrPrint(scip, conshdlr, consPrintSamediff) );
545 
546  return SCIP_OKAY;
547 }
548 
549 /** creates and captures a samediff constraint */
551  SCIP* scip, /**< SCIP data structure */
552  SCIP_CONS** cons, /**< pointer to hold the created constraint */
553  const char* name, /**< name of constraint */
554  int itemid1, /**< item id one */
555  int itemid2, /**< item id two */
556  CONSTYPE type, /**< stores whether the items have to be in the SAME or DIFFER packing */
557  SCIP_NODE* node, /**< the node in the B&B-tree at which the cons is sticking */
558  SCIP_Bool local /**< is constraint only valid locally? */
559  )
560 {
561  SCIP_CONSHDLR* conshdlr;
562  SCIP_CONSDATA* consdata;
563 
564  /* find the samediff constraint handler */
565  conshdlr = SCIPfindConshdlr(scip, CONSHDLR_NAME);
566  if( conshdlr == NULL )
567  {
568  SCIPerrorMessage("samediff constraint handler not found\n");
569  return SCIP_PLUGINNOTFOUND;
570  }
571 
572  /* create the constraint specific data */
573  SCIP_CALL( consdataCreate(scip, &consdata, itemid1, itemid2, type, node) );
574 
575  /* create constraint */
576  SCIP_CALL( SCIPcreateCons(scip, cons, name, conshdlr, consdata, FALSE, FALSE, FALSE, FALSE, TRUE,
577  local, FALSE, FALSE, FALSE, TRUE) );
578 
579  SCIPdebugMsg(scip, "created constraint: ");
580  SCIPdebug( consdataPrint(scip, consdata, NULL) );
581 
582  return SCIP_OKAY;
583 }
584 
585 /** returns item id one */
587  SCIP* scip, /**< SCIP data structure */
588  SCIP_CONS* cons /**< samediff constraint */
589  )
590 {
591  SCIP_CONSDATA* consdata;
592 
593  assert(cons != NULL);
594 
595  consdata = SCIPconsGetData(cons);
596  assert(consdata != NULL);
597 
598  return consdata->itemid1;
599 }
600 
601 /** returns item id two */
603  SCIP* scip, /**< SCIP data structure */
604  SCIP_CONS* cons /**< samediff constraint */
605  )
606 {
607  SCIP_CONSDATA* consdata;
608 
609  assert(cons != NULL);
610 
611  consdata = SCIPconsGetData(cons);
612  assert(consdata != NULL);
613 
614  return consdata->itemid2;
615 }
616 
617 /** return constraint type SAME or DIFFER */
619  SCIP* scip, /**< SCIP data structure */
620  SCIP_CONS* cons /**< samediff constraint */
621  )
622 {
623  SCIP_CONSDATA* consdata;
624 
625  assert(cons != NULL);
626 
627  consdata = SCIPconsGetData(cons);
628  assert(consdata != NULL);
629 
630  return consdata->type;
631 }
632 
633 /**@} */
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:563
static SCIP_DECL_CONSDELETE(consDeleteSamediff)
SCIP_STAGE SCIPgetStage(SCIP *scip)
Definition: scip_general.c:356
void SCIPvardataPrint(SCIP *scip, SCIP_VARDATA *vardata, FILE *file)
SCIP_Bool SCIPconsIsDynamic(SCIP_CONS *cons)
Definition: cons.c:8344
SCIP_RETCODE SCIPsetConshdlrTrans(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSTRANS((*constrans)))
Definition: scip_cons.c:586
SCIP_CONSHDLR * SCIPfindConshdlr(SCIP *scip, const char *name)
Definition: scip_cons.c:877
SCIP_VAR ** SCIPprobdataGetVars(SCIP *scip)
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
Definition: var.c:17966
static SCIP_DECL_CONSDEACTIVE(consDeactiveSamediff)
SCIP_RETCODE SCIPsetConshdlrDeactive(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSDEACTIVE((*consdeactive)))
Definition: scip_cons.c:678
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.
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:87
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:166
#define TRUE
Definition: def.h:86
#define SCIPdebug(x)
Definition: pub_message.h:84
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:54
static void consdataPrint(SCIP *scip, SCIP_CONSDATA *consdata, FILE *file)
SCIP_Bool SCIPconsIsStickingAtNode(SCIP_CONS *cons)
Definition: cons.c:8364
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:99
int SCIPnodeGetDepth(SCIP_NODE *node)
Definition: tree.c:7442
int * SCIPvardataGetConsids(SCIP_VARDATA *vardata)
SCIP_Bool SCIPconsIsRemovable(SCIP_CONS *cons)
Definition: cons.c:8354
#define SCIPdebugMsg
Definition: scip_message.h:69
void SCIPinfoMessage(SCIP *scip, FILE *file, const char *formatstr,...)
Definition: scip_message.c:199
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:934
SCIP_RETCODE SCIPrepropagateNode(SCIP *scip, SCIP_NODE *node)
Definition: scip_tree.c:468
#define CONSHDLR_DELAYPROP
Definition: cons_samediff.c:48
SCIP_Longint SCIPnodeGetNumber(SCIP_NODE *node)
Definition: tree.c:7432
#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:55
const char * SCIPconshdlrGetName(SCIP_CONSHDLR *conshdlr)
Definition: cons.c:4175
int SCIPgetItemid2Samediff(SCIP *scip, SCIP_CONS *cons)
const char * SCIPconsGetName(SCIP_CONS *cons)
Definition: cons.c:8085
int SCIPgetNChildren(SCIP *scip)
Definition: scip_tree.c:179
SCIP_Bool SCIPconsIsPropagated(SCIP_CONS *cons)
Definition: cons.c:8304
#define NULL
Definition: lpi_spx1.cpp:155
#define SCIP_CALL(x)
Definition: def.h:384
#define consEnfopsSamediff
SCIP_Bool SCIPconsIsLocal(SCIP_CONS *cons)
Definition: cons.c:8324
struct SCIP_ConsData SCIP_CONSDATA
Definition: type_cons.h:56
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:84
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:17271
SCIP_Bool SCIPconsIsChecked(SCIP_CONS *cons)
Definition: cons.c:8284
SCIP_Bool SCIPconsIsInitial(SCIP_CONS *cons)
Definition: cons.c:8254
SCIP_RETCODE SCIPfixVar(SCIP *scip, SCIP_VAR *var, SCIP_Real fixedval, SCIP_Bool *infeasible, SCIP_Bool *fixed)
Definition: scip_var.c:8273
#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:770
int SCIPgetItemid1Samediff(SCIP *scip, SCIP_CONS *cons)
static SCIP_DECL_CONSPRINT(consPrintSamediff)
#define consCheckSamediff
#define CONSHDLR_PROPFREQ
Definition: cons_samediff.c:44
static SCIP_DECL_CONSTRANS(consTransSamediff)
struct SCIP_ProbData SCIP_PROBDATA
Definition: type_prob.h:44
SCIP_CONSDATA * SCIPconsGetData(SCIP_CONS *cons)
Definition: cons.c:8115
SCIP_PROBDATA * SCIPgetProbData(SCIP *scip)
Definition: scip_prob.c:962
static SCIP_RETCODE consdataFree(SCIP *scip, SCIP_CONSDATA **consdata)
int SCIPvardataGetNConsids(SCIP_VARDATA *vardata)
SCIP_Bool SCIPconsIsModifiable(SCIP_CONS *cons)
Definition: cons.c:8334
SCIP_Bool SCIPconsIsEnforced(SCIP_CONS *cons)
Definition: cons.c:8274
SCIP_Bool SCIPconsIsSeparated(SCIP_CONS *cons)
Definition: cons.c:8264
#define consLockSamediff
#define CONSHDLR_CHECKPRIORITY
Definition: cons_samediff.c:43
struct SCIP_ConshdlrData SCIP_CONSHDLRDATA
Definition: type_cons.h:55
static SCIP_DECL_CONSPROP(consPropSamediff)
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
Definition: var.c:17976
SCIP_RETCODE SCIPsetConshdlrActive(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSACTIVE((*consactive)))
Definition: scip_cons.c:655
SCIPallocBlockMemory(scip, subsol))
enum ConsType CONSTYPE
Definition: cons_samediff.h:40
static SCIP_DECL_CONSACTIVE(consActiveSamediff)
SCIP_RETCODE SCIPprintVar(SCIP *scip, SCIP_VAR *var, FILE *file)
Definition: scip_var.c:9882
SCIP_RETCODE SCIPsetConshdlrProp(SCIP *scip, SCIP_CONSHDLR *conshdlr, SCIP_DECL_CONSPROP((*consprop)), int propfreq, SCIP_Bool delayprop, SCIP_PROPTIMING proptiming)
Definition: scip_cons.c:266