Scippy

GCG

Branch-and-Price & Column Generation for Everyone

rowgraph_weighted_def.h
Go to the documentation of this file.
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2/* */
3/* This file is part of the program and library */
4/* GCG --- Generic Column Generation */
5/* a Dantzig-Wolfe decomposition based extension */
6/* of the branch-cut-and-price framework */
7/* SCIP --- Solving Constraint Integer Programs */
8/* */
9/* Copyright (C) 2010-2026 Operations Research, RWTH Aachen University */
10/* Zuse Institute Berlin (ZIB) */
11/* */
12/* Licensed under the Apache License, Version 2.0 (the "License"); */
13/* you may not use this file except in compliance with the License. */
14/* You may obtain a copy of the License at */
15/* */
16/* http://www.apache.org/licenses/LICENSE-2.0 */
17/* */
18/* Unless required by applicable law or agreed to in writing, software */
19/* distributed under the License is distributed on an "AS IS" BASIS, */
20/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
21/* See the License for the specific language governing permissions and */
22/* limitations under the License. */
23/* */
24/* You should have received a copy of the Apache-2.0 license */
25/* along with GCG; see the file LICENSE. If not visit gcg.or.rwth-aachen.de.*/
26/* */
27/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
28
29/**@file rowgraph_weighted_def.h
30 * @brief A row graph where each row is a node and rows are adjacent if they share a variable.
31 * The edges are weighted according to specified similarity measure.
32 * @author Igor Pesic
33 */
34
35/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
36// #define SCIP_DEBUG
37
38#ifndef GCG_ROWGRAPH_WEIGHTED_DEF_H_
39#define GCG_ROWGRAPH_WEIGHTED_DEF_H_
40
42#include "graph/graph_gcg.h"
45#include <algorithm>
46#include <iostream>
47#include <vector>
48#include <map>
49#include <set>
50#include <climits>
51#include <queue>
52
53using namespace std;
54
55namespace gcg {
56
57template <class T>
59 GCG* gcgstruct, /**< GCG data structure */
60 Weights w /**< weights for the given graph */
61 ) : RowGraph<T>(gcgstruct,w)
62{
63 this->name = string("rowgraph_weighted");
64 n_blocks = -1;
65 non_cl = INT_MAX;
66}
67
68template <class T>
70{
71 // Auto-generated destructor stub
72}
73
74
75template <class T>
77 SCIP_CONS** conss, /**< constraints for which graph should be created */
78 SCIP_VAR** vars, /**< variables for which graph should be created */
79 int nconss_, /**< number of constraints */
80 int nvars_, /**< number of variables */
81 DISTANCE_MEASURE dist, /**< Here we define the distance measure between two rows */
82 WEIGHT_TYPE w_type /**< Depending on the algorithm we can build distance or similarity graph */
83 )
84{
85 int i;
86 int j;
87 int k;
88 int l;
89 SCIP_Bool success;
90 SCIP* scip = GCGgetOrigprob(this->gcg);
91
92 assert(conss != NULL);
93 assert(vars != NULL);
94 assert(nvars_ > 0);
95 assert(nconss_ > 0);
96
97 this->nvars = nvars_;
98 this->nconss = nconss_;
99
100 SCIP_CALL( this->graph.addNNodes(this->nconss) );
101
102 /* go through all constraints */
103 for( i = 0; i < this->nconss; ++i )
104 {
105 SCIP_VAR** curvars1 = NULL;
106
107 int ncurvars1;
108 SCIP_CALL( SCIPgetConsNVars(scip, conss[i], &ncurvars1, &success) );
109 assert(success);
110 if( ncurvars1 == 0 )
111 continue;
112
113 /*
114 * may work as is, as we are copying the constraint later regardless
115 * if there are variables in it or not
116 */
117 SCIP_CALL( SCIPallocBufferArray(scip, &curvars1, ncurvars1) );
118 SCIP_CALL( SCIPgetConsVars(scip, conss[i], curvars1, ncurvars1, &success) );
119 assert(success);
120
121 /* go through all constraints again */
122 for( j = 0; j < i; ++j )
123 {
124 SCIP_VAR** curvars2 = NULL;
125 int ncurvars2;
126 SCIP_CALL( SCIPgetConsNVars(scip, conss[j], &ncurvars2, &success) );
127 assert(success);
128 if( ncurvars2 == 0 )
129 continue;
130
131
132 /*
133 * may work as is, as we are copying the constraint later regardless
134 * if there are variables in it or not
135 */
136 SCIP_CALL( SCIPallocBufferArray(scip, &curvars2, ncurvars2) );
137 SCIP_CALL( SCIPgetConsVars(scip, conss[j], curvars2, ncurvars2, &success) );
138 assert(success);
139
140
141 /** @todo skip all variables that have a zero coeffient or where all coefficients add to zero */
142 /** @todo Do more then one entry per variable actually work? */
143
144 int a = 0; // number of common variables
145 int b = 0; // number of variables that appear ONLY in the second row
146 int c = 0; // number of variables that appear ONLY in the first row
147 for( k = 0; k < ncurvars1; ++k )
148 {
149 SCIP_VAR* var1 = NULL;
150 int varIndex1;
151
152 if( !GCGisVarRelevant(curvars1[k]) )
153 continue;
154
156 var1 = SCIPvarGetProbvar(curvars1[k]);
157 else
158 var1 = curvars1[k];
159
160 assert(var1 != NULL);
161 varIndex1 = SCIPvarGetProbindex(var1);
162 assert(varIndex1 >= 0);
163 assert(varIndex1 < this->nvars);
164
165 for( l = 0; l < ncurvars2; ++l )
166 {
167 SCIP_VAR* var2 = NULL;
168 int varIndex2;
169
170 if( !GCGisVarRelevant(curvars2[l]) )
171 continue;
172
174 var2 = SCIPvarGetProbvar(curvars2[l]);
175 else
176 var2 = curvars2[l];
177
178 assert(var2 != NULL);
179 varIndex2 = SCIPvarGetProbindex(var2);
180 assert(varIndex2 >= 0);
181 assert(varIndex2 < this->nvars);
182
183 if(varIndex1 == varIndex2)
184 {
185 a++;
186 break; // stop comparing the variable from the 1st const. with the rest of vars. in the 2nd const.
187 }
188 }
189 }
190 b = ncurvars2 - a;
191 c = ncurvars1 - a;
192 assert(a >= 0); // number of common var
193 assert(b >= 0); // number of variables in the second conss
194 assert(c >= 0); // number of variables in the first conss
195 if(a != 0){
196 double edge_weight = calculateSimilarity(a, b, c, dist, w_type, i==j);
197 this->graph.addEdge(i, j, edge_weight);
198 }
199
200 SCIPfreeBufferArray(scip, &curvars2);
201 }
202 SCIPfreeBufferArray(scip, &curvars1);
203 }
204
205 if(dist == INTERSECTION)
206 {
207 this->graph.normalize();
208 if(w_type == DIST)
209 {
210 return SCIP_INVALIDCALL;
211 }
212 }
213
214 SCIP_CALL( this->graph.flush() );
215
216 assert(this->graph.getNNodes() == nconss_);
217
218 return SCIP_OKAY;
219}
220
221template <class T>
223 DETPROBDATA* detprobdata,
224 PARTIALDECOMP* partialdec,
225 DISTANCE_MEASURE dist, /**< Here we define the distance measure between two rows */
226 WEIGHT_TYPE w_type /**< Depending on the algorithm we can build distance or similarity graph */
227 )
228{
229
230 int i;
231 int j;
232 int k;
233 int l;
234 int m;
235 vector<int> conssForGraph; /** stores the conss included by the graph */
236 vector<int> varsForGraph; /** stores the vars included by the graph */
237 vector<bool> varsBool(partialdec->getNVars(), false); /**< true, if the var will be part of the graph */
238 vector<bool> conssBool(partialdec->getNConss(), false); /**< true, if the cons will be part of the graph */
239 unordered_map<int, int> oldToNewConsIndex; /** stores new index of the conss */
240 unordered_map<int, int> oldToNewVarIndex; /** stores new index of the vars */
241
242 for(int c = 0; c < partialdec->getNOpenconss(); ++c)
243 {
244 int cons = partialdec->getOpenconss()[c];
245 for(int v = 0; v < partialdec->getNOpenvars(); ++v)
246 {
247 int var = partialdec->getOpenvars()[v];
248 for(i = 0; i < detprobdata->getNVarsForCons(cons); ++i)
249 {
250 if(var == detprobdata->getVarsForCons(cons)[i])
251 {
252 varsBool[var] = true;
253 conssBool[cons] = true;
254 }
255 }
256 }
257 }
258
259 for(int v = 0; v < partialdec->getNOpenvars(); ++v)
260 {
261 int var = partialdec->getOpenvars()[v];
262 if(varsBool[var])
263 varsForGraph.push_back(var);
264 }
265 for(int c = 0; c < partialdec->getNOpenconss(); ++c)
266 {
267 int cons = partialdec->getOpenconss()[c];
268 if(conssBool[cons])
269 conssForGraph.push_back(cons);
270 }
271
272 this->nvars = (int)varsForGraph.size();
273 this->nconss = (int)conssForGraph.size();
274 assert(this->nconss > 0);
275 assert(this->nvars > 0);
276
277 for(int v = 0; v < (int)varsForGraph.size(); ++v)
278 {
279 int oldVarId = varsForGraph[v];
280 oldToNewVarIndex.insert({oldVarId,v});
281 }
282 for(int c = 0; c < (int)conssForGraph.size(); ++c)
283 {
284 int oldConsId = conssForGraph[c];
285 oldToNewConsIndex.insert({oldConsId,c});
286 }
287
288
289
290 SCIP_CALL( this->graph.addNNodes(this->nconss) );
291
292 /* go through all constraints */
293 for( i = 0; i < this->nconss; ++i )
294 {
295 int cons1 = conssForGraph[i];
296 assert(conssBool[cons1]);
297
298 /* go through all constraints again */
299 for( j = 0; j < i; ++j )
300 {
301 int cons2 = conssForGraph[j];
302
303 int a = 0; // number of common variables
304 int b = 0; // number of variables that appear ONLY in the second row
305 int c = 0; // number of variables that appear ONLY in the first row
306
307
308 for( k = 0; k < detprobdata->getNVarsForCons(cons1); ++k)
309 {
310 int var1 = detprobdata->getVarsForCons(cons1)[k];
311 if(!varsBool[var1])
312 continue;
313 assert(varsBool[var1]);
314
315 for(l = 0; l < detprobdata->getNVarsForCons(cons2); ++l)
316 {
317 int var2 = detprobdata->getVarsForCons(cons2)[l];
318 if(!varsBool[var2])
319 continue;
320
321 if(var1 == var2)
322 {
323 a++;
324 break; // stop comparing the variable from the 1st const. with the rest of vars. in the 2nd const.
325 }
326 }
327 for(m = 0; m < detprobdata->getNVarsForCons(cons2); ++m)
328 {
329 int var = detprobdata->getVarsForCons(cons2)[m];
330 if(varsBool[var])
331 b++;
332 }
333 b = b - a;
334
335 for(m = 0; m < detprobdata->getNVarsForCons(cons1); ++m)
336 {
337 int var = detprobdata->getVarsForCons(cons1)[m];
338 if(varsBool[var])
339 c++;
340 }
341 c = c - a;
342
343 assert(a >= 0); // number of common var
344 assert(b >= 0); // number of variables in the second conss
345 assert(c >= 0); // number of variables in the first conss
346 if(a != 0){
347 double edge_weight = calculateSimilarity(a, b, c, dist, w_type, i==j);
348 this->graph.addEdge(oldToNewConsIndex[cons1], oldToNewConsIndex[cons2], edge_weight);
349 }
350 }
351 }
352 }
353
354 if(dist == INTERSECTION)
355 {
356 this->graph.normalize();
357 if(w_type == DIST)
358 {
359 return SCIP_INVALIDCALL;
360 }
361 }
362
363 SCIP_CALL( this->graph.flush() );
364
365 return SCIP_OKAY;
366}
367
368template <class T>
369double RowGraphWeighted<T>::calculateSimilarity(int _a, int _b, int _c, DISTANCE_MEASURE dist, WEIGHT_TYPE w_type, bool itself)
370{
371 if(w_type == DIST )
372 {
373 if(_c == 0 && _b == 0) return 1e-10;
374 }
375 else
376 {
377 if(_c == 0 && _b == 0) return (1.0 - 1e-10);
378 }
379 double result = 0.0;
380 double a = (double)_a;
381 double b = (double)_b;
382 double c = (double)_c;
383 switch( dist ) {
384 case JOHNSON:
385 result = (a/(a+b) + a/(a+c)) / 2.0;
386 break;
387 case INTERSECTION:
388 result = a;
389 break;
390 case JACCARD:
391 result = a / (a+b+c);
392 break;
393 case COSINE:
394 result = a / (sqrt(a+b)*sqrt(a+c));
395 break;
396 case SIMPSON:
397 result = a / MIN(a+b, a+c);
398 break;
399 }
400
401
402
403 if(dist != INTERSECTION)
404 {
405 assert(result >= 0.0);
406 assert(result <= 1.0);
407 }
408
409 if(!itself)
410 {
411 result *= (1 - 1e-10);
412 }
413
414 if(w_type == DIST && dist != INTERSECTION)
415 {
416 result = 1.0 - result;
417 }
418
419 return result;
420}
421
422template <>
423SCIP_RETCODE RowGraphWeighted<GraphGCG>::postProcess(vector<int>& labels, bool enabled)
424{
425 SCIP* scip = GCGgetOrigprob(this->gcg);
426 assert((int)labels.size() == graph.getNNodes());
427 set<int> diff_blocks_beginning;
428 for(auto curr_int = labels.begin(), end = labels.end(); curr_int != end; ++curr_int)
429 {
430 diff_blocks_beginning.insert(*curr_int);
431 }
432 //std::cout << "diff_blocks_beginning: " << diff_blocks_beginning.size() << std::endl;
433 bool skip_me = false;
434 if(diff_blocks_beginning.size() == labels.size())
435 {
436 skip_me = true;
437 }
438 // If the post processing is enabled, remove the coliding conss, otherwise just set the partition
439 if(enabled && !skip_me)
440 {
441 this->non_cl = (int)labels.size();
442 // for each column in the conss matrix we save labels of all the constraints where the variable appears
443 vector< vector<int> > all_labels_in_col(this->nvars);
444
445 // for each column in the conss matrix we count the number of occurrences of each label
446 vector< map<int, int> > all_label_occ_in_col(this->nvars);
447
448 // item i saves number which appears most often in the all_labels_in_col[i]
449 vector<int> col_labels(this->nvars, -1);
450
451 SCIP_CONS** conss = SCIPgetConss(scip);
452 SCIP_Bool success;
453
454 // For each var save the labels of all the constraints where this var appears.
455 for(auto i = 0; i < this->nconss; i++)
456 {
457 SCIP_VAR** curvars = NULL;
458 int ncurvars;
459 SCIP_CALL( SCIPgetConsNVars(scip, conss[i], &ncurvars, &success) );
460 assert(success);
461 if( ncurvars == 0 )
462 continue;
463
464 /*
465 * may work as is, as we are copying the constraint later regardless
466 * if there are variables in it or not
467 */
468 SCIP_CALL( SCIPallocBufferArray(scip, &curvars, ncurvars) );
469 SCIP_CALL( SCIPgetConsVars(scip, conss[i], curvars, ncurvars, &success) );
470 assert(success);
471
472 for(auto j = 0; j < ncurvars; j++)
473 {
474 SCIP_VAR* var;
475
476 if( !GCGisVarRelevant(curvars[j]) )
477 continue;
478
479 if( SCIPgetStage(scip) >= SCIP_STAGE_TRANSFORMED)
480 var = SCIPvarGetProbvar(curvars[j]);
481 else
482 var = curvars[j];
483
484 assert(var != NULL);
485 int varIndex = SCIPvarGetProbindex(var);
486 assert(varIndex >= 0);
487 assert(varIndex < this->nvars);
488
489 // push the label of the constraint to the columns where the variable appears
490 all_labels_in_col[varIndex].push_back(labels[i]);
491 all_label_occ_in_col[varIndex][labels[i]]++;
492 }
493 SCIPfreeBufferArray(scip, &curvars);
494 }
495
496 // fill the col_labels
497 for(auto i = 0; i < this->nvars; i++)
498 {
499 auto pr = max_element
500 (
501 all_label_occ_in_col[i].begin(), all_label_occ_in_col[i].end(),
502 [] (const pair<int,int> & p1, const pair<int,int> & p2) {
503 return p1.second < p2.second;
504 }
505 );
506 // new code
507 col_labels[i] = pr->first;
508 }
509
510 // Iterate all the conss and remove them (i.e. set label to -1) if necessary
511 for(auto i = 0; i < this->nconss; i++)
512 {
513 SCIP_VAR** curvars1 = NULL;
514 int ncurvars1;
515 SCIP_CALL( SCIPgetConsNVars(scip, conss[i], &ncurvars1, &success) );
516 assert(success);
517 if( ncurvars1 == 0 )
518 continue;
519
520 /*
521 * may work as is, as we are copying the constraint later regardless
522 * if there are variables in it or not
523 */
524 SCIP_CALL( SCIPallocBufferArray(scip, &curvars1, ncurvars1) );
525 SCIP_CALL( SCIPgetConsVars(scip, conss[i], curvars1, ncurvars1, &success) );
526 assert(success);
527
528 for(auto j = 0; j < ncurvars1; j++)
529 {
530 SCIP_VAR* var1;
531
532 if( !GCGisVarRelevant(curvars1[j]) )
533 continue;
534
535 if( SCIPgetStage(scip) >= SCIP_STAGE_TRANSFORMED)
536 var1 = SCIPvarGetProbvar(curvars1[j]);
537 else
538 var1 = curvars1[j];
539
540 assert(var1 != NULL);
541 int varIndex = SCIPvarGetProbindex(var1);
542 assert(varIndex >= 0);
543 assert(varIndex < this->nvars);
544
545 // Check if in a conss we have found a var with different label than the conss label.
546 // This means that this var is mostly belonging to some other block, so remove it
547 if(col_labels[varIndex] != labels[i])
548 {
549 labels[i] = -1;
550
551 // this is new part
552 // it updates the column labels each time after eliminating some conss
553 all_label_occ_in_col[varIndex][labels[i]]--;
554 auto pr = max_element
555 (
556 all_label_occ_in_col[varIndex].begin(), all_label_occ_in_col[varIndex].end(),
557 [] (const pair<int,int> & p1, const pair<int,int> & p2) {
558 return p1.second < p2.second;
559 }
560 );
561 col_labels[varIndex] = pr->first;
562 }
563 }
564 SCIPfreeBufferArray(scip, &curvars1);
565
566 }
567 }
568
569 if(!skip_me)
570 {
571 // Fix the labeling so that it starts from 0 without skipping the enumeration order
572 // And set the graph partition accordingly.
573 set<int> diff_blocks;
574
575 for(auto curr_int = labels.begin(), end = labels.end(); curr_int != end; ++curr_int)
576 {
577 diff_blocks.insert(*curr_int);
578 }
579
580 const int non_cl_pts = count(labels.begin(), labels.end(), -1);
581 if(non_cl_pts > 0)
582 {
583 this->n_blocks = (int) diff_blocks.size() - 1;
584 }
585 else
586 {
587 this->n_blocks = (int) diff_blocks.size();
588 }
589 this->non_cl = non_cl_pts;
590
591 map<int,int> labels_fix;
592 int new_label;
593 if(this->non_cl > 0) new_label = -1;
594 else new_label = 0;
595
596 for(int old_label: diff_blocks)
597 {
598 labels_fix[old_label] = new_label;
599 new_label++;
600 }
601 for(int i = 0; i < (int)labels.size(); i++)
602 {
603 labels[i] = labels_fix[labels[i]];
604 }
605 }
606
607 // put the labels as the partition...
608 for(int i = 0; i < (int)labels.size(); i++)
609 {
610 this->graph.setPartition(i, labels[i]);
611 }
612 return SCIP_OKAY;
613}
614
615template <>
616SCIP_RETCODE RowGraphWeighted<GraphGCG>::postProcessForPartialGraph(gcg::DETPROBDATA* detprobdata, gcg::PARTIALDECOMP* partialdec, vector<int>& labels, bool enabled)
617{
618 assert((int)labels.size() == graph.getNNodes());
619 set<int> diff_blocks_beginning;
620 for(auto curr_int = labels.begin(), end = labels.end(); curr_int != end; ++curr_int)
621 {
622 diff_blocks_beginning.insert(*curr_int);
623 }
624 bool skip_me = false;
625 if(diff_blocks_beginning.size() == labels.size())
626 {
627 skip_me = true;
628 }
629 // If the post processing is enabled, remove the coliding conss, otherwise just set the partition
630 if(enabled && !skip_me)
631 {
632 //fillout conssForGraph and varsForGraph
633 vector<int> conssForGraph; /* stores the conss included by the graph */
634 vector<int> varsForGraph; /* stores the vars included by the graph */
635 vector<bool> varsBool(partialdec->getNVars(), false); /* true, if the var will be part of the graph */
636 vector<bool> conssBool(partialdec->getNConss(), false); /* true, if the cons will be part of the graph */
637 unordered_map<int, int> oldToNewConsIndex; /* stores new index of the conss */
638 unordered_map<int, int> oldToNewVarIndex; /* stores new index of the vars */
639
640 for(int c = 0; c < partialdec->getNOpenconss(); ++c)
641 {
642 int cons = partialdec->getOpenconss()[c];
643 for(int v = 0; v < partialdec->getNOpenvars(); ++v)
644 {
645 int var = partialdec->getOpenvars()[v];
646 for(int i = 0; i < detprobdata->getNVarsForCons(cons); ++i)
647 {
648 if(var == detprobdata->getVarsForCons(cons)[i])
649 {
650 varsBool[var] = true;
651 conssBool[cons] = true;
652 }
653 }
654 }
655 }
656
657 for(int v = 0; v < partialdec->getNOpenvars(); ++v)
658 {
659 int var = partialdec->getOpenvars()[v];
660 if(varsBool[var] == true)
661 varsForGraph.push_back(var);
662 }
663 for(int c = 0; c < partialdec->getNOpenconss(); ++c)
664 {
665 int cons = partialdec->getOpenconss()[c];
666 if(conssBool[cons] == true)
667 conssForGraph.push_back(cons);
668 }
669
670 assert(this->nvars == (int) varsForGraph.size());
671 assert(this->nconss == (int) conssForGraph.size());
672
673 sort(conssForGraph.begin(), conssForGraph.end());
674 sort(varsForGraph.begin(), varsForGraph.end());
675
676 //fillout oldToNewVarIndex and oldToNewConsIndex
677 for(int v = 0; v < this->nvars; ++v)
678 {
679 int oldVarId = varsForGraph[v];
680 oldToNewVarIndex.insert({oldVarId,v});
681 }
682
683 for(int c = 0; c < this->nconss; ++c)
684 {
685 int oldConsId = conssForGraph[c];
686 oldToNewConsIndex.insert({oldConsId,c});
687 }
688
689 this->non_cl = (int)labels.size();
690 // for each column in the conss matrix we save labels of all the constraints where the variable appears
691 vector< vector<int> > all_labels_in_col(this->nvars);
692
693 // for each column in the conss matrix we count the number of occurrences of each label
694 vector< map<int, int> > all_label_occ_in_col(this->nvars);
695
696 // item i saves number which appears most often in the all_labels_in_col[i]
697 vector<int> col_labels(this->nvars, -1);
698
699
700 // For each var save the labels of all the constraints where this var appears.
701 for(size_t c = 0; c < conssForGraph.size(); c++)
702 {
703 int cons = conssForGraph[c];
704 int consIndex = oldToNewConsIndex[cons];
705 assert(consIndex >= 0);
706 assert(consIndex < this->nconss);
707 for(int v = 0; v < detprobdata->getNVarsForCons(cons); ++v)
708 {
709 int var = detprobdata->getVarsForCons(cons)[v];
710 if(find(varsForGraph.begin(), varsForGraph.end(), var) == varsForGraph.end())
711 continue;
712 int varIndex = oldToNewVarIndex[var];
713 assert(varIndex >= 0);
714 assert(varIndex < this->nvars);
715 all_labels_in_col[varIndex].push_back(labels[consIndex]);
716 }
717 }
718
719 // fill the col_labels
720 for(size_t v = 0; v < varsForGraph.size(); ++v)
721 {
722 int var = varsForGraph[v];
723 int varIndex = oldToNewVarIndex[var];
724 assert(varIndex >= 0);
725 assert(varIndex < this->nvars);
726
727 auto pr = max_element
728 (
729 all_label_occ_in_col[varIndex].begin(), all_label_occ_in_col[varIndex].end(),
730 [] (const pair<int,int> & p1, const pair<int,int> & p2) {
731 return p1.second < p2.second;
732 }
733 );
734 col_labels[varIndex] = pr->first;
735 }
736
737
738 // Iterate all the conss and remove them (i.e. set label to -1) if necessary
739 for(size_t c = 0; c < conssForGraph.size(); ++c)
740 {
741 int cons = conssForGraph[c];
742 assert(cons >= 0);
743 int consIndex = oldToNewConsIndex[cons];
744 assert(consIndex >= 0);
745 assert(consIndex < this->nconss);
746 for(int v = 0; v < detprobdata->getNVarsForCons(cons); ++v)
747 {
748 int var = detprobdata->getVarsForCons(cons)[v];
749 if(find(varsForGraph.begin(), varsForGraph.end(), var) == varsForGraph.end())
750 continue;
751 int varIndex = oldToNewVarIndex[var];
752 assert(varIndex >= 0);
753 assert(varIndex < this->nvars);
754 // Check if in a conss we have found a var with different label than the conss label.
755 // This means that this var is mostly belonging to some other block, so remove it
756 if(col_labels[varIndex] != labels[consIndex])
757 {
758 labels.at(consIndex) = -1;
759
760 // this is new part
761 // it updates the column labels each time after eliminating some conss
762 all_label_occ_in_col[varIndex][labels[consIndex]]--;
763 auto pr = max_element
764 (
765 all_label_occ_in_col[varIndex].begin(), all_label_occ_in_col[varIndex].end(),
766 [] (const pair<int,int> & p1, const pair<int,int> & p2) {
767 return p1.second < p2.second;
768 }
769 );
770 col_labels[varIndex] = pr->first;
771 }
772 }
773 }
774 }
775
776 if(!skip_me)
777 {
778 // Fix the labeling so that it starts from 0 without skipping the enumeration order
779 // And set the graph partition accordingly.
780 set<int> diff_blocks;
781
782 for(auto curr_int = labels.begin(), end = labels.end(); curr_int != end; ++curr_int)
783 {
784 diff_blocks.insert(*curr_int);
785 }
786
787 const int non_cl_pts = count(labels.begin(), labels.end(), -1);
788 if(non_cl_pts > 0)
789 {
790 this->n_blocks = (int) diff_blocks.size() - 1;
791 }
792 else
793 {
794 this->n_blocks = (int) diff_blocks.size();
795 }
796 this->non_cl = non_cl_pts;
797
798 map<int,int> labels_fix;
799 int new_label;
800 if(this->non_cl > 0) new_label = -1;
801 else new_label = 0;
802
803 for(int old_label: diff_blocks)
804 {
805 labels_fix[old_label] = new_label;
806 new_label++;
807 }
808 for(int i = 0; i < (int)labels.size(); i++)
809 {
810 labels[i] = labels_fix[labels[i]];
811 }
812 }
813
814 // put the labels as the partition...
815 for(int i = 0; i < (int)labels.size(); i++)
816 {
817 this->graph.setPartition(i, labels[i]);
818 }
819 return SCIP_OKAY;
820}
821
822
823// this function is obsolete
824template <>
825SCIP_RETCODE RowGraphWeighted<GraphGCG>::postProcessStableSet(vector<int>& labels, bool enabled)
826{
827 SCIP* scip = GCGgetOrigprob(this->gcg);
828 assert((int)labels.size() == graph.getNNodes());
829 set<int> diff_blocks_beginning;
830 for(auto curr_int = labels.begin(), end = labels.end(); curr_int != end; ++curr_int)
831 {
832 diff_blocks_beginning.insert(*curr_int);
833 }
834 bool skip_me = false;
835 if(diff_blocks_beginning.size() == labels.size())
836 {
837 skip_me = true;
838 }
839
840
841 // If the post processing is enabled, remove the coliding conss, otherwise just set the partition
842 if(enabled && !skip_me)
843 {
844 priority_graph stable_set_graph;
845 //SCIPverbMessage(this->scip_, SCIP_VERBLEVEL_NORMAL, NULL, " running postProcessStableSet\n");
846 this->non_cl = (int)labels.size();
847 // for each column in the conss matrix we save labels of all the constraints where the variable appears
848 vector< vector<int> > all_ind_in_col(this->nvars);
849
850
851 SCIP_CONS** conss = SCIPgetConss(scip);
852 SCIP_Bool success;
853
854 /* go through all constraints */
855 for(int i = 0; i < this->nconss; ++i )
856 {
857 SCIP_VAR** curvars1 = NULL;
858
859 int ncurvars1;
860 SCIP_CALL( SCIPgetConsNVars(scip, conss[i], &ncurvars1, &success) );
861 assert(success);
862 if( ncurvars1 == 0 )
863 continue;
864
865 /*
866 * may work as is, as we are copying the constraint later regardless
867 * if there are variables in it or not
868 */
869 SCIP_CALL( SCIPallocBufferArray(scip, &curvars1, ncurvars1) );
870 SCIP_CALL( SCIPgetConsVars(scip, conss[i], curvars1, ncurvars1, &success) );
871 assert(success);
872
873 /* go through all constraints */
874 for(int j = 0; j < i; ++j )
875 {
876 if(labels[i] == labels[j]) continue;
877 SCIP_VAR** curvars2 = NULL;
878 SCIP_Bool continueloop;
879 int ncurvars2;
880 SCIP_CALL( SCIPgetConsNVars(scip, conss[j], &ncurvars2, &success) );
881 assert(success);
882 if( ncurvars2 == 0 )
883 continue;
884
885 continueloop = FALSE;
886 /*
887 * may work as is, as we are copying the constraint later regardless
888 * if there are variables in it or not
889 */
890 SCIP_CALL( SCIPallocBufferArray(scip, &curvars2, ncurvars2) );
891 SCIP_CALL( SCIPgetConsVars(scip, conss[j], curvars2, ncurvars2, &success) );
892 assert(success);
893
894
895 /** @todo skip all variables that have a zero coeffient or where all coefficients add to zero */
896 /** @todo Do more then one entry per variable actually work? */
897
898 for(int k = 0; k < ncurvars1; ++k )
899 {
900 SCIP_VAR* var1 = NULL;
901 int varIndex1;
902
903 if( !GCGisVarRelevant(curvars1[k]) )
904 continue;
905
906 if( SCIPgetStage(scip) >= SCIP_STAGE_TRANSFORMED)
907 var1 = SCIPvarGetProbvar(curvars1[k]);
908 else
909 var1 = curvars1[k];
910
911 assert(var1 != NULL);
912 varIndex1 = SCIPvarGetProbindex(var1);
913 assert(varIndex1 >= 0);
914 assert(varIndex1 < this->nvars);
915
916 for(int l = 0; l < ncurvars2; ++l )
917 {
918 SCIP_VAR* var2 = NULL;
919 int varIndex2;
920
921 if( !GCGisVarRelevant(curvars2[l]) )
922 continue;
923
924 if( SCIPgetStage(scip) >= SCIP_STAGE_TRANSFORMED)
925 var2 = SCIPvarGetProbvar(curvars2[l]);
926 else
927 var2 = curvars2[l];
928
929 assert(var2 != NULL);
930 varIndex2 = SCIPvarGetProbindex(var2);
931 assert(varIndex2 >= 0);
932 assert(varIndex2 < this->nvars);
933
934 if(varIndex1 == varIndex2)
935 {
936 stable_set_graph.addNode(i);
937 stable_set_graph.addNode(j);
938 stable_set_graph.addEdge(i, j);
939
940 /*
941 * this->graph.flush();
942 */
943
944 continueloop = TRUE;
945 break;
946 }
947 }
948 if(continueloop)
949 break;
950 }
951 SCIPfreeBufferArray(scip, &curvars2);
952 }
953 SCIPfreeBufferArray(scip, &curvars1);
954 }
955
956 // run greedy heuristic for stable set
957 vector<int> stable_set;
958 vector<int> no_stable_set;
959 while(!stable_set_graph.empty()){
960 int current = stable_set_graph.top().first;
961 stable_set.push_back(current);
962 set<int> neighbors = stable_set_graph.getNeighbors(current);
963 stable_set_graph.pop();
964 for(auto neighbor : neighbors){
965 stable_set_graph.removeNode(neighbor, no_stable_set);
966 }
967 }
968
969
970 // Iterate all the conss and remove them (i.e. set label to -1) if necessary
971 for(int to_remove : no_stable_set)
972 {
973 //SCIPverbMessage(this->scip_, SCIP_VERBLEVEL_NORMAL, NULL, " to_remove: %d \n", to_remove);
974 labels[to_remove] = -1;
975 }
976 }
977
978
979 if(!skip_me)
980 {
981 // Fix the labeling so that it starts from 0 without skipping the enumeration order
982 // And set the graph partition accordingly.
983 set<int> diff_blocks;
984 for(auto curr_int = labels.begin(), end = labels.end(); curr_int != end; ++curr_int)
985 {
986 diff_blocks.insert(*curr_int);
987 }
988
989 const int non_cl_pts = count(labels.begin(), labels.end(), -1);
990 if(non_cl_pts > 0)
991 {
992 this->n_blocks = (int) diff_blocks.size() - 1;
993 }
994 else
995 {
996 this->n_blocks = (int) diff_blocks.size();
997 }
998 this->non_cl = non_cl_pts;
999
1000 map<int,int> labels_fix;
1001 int new_label;
1002 if(this->non_cl > 0) new_label = -1;
1003 else new_label = 0;
1004
1005 for(int old_label: diff_blocks)
1006 {
1007 labels_fix[old_label] = new_label;
1008 new_label++;
1009 }
1010 for(int i = 0; i < (int)labels.size(); i++)
1011 {
1012 labels[i] = labels_fix[labels[i]];
1013 }
1014 }
1015
1016 // put the labels as the partition...
1017 for(int i = 0; i < (int)labels.size(); i++)
1018 {
1019 this->graph.setPartition(i, labels[i]);
1020 }
1021 return SCIP_OKAY;
1022}
1023
1024// this function is obsolete
1025template <>
1026SCIP_RETCODE RowGraphWeighted<GraphGCG>::postProcessStableSetForPartialGraph(gcg::DETPROBDATA* detprobdata, gcg::PARTIALDECOMP* partialdec, vector<int>& labels, bool enabled)
1027{
1028 assert((int)labels.size() == graph.getNNodes());
1029 set<int> diff_blocks_beginning;
1030 for(auto curr_int = labels.begin(), end = labels.end(); curr_int != end; ++curr_int)
1031 {
1032 diff_blocks_beginning.insert(*curr_int);
1033 }
1034 bool skip_me = false;
1035 if(diff_blocks_beginning.size() == labels.size())
1036 {
1037 skip_me = true;
1038 }
1039
1040
1041
1042 // If the post processing is enabled, remove the coliding conss, otherwise just set the partition
1043 if(enabled && !skip_me)
1044 {
1045 //fillout conssForGraph and varsForGraph
1046 vector<int> conssForGraph; /** stores the conss included by the graph */
1047 vector<int> varsForGraph; /** stores the vars included by the graph */
1048 vector<bool> varsBool(partialdec->getNVars(), false); /**< true, if the var will be part of the graph */
1049 vector<bool> conssBool(partialdec->getNConss(), false); /**< true, if the cons will be part of the graph */
1050 unordered_map<int, int> oldToNewConsIndex; /** stores new index of the conss */
1051 unordered_map<int, int> oldToNewVarIndex; /** stores new index of the vars */
1052
1053 for(int c = 0; c < partialdec->getNOpenconss(); ++c)
1054 {
1055 int cons = partialdec->getOpenconss()[c];
1056 for(int v = 0; v < partialdec->getNOpenvars(); ++v)
1057 {
1058 int var = partialdec->getOpenvars()[v];
1059 for(int i = 0; i < detprobdata->getNVarsForCons(cons); ++i)
1060 {
1061 if(var == detprobdata->getVarsForCons(cons)[i])
1062 {
1063 varsBool[var] = true;
1064 conssBool[cons] = true;
1065 }
1066 }
1067 }
1068 }
1069
1070 for(int v = 0; v < partialdec->getNOpenvars(); ++v)
1071 {
1072 int var = partialdec->getOpenvars()[v];
1073 if(varsBool[var] == true)
1074 varsForGraph.push_back(var);
1075 }
1076 for(int c = 0; c < partialdec->getNOpenconss(); ++c)
1077 {
1078 int cons = partialdec->getOpenconss()[c];
1079 if(conssBool[cons] == true)
1080 conssForGraph.push_back(cons);
1081 }
1082
1083 assert(this->nvars == (int) varsForGraph.size());
1084 assert(this->nconss == (int) conssForGraph.size());
1085
1086 sort(conssForGraph.begin(), conssForGraph.end());
1087 sort(varsForGraph.begin(), varsForGraph.end());
1088
1089 //fillout oldToNewVarIndex and oltToNewConsIndex
1090 for(int v = 0; v < this->nvars; ++v)
1091 {
1092 int oldVarId = varsForGraph[v];
1093 oldToNewVarIndex.insert({oldVarId,v});
1094 }
1095
1096 for(int c = 0; c < this->nconss; ++c)
1097 {
1098 int oldConsId = conssForGraph[c];
1099 oldToNewConsIndex.insert({oldConsId,c});
1100 }
1101
1102 priority_graph stable_set_graph;
1103 this->non_cl = (int)labels.size();
1104 // for each column in the conss matrix we save labels of all the constraints where the variable appears
1105 vector< vector<int> > all_ind_in_col(this->nvars);
1106
1107 /* go through all constraints */
1108 for(int c = 0; c < this->nconss; ++c)
1109 {
1110 int cons1 = conssForGraph[c];
1111 int consIndex1 = oldToNewConsIndex[cons1];
1112 assert(consIndex1 >= 0);
1113 assert(consIndex1 < this->nconss);
1114
1115 /*
1116 * may work as is, as we are copying the constraint later regardless
1117 * if there are variables in it or not
1118 */
1119
1120 /* go through all constraints */
1121 for(int d = 0; d < c; ++d )
1122 {
1123 int cons2 = conssForGraph[d];
1124 int consIndex2 = oldToNewConsIndex[cons2];
1125 assert(consIndex2 >= 0);
1126 assert(consIndex2 < this->nconss);
1127 if(labels[consIndex1] == labels[consIndex2])
1128 continue;
1129 SCIP_Bool continueloop = FALSE;
1130 /*
1131 * may work as is, as we are copying the constraint later regardless
1132 * if there are variables in it or not
1133 */
1134
1135 /** @todo skip all variables that have a zero coeffient or where all coefficients add to zero */
1136 /** @todo Do more then one entry per variable actually work? */
1137 for(int v = 0; v < detprobdata->getNVarsForCons(cons1); ++v)
1138 {
1139 int var1 = detprobdata->getVarsForCons(cons1)[v];
1140 if(find(varsForGraph.begin(), varsForGraph.end(), var1) == varsForGraph.end())
1141 continue;
1142 int varIndex1 = oldToNewVarIndex[var1];
1143 assert(varIndex1 >= 0);
1144 assert(varIndex1 < this->nvars);
1145 for(int w = 0; w < detprobdata->getNVarsForCons(cons2); ++w)
1146 {
1147 int var2 = detprobdata->getVarsForCons(cons2)[w];
1148 if(find(varsForGraph.begin(), varsForGraph.end(), var2) == varsForGraph.end())
1149 continue;
1150 int varIndex2 = oldToNewVarIndex[var2];
1151 assert(varIndex2 >= 0);
1152 assert(varIndex2 < this->nvars);
1153 if(varIndex1 == varIndex2)
1154 {
1155 stable_set_graph.addNode(consIndex1);
1156 stable_set_graph.addNode(consIndex2);
1157 stable_set_graph.addEdge(consIndex1, consIndex2);
1158 continueloop = TRUE;
1159 break;
1160 }
1161 }
1162 if(continueloop)
1163 break;
1164 }
1165 }
1166 }
1167
1168 // run greedy heuristic for stable set
1169 vector<int> stable_set;
1170 vector<int> no_stable_set;
1171 while(!stable_set_graph.empty()){
1172 int current = stable_set_graph.top().first;
1173 stable_set.push_back(current);
1174 set<int> neighbors = stable_set_graph.getNeighbors(current);
1175 stable_set_graph.pop();
1176 for(auto neighbor : neighbors){
1177 stable_set_graph.removeNode(neighbor, no_stable_set);
1178 }
1179 }
1180
1181
1182 // Iterate all the conss and remove them (i.e. set label to -1) if necessary
1183 for(int to_remove : no_stable_set)
1184 {
1185 labels[to_remove] = -1;
1186 }
1187 }
1188
1189
1190 if(!skip_me)
1191 {
1192 // Fix the labeling so that it starts from 0 without skipping the enumeration order
1193 // And set the graph partition accordingly.
1194 set<int> diff_blocks;
1195 for(auto curr_int = labels.begin(), end = labels.end(); curr_int != end; ++curr_int)
1196 {
1197 diff_blocks.insert(*curr_int);
1198 }
1199
1200 const int non_cl_pts = count(labels.begin(), labels.end(), -1);
1201 if(non_cl_pts > 0)
1202 {
1203 this->n_blocks = (int) diff_blocks.size() - 1;
1204 }
1205 else
1206 {
1207 this->n_blocks = (int) diff_blocks.size();
1208 }
1209 this->non_cl = non_cl_pts;
1210
1211 map<int,int> labels_fix;
1212 int new_label;
1213 if(this->non_cl > 0) new_label = -1;
1214 else new_label = 0;
1215
1216 for(int old_label: diff_blocks)
1217 {
1218 labels_fix[old_label] = new_label;
1219 new_label++;
1220 }
1221 for(int i = 0; i < (int)labels.size(); i++)
1222 {
1223 labels[i] = labels_fix[labels[i]];
1224 }
1225 }
1226
1227 // put the labels as the partition...
1228 for(int i = 0; i < (int)labels.size(); i++)
1229 {
1230 this->graph.setPartition(i, labels[i]);
1231 }
1232 return SCIP_OKAY;
1233}
1234
1235template <>
1237{
1238 vector<int> labels;
1239 labels = GraphAlgorithms<GraphGCG>::dbscan(graph, eps);
1240 assert((int)labels.size() == graph.getNNodes());
1241
1242 SCIP_CALL( postProcess(labels, postprocenable) );
1243 return SCIP_OKAY;
1244}
1245
1246template <>
1248{
1249 vector<int> labels;
1250 labels = GraphAlgorithms<GraphGCG>::dbscan(graph, eps);
1251 assert((int)labels.size() == graph.getNNodes());
1252
1253 SCIP_CALL( postProcessForPartialGraph(detprobdata, partialdec, labels, postprocenable) );
1254 return SCIP_OKAY;
1255}
1256
1257
1258template <>
1260{
1261 vector<int> labels;
1262 labels = GraphAlgorithms<GraphGCG>::mst(graph, eps);
1263 assert((int)labels.size() == graph.getNNodes());
1264
1265 SCIP_CALL( postProcess(labels, postprocenable) );
1266 return SCIP_OKAY;
1267}
1268
1269template <>
1271{
1272 vector<int> labels;
1273 labels = GraphAlgorithms<GraphGCG>::mst(graph, eps);
1274 assert((int)labels.size() == graph.getNNodes());
1275
1276 SCIP_CALL( postProcessForPartialGraph(detprobdata, partialdec, labels, postprocenable) );
1277 return SCIP_OKAY;
1278}
1279
1280template <>
1281SCIP_RETCODE RowGraphWeighted<GraphGCG>::computePartitionMCL(int& stoppedAfter, double inflatefactor, bool postprocenable)
1282{
1283 vector<int> labels;
1284 labels = GraphAlgorithms<GraphGCG>::mcl(graph, stoppedAfter, inflatefactor);
1285 assert((int)labels.size() == graph.getNNodes());
1286
1287 SCIP_CALL( postProcess(labels, postprocenable) );
1288 return SCIP_OKAY;
1289}
1290
1291template <>
1292SCIP_RETCODE RowGraphWeighted<GraphGCG>::computePartitionMCLForPartialGraph(gcg::DETPROBDATA* detprobdata, gcg::PARTIALDECOMP* partialdec, int& stoppedAfter, double inflatefactor, bool postprocenable)
1293{
1294 vector<int> labels;
1295 labels = GraphAlgorithms<GraphGCG>::mcl(graph, stoppedAfter, inflatefactor);
1296 assert((int)labels.size() == graph.getNNodes());
1297
1298 SCIP_CALL( postProcessForPartialGraph(detprobdata, partialdec, labels, postprocenable) );
1299 return SCIP_OKAY;
1300}
1301
1302template <class T>
1304{
1305 _n_blocks = n_blocks;
1306 return SCIP_OKAY;
1307}
1308
1309template <class T>
1311{
1312 _non_cl = non_cl;
1313 return SCIP_OKAY;
1314}
1315
1316template <class T>
1318{
1319 return this->graph.getEdgeWeightPercentile(q);
1320}
1321
1322} /* namespace gcg */
1323#endif
SCIP_VAR * w
SCIP_VAR * a
SCIP_VAR ** b
GCG_EXPORT int getNVarsForCons(int consIndex)
returns the number of variables for a given constraint
GCG_EXPORT std::vector< int > & getVarsForCons(int consIndex)
returns the variable indices of the coefficient matrix for a constraint
static std::vector< int > mst(Graph< GraphGCG > &graph, double cutoff, int minPts=4)
static std::vector< int > mcl(Graph< GraphGCG > &graph, int &stoppedAfter, double inflatefac, int maxiters=25, int expandfac=2)
static std::vector< int > dbscan(Graph< GraphGCG > &graph, double eps, int minPts=4)
std::string name
Definition: matrixgraph.h:57
class to manage partial decompositions
GCG_EXPORT int getNConss()
Gets the number of constraints.
GCG_EXPORT int getNOpenvars()
Gets size of vector containing variables not assigned yet.
GCG_EXPORT int getNOpenconss()
Gets size of vector containing constraints not assigned yet.
GCG_EXPORT int getNVars()
Gets number of vars.
GCG_EXPORT std::vector< int > & getOpenconss()
Gets vector containing constraints not assigned yet.
GCG_EXPORT std::vector< int > & getOpenvars()
Gets vector containing variables not assigned yet.
virtual SCIP_RETCODE computePartitionMCL(int &stoppedAfter, double inflatefactor, bool postprocenable)
virtual SCIP_RETCODE nonClustered(int &_non_cl)
virtual SCIP_RETCODE createFromPartialMatrix(DETPROBDATA *detprobdata, PARTIALDECOMP *partialdec, DISTANCE_MEASURE dist, WEIGHT_TYPE w_type)
static double calculateSimilarity(int a, int b, int c, DISTANCE_MEASURE dist, WEIGHT_TYPE w_type, bool itself)
virtual SCIP_RETCODE computePartitionDBSCANForPartialGraph(gcg::DETPROBDATA *detprobdata, gcg::PARTIALDECOMP *partialdec, double eps, bool postprocenable)
virtual SCIP_RETCODE getNBlocks(int &_n_blocks)
virtual SCIP_RETCODE createFromMatrix(SCIP_CONS **conss, SCIP_VAR **vars, int nconss_, int nvars_, DISTANCE_MEASURE dist, WEIGHT_TYPE w_type)
virtual SCIP_RETCODE computePartitionMSTForPartialGraph(gcg::DETPROBDATA *detprobdata, gcg::PARTIALDECOMP *partialdec, double eps, bool postprocenable)
virtual SCIP_RETCODE computePartitionMST(double eps, bool postprocenable)
virtual SCIP_RETCODE computePartitionDBSCAN(double eps, bool postprocenable)
virtual SCIP_RETCODE computePartitionMCLForPartialGraph(gcg::DETPROBDATA *detprobdata, gcg::PARTIALDECOMP *partialdec, int &stoppedAfter, double inflatefactor, bool postprocenable)
RowGraphWeighted(GCG *gcg, Weights w)
virtual double getEdgeWeightPercentile(double q)
void addNode(int id)
set< int > getNeighbors(int node)
bool removeNode(int node, vector< int > &removed)
void addEdge(int node_i, int node_j)
#define SCIP_Bool
#define MIN(x, y)
#define SCIP_CALL(x)
#define TRUE
#define FALSE
Implementation of the graph which supports both node and edge weights.
several metrics for graphs
SCIP * GCGgetOrigprob(GCG *gcg)
Definition: gcg.cpp:87
SCIP_STAGE SCIPgetStage(SCIP *scip)
SCIP_CONS ** SCIPgetConss(SCIP *scip)
SCIP_Bool GCGisVarRelevant(SCIP_VAR *var)
Definition: scip_misc.c:42
SCIP_RETCODE SCIPgetConsNVars(SCIP *scip, SCIP_CONS *cons, int *nvars, SCIP_Bool *success)
SCIP_RETCODE SCIPgetConsVars(SCIP *scip, SCIP_CONS *cons, SCIP_VAR **vars, int varssize, SCIP_Bool *success)
#define SCIPallocBufferArray(scip, ptr, num)
#define SCIPfreeBufferArray(scip, ptr)
SCIP_VAR * SCIPvarGetProbvar(SCIP_VAR *var)
int SCIPvarGetProbindex(SCIP_VAR *var)
#define NULL
enum DistanceMeasure DISTANCE_MEASURE
enum WeightType WEIGHT_TYPE
@ INTERSECTION
real eps
A row graph where each row is a node and rows are adjacent if they share a variable....
Definition: struct_gcg.h:55
int size
SCIP_OKAY
SCIP_INVALIDCALL
enum SCIP_Retcode SCIP_RETCODE
SCIP_STAGE_TRANSFORMED