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