GCG 4.1.1 (dev)

Generic Column Generation

Loading...
Searching...
No Matches
gcgcol.c
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 gcgcol.c
30 * @brief methods for working with gcg column structure
31 * @author Jonas Witt
32 *
33 * Various methods to work with gcg column structure
34 *
35 */
36
37/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
38
39#include "gcg/pub_gcgcol.h"
40
41#include "gcg/gcg.h"
42#include "scip/def.h"
43#include "scip/scip.h"
44#include "scip/cons_linear.h"
45#include "gcg/pricer_gcg.h"
46#include "gcg/sepa_original.h"
47#include "gcg/struct_gcgcol.h"
49
50#include <assert.h>
51
52/** create a gcg column */
54 GCG* gcg, /**< GCG data structure */
55 SCIP* pricingprob, /**< SCIP data structure (pricing problem) */
56 GCG_COL** gcgcol, /**< pointer to store gcg column */
57 int probnr, /**< number of corresponding pricing problem */
58 SCIP_VAR** vars, /**< (sorted) array of variables of corresponding pricing problem */
59 SCIP_Real* vals, /**< array of solution values (belonging to vars) */
60 int nvars, /**< number of variables */
61 SCIP_Bool isray, /**< is the column a ray? */
62 SCIP_Real redcost /**< last known reduced cost */
63 )
64{
65 int i;
66 int ninferredpricingvars;
67 GCG_EXTENDEDMASTERCONSDATA** activecuts = NULL;
68 int nactivecuts;
69 GCG_EXTENDEDMASTERCONSDATA** branchextendedmasterconsdata = NULL;
70 int nbranchextendedmasterconsdata = 0;
71 int nnzinferredcoefvars;
72
73 /* WARNING: this function has to be threadsafe!*/
74
75 nnzinferredcoefvars = GCGcountInferredCoefPricingVars(vars, nvars);
76 ninferredpricingvars = GCGgetNActivePricingproblemModifications(gcg, probnr);
77
78 assert(GCGgetNAppliedPricingproblemModifications(gcg, probnr) >= nnzinferredcoefvars);
79
80 SCIP_CALL( SCIPallocBlockMemory(pricingprob, gcgcol) );
81 (*gcgcol)->maxvars = SCIPcalcMemGrowSize(pricingprob, nvars - nnzinferredcoefvars);
82 SCIP_CALL( SCIPallocBlockMemoryArray(pricingprob, &((*gcgcol)->vars), (*gcgcol)->maxvars) );
83 SCIP_CALL( SCIPallocBlockMemoryArray(pricingprob, &((*gcgcol)->vals), (*gcgcol)->maxvars) );
84
85 if( ninferredpricingvars > 0 )
86 {
87 (*gcgcol)->maxinferredpricingvars = SCIPcalcMemGrowSize(pricingprob, ninferredpricingvars);
88 SCIP_CALL( SCIPallocBlockMemoryArray(pricingprob, &((*gcgcol)->inferredpricingvars), (*gcgcol)->maxinferredpricingvars) );
89 SCIP_CALL( SCIPallocBlockMemoryArray(pricingprob, &((*gcgcol)->inferredpricingvals), (*gcgcol)->maxinferredpricingvars) );
90 }
91 else
92 {
93 (*gcgcol)->inferredpricingvars = NULL;
94 (*gcgcol)->inferredpricingvals = NULL;
95 (*gcgcol)->maxinferredpricingvars = 0;
96 }
97
98 (*gcgcol)->pricingprob = pricingprob;
99 (*gcgcol)->probnr = probnr;
100 (*gcgcol)->isray = isray;
101 (*gcgcol)->redcost = redcost;
102 (*gcgcol)->age = 0;
103 (*gcgcol)->mastercoefs = NULL;
104 (*gcgcol)->originalsepamastercuts = NULL;
105 (*gcgcol)->linkvars = NULL;
106 (*gcgcol)->nmastercoefs = 0;
107 (*gcgcol)->noriginalsepamastercuts = 0;
108 (*gcgcol)->maxmastercoefs = 0;
109 (*gcgcol)->maxoriginalsepamastercuts = 0;
110 (*gcgcol)->nlinkvars = 0;
111 (*gcgcol)->initcoefs = FALSE;
112
113 /* data structures to store the cut coefficients for active master separator cuts */
114 (*gcgcol)->mastersepacutcoeffs = NULL;
115 (*gcgcol)->nmastersepacutcoeffs = 0;
116 (*gcgcol)->mastersepacutscoeffssize = 0;
117
118 (*gcgcol)->pos = -1;
119
120
121 (*gcgcol)->nvars = 0;
122 (*gcgcol)->ninferredpricingvars = 0;
123 for( i = 0; i < nvars; ++i )
124 {
125 SCIP_VAR* origvar;
126 SCIP_Real scalar;
127 SCIP_Real constant;
128 SCIP_Real origval;
129
130 scalar = 1.0;
131 constant = 0.0;
132
133 origvar = vars[i];
134
135 SCIP_CALL( SCIPvarGetOrigvarSum(&origvar, &scalar, &constant) );
136
137 assert( !SCIPisZero(pricingprob, scalar) );
138
139 origval = (vals[i] - constant) / scalar;
140
141 /* round origval if possible to avoid numerical troubles */
142 if( SCIPvarIsIntegral(origvar) && SCIPisFeasIntegral(pricingprob, origval) )
143 origval = SCIPround(pricingprob, origval);
144
145 if( SCIPisZero(pricingprob, origval) )
146 continue;
147
148 if( GCGvarIsPricing(origvar) )
149 {
150 assert(GCGvarIsPricing(origvar) && GCGpricingVarGetNOrigvars(origvar) > 0 && GCGpricingVarGetOrigvars(origvar)[0] != NULL);
151 assert((*gcgcol)->nvars < (*gcgcol)->maxvars);
152 (*gcgcol)->vars[(*gcgcol)->nvars] = origvar;
153 (*gcgcol)->vals[(*gcgcol)->nvars] = origval;
154 ++(*gcgcol)->nvars;
155 SCIPcaptureVar(pricingprob, origvar);
156 }
157 }
158
159 /* sort vars and vals array w.r.t. variable index */
160 SCIPsortPtrReal((void**)(*gcgcol)->vars, (double*)(*gcgcol)->vals, SCIPvarComp, (*gcgcol)->nvars);
161
162 SCIP_CALL( GCGrelaxBranchGetAllActiveExtendedMasterConss(gcg, NULL, NULL, &branchextendedmasterconsdata, &nbranchextendedmasterconsdata) );
163 for( i = 0; i < nbranchextendedmasterconsdata; ++i )
164 {
166 SCIP_Real val;
167
168 mod = GCGextendedmasterconsGetPricingModification(gcg, branchextendedmasterconsdata[i], probnr);
169 assert(mod != NULL);
170
171 GCGbranchGetExtendedmasterconsCoeff(gcg, branchextendedmasterconsdata[i], (*gcgcol)->vars, (*gcgcol)->vals, (*gcgcol)->nvars, probnr, NULL, &val);
172
173 if( !SCIPisZero(pricingprob, val) )
174 {
176 assert(var != NULL);
177 assert((*gcgcol)->ninferredpricingvars < (*gcgcol)->maxinferredpricingvars);
178 (*gcgcol)->inferredpricingvars[(*gcgcol)->ninferredpricingvars] = var;
179 (*gcgcol)->inferredpricingvals[(*gcgcol)->ninferredpricingvars] = val;
180 ++(*gcgcol)->ninferredpricingvars;
181 SCIPcaptureVar(pricingprob, var);
182 }
183 }
184
185 activecuts = GCGgetActiveMastersepacuts(gcg);
186 nactivecuts = GCGgetNActiveMastersepacuts(gcg);
187 for( i = 0; i < nactivecuts; ++i )
188 {
190 SCIP_Real val;
191
192 mod = GCGextendedmasterconsGetPricingModification(gcg, activecuts[i], probnr);
193 assert(mod != NULL);
194
195 GCGmastersepacutGetExtendedmasterconsCoeff(gcg, activecuts[i], (*gcgcol)->vars, (*gcgcol)->vals, (*gcgcol)->nvars, probnr, NULL, &val);
196
197 if( !SCIPisZero(pricingprob, val) )
198 {
200 assert(var != NULL);
201 assert((*gcgcol)->ninferredpricingvars < (*gcgcol)->maxinferredpricingvars);
202 (*gcgcol)->inferredpricingvars[(*gcgcol)->ninferredpricingvars] = var;
203 (*gcgcol)->inferredpricingvals[(*gcgcol)->ninferredpricingvars] = val;
204 ++(*gcgcol)->ninferredpricingvars;
205 SCIPcaptureVar(pricingprob, var);
206 }
207 }
208
209 assert(ninferredpricingvars >= (*gcgcol)->ninferredpricingvars);
210
211 if( (*gcgcol)->inferredpricingvars != NULL )
212 {
213 SCIPsortPtrReal((void**)(*gcgcol)->inferredpricingvars, (double*)(*gcgcol)->inferredpricingvals,
214 SCIPvarComp, (*gcgcol)->ninferredpricingvars);
215 }
216
217#ifndef NDEBUG
218 for( i = 1 ; i < (*gcgcol)->nvars; ++i )
219 {
220 assert( SCIPvarCompare((*gcgcol)->vars[i-1], (*gcgcol)->vars[i]) < 0 );
221 }
222 for( i = 1 ; i < (*gcgcol)->ninferredpricingvars; ++i )
223 {
224 assert( SCIPvarCompare((*gcgcol)->inferredpricingvars[i-1], (*gcgcol)->inferredpricingvars[i]) < 0 );
225 }
226#endif
227 return SCIP_OKAY;
228}
229
230/** free a gcg column */
232 GCG_COL** gcgcol /**< pointer to store gcg column */
233 )
234{
235 int i;
236 assert(gcgcol != NULL);
237 assert(*gcgcol != NULL);
238
239 /* WARNING: this function has to be threadsafe!*/
240
241 for( i = 0; i < (*gcgcol)->nvars; ++i )
242 SCIP_CALL( SCIPreleaseVar((*gcgcol)->pricingprob, &(*gcgcol)->vars[i]) );
243 assert((*gcgcol)->nvars == 0 || (*gcgcol)->vars != NULL);
244 SCIPfreeBlockMemoryArrayNull((*gcgcol)->pricingprob, &(*gcgcol)->vars, (*gcgcol)->maxvars);
245 assert((*gcgcol)->nvars == 0 || (*gcgcol)->vals != NULL);
246 SCIPfreeBlockMemoryArrayNull((*gcgcol)->pricingprob, &(*gcgcol)->vals, (*gcgcol)->maxvars);
247 for( i = 0; i < (*gcgcol)->ninferredpricingvars; ++i )
248 SCIP_CALL( SCIPreleaseVar((*gcgcol)->pricingprob, &(*gcgcol)->inferredpricingvars[i]) );
249 assert((*gcgcol)->ninferredpricingvars == 0 || (*gcgcol)->inferredpricingvars != NULL);
250 SCIPfreeBlockMemoryArrayNull((*gcgcol)->pricingprob, &(*gcgcol)->inferredpricingvars, (*gcgcol)->maxinferredpricingvars);
251 assert((*gcgcol)->ninferredpricingvars == 0 || (*gcgcol)->inferredpricingvals != NULL);
252 SCIPfreeBlockMemoryArrayNull((*gcgcol)->pricingprob, &(*gcgcol)->inferredpricingvals, (*gcgcol)->maxinferredpricingvars);
253 SCIPfreeBlockMemoryArrayNull((*gcgcol)->pricingprob, &(*gcgcol)->mastercoefs, (*gcgcol)->maxmastercoefs);
254 SCIPfreeBlockMemoryArrayNull((*gcgcol)->pricingprob, &(*gcgcol)->linkvars, (*gcgcol)->maxlinkvars);
255 SCIPfreeBlockMemoryArrayNull((*gcgcol)->pricingprob, &(*gcgcol)->originalsepamastercuts, (*gcgcol)->maxoriginalsepamastercuts);
256
257 /* free data structures for storing coefficients of mastercuts generated by separators */
258 SCIPfreeBlockMemoryArrayNull((*gcgcol)->pricingprob, &((*gcgcol)->mastersepacutcoeffs), (*gcgcol)->mastersepacutscoeffssize);
259 (*gcgcol)->mastersepacutscoeffssize =0;
260 (*gcgcol)->nmastersepacutcoeffs = 0;
261
262 SCIPfreeBlockMemory((*gcgcol)->pricingprob, gcgcol);
263 return SCIP_OKAY;
264}
265
266/** create a gcg column from a solution to a pricing problem */
268 GCG* gcg, /**< GCG data structure */
269 SCIP* pricingprob, /**< SCIP data structure (pricing problem) */
270 SCIP* subproblem, /**< SCIP data structure that contains the actual solution (if NULL pricingprob will be used) */
271 SCIP_HASHMAP* varmap, /**< mapping of pricingprob vars to subproblem vars (can be NULL if subproblem is NULL) */
272 GCG_COL** gcgcol, /**< pointer to store gcg column */
273 int prob, /**< number of corresponding pricing problem */
274 SCIP_SOL* sol, /**< solution of pricing problem with index prob */
275 SCIP_Bool isray, /**< is column a ray? */
276 SCIP_Real redcost /**< last known reduced cost */
277 )
278{
279 SCIP* solprob;
280 SCIP_VAR** solvars;
281 SCIP_VAR** colvars;
282
283 SCIP_Real* colvals;
284
285 int nsolvars;
286 int ncolvars;
287
288 int i;
289
290 if ( subproblem == NULL )
291 solprob = pricingprob;
292 else
293 solprob = subproblem;
294
295 solvars = SCIPgetOrigVars(pricingprob);
296 nsolvars = SCIPgetNOrigVars(pricingprob);
297
298 SCIP_CALL( SCIPallocBufferArray(pricingprob, &colvars, nsolvars) );
299 SCIP_CALL( SCIPallocBufferArray(pricingprob, &colvals, nsolvars) );
300
301 ncolvars = 0;
302
303 for( i = 0; i < nsolvars; ++i )
304 {
305 SCIP_VAR* solvar;
307
308 solvar = solvars[i];
309 if ( varmap != NULL )
310 solval = SCIPgetSolVal(subproblem, sol, SCIPhashmapGetImage(varmap, solvar));
311 else
312 solval = SCIPgetSolVal(pricingprob, sol, solvar);
313
314 /* round solval if possible to avoid numerical troubles */
315 if( SCIPvarIsIntegral(solvar) && SCIPisFeasIntegral(solprob, solval) )
316 solval = SCIPround(solprob, solval);
317
318 if( SCIPisZero(solprob, solval) )
319 {
320 continue;
321 }
322
323 colvars[ncolvars] = solvar;
324 colvals[ncolvars] = solval;
325 ++ncolvars;
326 }
327
328 SCIP_CALL( GCGcreateGcgCol(gcg, pricingprob, gcgcol, prob, colvars, colvals, ncolvars, isray, redcost) );
329
330 SCIPfreeBufferArray(pricingprob, &colvals);
331 SCIPfreeBufferArray(pricingprob, &colvars);
332
333 return SCIP_OKAY;
334}
335
336/** comparison method for sorting gcg columns by non-decreasing reduced cost */
337SCIP_DECL_SORTPTRCOMP(GCGcolCompRedcost)
338{
339 SCIP_Real redcost1;
340 SCIP_Real redcost2;
341
342 redcost1 = GCGcolGetRedcost((GCG_COL*) elem1);
343 redcost2 = GCGcolGetRedcost((GCG_COL*) elem2);
344
345 if( redcost1 < redcost2 )
346 return -1;
347 else if( redcost1 > redcost2 )
348 return +1;
349 else
350 return 0;
351}
352
353/** comparison method for sorting gcg columns by non-increasing age */
355{
356 int age1;
357 int age2;
358
359 age1 = GCGcolGetAge((GCG_COL*) elem1);
360 age2 = GCGcolGetAge((GCG_COL*) elem2);
361
362 if( age1 < age2 )
363 return +1;
364 else if( age1 > age2 )
365 return -1;
366 else
367 return 0;
368}
369
370/** comparison method for gcg columns. Returns TRUE iff columns are equal */
372 GCG_COL* gcgcol1,
373 GCG_COL* gcgcol2
374 )
375{
376 SCIP* pricingprob;
377
378 SCIP_VAR** vars1;
379 SCIP_VAR** vars2;
380
381 SCIP_Real* vals1;
382 SCIP_Real* vals2;
383
384 int i;
385
386 if( gcgcol1->probnr != gcgcol2->probnr )
387 return FALSE;
388
389 if( gcgcol1->nvars != gcgcol2->nvars )
390 return FALSE;
391
392 pricingprob = GCGcolGetPricingProb(gcgcol1);
393
394 vars1 = GCGcolGetVars(gcgcol1);
395 vars2 = GCGcolGetVars(gcgcol2);
396
397 vals1 = GCGcolGetVals(gcgcol1);
398 vals2 = GCGcolGetVals(gcgcol2);
399
400 for( i = 0; i < gcgcol1->nvars; ++i )
401 {
402 if( vars1[i] != vars2[i] || !SCIPisEQ(pricingprob, vals1[i], vals2[i]) )
403 {
404 return FALSE;
405 }
406 }
407
408#ifndef NDEBUG
409 vars1 = gcgcol1->inferredpricingvars;
410 vars2 = gcgcol2->inferredpricingvars;
411
412 vals1 = gcgcol1->inferredpricingvals;
413 vals2 = gcgcol2->inferredpricingvals;
414
416 for( i = 0; i < gcgcol1->ninferredpricingvars; ++i )
417 {
418 assert(vars1[i] == vars2[i] && SCIPisEQ(pricingprob, vals1[i], vals2[i]));
419 }
420#endif
421
422 return TRUE;
423
424}
425
426/** get pricing problem index of gcg column */
428 GCG_COL* gcgcol
429 )
430{
431 return gcgcol->probnr;
432}
433
434/** get pricing problem of gcg column */
436 GCG_COL* gcgcol
437 )
438{
439 return gcgcol->pricingprob;
440}
441
442/** get variables of gcg column */
444 GCG_COL* gcgcol
445 )
446{
447 return gcgcol->vars;
448}
449
450/** get values of gcg column */
452 GCG_COL* gcgcol
453 )
454{
455 return gcgcol->vals;
456}
457
458/** get number of variables of gcg column */
460 GCG_COL* gcgcol
461 )
462{
463 return gcgcol->nvars;
464}
465
466/** is gcg column a ray? */
468 GCG_COL* gcgcol
469 )
470{
471 return gcgcol->isray;
472}
473
474/** get reduced cost of gcg column */
476 GCG_COL* gcgcol
477 )
478{
479 return gcgcol->redcost;
480}
481
482/** get age of gcg column */
484 GCG_COL* gcgcol
485 )
486{
487 return gcgcol->age;
488}
489
490/** update reduced cost of variable and increase age */
492 GCG_COL* gcgcol, /**< gcg column structure */
493 SCIP_Real redcost, /**< new reduced cost */
494 SCIP_Bool growold /**< change age depending on reduced cost? */
495 )
496{
497 gcgcol->redcost = redcost;
498
499 if( !growold )
500 return;
501
502 if( !SCIPisNegative(gcgcol->pricingprob, redcost) )
503 ++(gcgcol->age);
504 else
505 gcgcol->age = 0;
506}
507
508/** get master coefficients of column */
510 GCG_COL* gcgcol /**< gcg column structure */
511 )
512{
513 return gcgcol->mastercoefs;
514}
515
516/** get number of master coefficients of column */
518 GCG_COL* gcgcol /**< gcg column structure */
519 )
520{
521 return gcgcol->nmastercoefs;
522}
523
524/** set master coefficients information of column */
526 GCG_COL* gcgcol, /**< gcg column structure */
527 SCIP_Real* mastercoefs, /**< array of master coefficients */
528 int nmastercoefs /**< new number of master coefficients */
529 )
530{
531 int i;
532
533 SCIPdebugMessage("Col set master coefs\n");
534 assert(gcgcol->nmastercoefs == 0);
535 if( nmastercoefs == 0 )
536 return SCIP_OKAY;
537
538 gcgcol->maxmastercoefs = SCIPcalcMemGrowSize(gcgcol->pricingprob, nmastercoefs);
540
541 for( i = 0; i < nmastercoefs; ++i )
542 {
543 SCIP_Real coef = mastercoefs[i];
544 gcgcol->mastercoefs[i] = coef;
545 }
546
547 gcgcol->nmastercoefs = nmastercoefs;
548
549 return SCIP_OKAY;
550}
551
552/** set norm of column */
554 GCG_COL* gcgcol, /**< gcg column structure */
555 SCIP_Real norm /**< norm of column */
556 )
557{
558 gcgcol->norm = norm;
559}
560
561/** get norm of column */
563 GCG* gcg, /**< GCG data structure */
564 GCG_COL* gcgcol /**< gcg column structure */
565 )
566{
567 SCIP* scip;
568 int i;
569 int j;
570 SCIP_Real norm;
571
572 assert(gcg != NULL);
573 assert(gcgcol != NULL);
574
576 norm = 0.0;
577 /* compute scalar of master values of gcg columns */
578 for( i = 0; i < gcgcol->nmastercoefs; ++i )
579 {
580 if( !SCIPisZero(scip, gcgcol->mastercoefs[i]) )
581 norm += SQR(gcgcol->mastercoefs[i]);
582 }
583
584 for( i = 0; i < gcgcol->noriginalsepamastercuts; ++i )
585 {
586 if( !SCIPisZero(scip, gcgcol->originalsepamastercuts[i]) )
587 norm += SQR(gcgcol->originalsepamastercuts[i]);
588 }
589
590 /* consider coefficients for cuts generated by separators */
591 for( j = 0; j < gcgcol->nmastersepacutcoeffs; j++ )
592 {
593 if( !SCIPisZero(scip, gcgcol->mastersepacutcoeffs[j]) )
594 norm += SQR(gcgcol->mastersepacutcoeffs[j]);;
595 }
596
597 for( i = 0; i < gcgcol->ninferredpricingvars; ++i )
598 {
600 norm += SQR(gcgcol->inferredpricingvals[i]);
601 }
602
603 for( i = 0; i < gcgcol->nlinkvars; ++i )
604 {
605 if( !SCIPisZero(scip, gcgcol->vals[gcgcol->linkvars[i]]) )
606 norm += gcgcol->vals[gcgcol->linkvars[i]];
607 }
608
609 /* consider convexity constraint */
610 norm += 1.0;
611
612 gcgcol->norm = norm;
613 return SCIP_OKAY;
614}
615
616/** set master coefficients of column as initialized */
618 GCG_COL* gcgcol /**< gcg column structure */
619 )
620{
621 assert(!gcgcol->initcoefs);
622 gcgcol->initcoefs = TRUE;
623 return SCIP_OKAY;
624}
625
626/** return if master coefficients of column have been initialized */
628 GCG_COL* gcgcol /**< gcg column structure */
629 )
630{
631 return gcgcol->initcoefs;
632}
633
634/** get master coefficients of column */
636 GCG_COL* gcgcol /**< gcg column structure */
637 )
638{
639 return gcgcol->linkvars;
640}
641
642/** get number of master coefficients of column */
644 GCG_COL* gcgcol /**< gcg column structure */
645 )
646{
647 return gcgcol->nlinkvars;
648}
649
650/** set master coefficients information of column */
652 GCG_COL* gcgcol, /**< gcg column structure */
653 int* linkvars, /**< array of linking variable indices for gcgcol->var */
654 int nlinkvars /**< number of linking variables in gcgcol->var */
655 )
656{
657 int i;
658
659 assert(gcgcol->nlinkvars == 0);
660
661 gcgcol->maxlinkvars = SCIPcalcMemGrowSize(gcgcol->pricingprob, nlinkvars);
662 SCIP_CALL( SCIPallocBlockMemoryArray(gcgcol->pricingprob, &(gcgcol->linkvars), gcgcol->maxlinkvars) );
663
664 for( i = 0; i < nlinkvars; ++i )
665 {
666 gcgcol->linkvars[i] = linkvars[i];
667 }
668
669 gcgcol->nlinkvars = nlinkvars;
670
671 return SCIP_OKAY;
672}
673
674/** get original separator cut coefficients of column in master problem */
676 GCG_COL* gcgcol /**< gcg column structure */
677 )
678{
679 return gcgcol->originalsepamastercuts;
680}
681
682/** get number of original separator cut coefficients of column in master problem */
684 GCG_COL* gcgcol /**< gcg column structure */
685 )
686{
687 return gcgcol->noriginalsepamastercuts;
688}
689
690/** get norm of column */
692 GCG_COL* gcgcol /**< gcg column structure */
693 )
694{
695 return gcgcol->norm;
696}
697
698/** update original separator cut coefficients information of column in the master problem */
700 GCG_COL* gcgcol, /**< gcg column structure */
701 SCIP_Real* neworiginalsepamastercuts,/**< pointer to new array of extended master cons coefficients */
702 int nneworiginalsepamastercuts/**< new number of extended master cons coefficients */
703 )
704{
705 int i;
706 int newsize;
707
708 i = gcgcol->noriginalsepamastercuts + nneworiginalsepamastercuts;
709 newsize = SCIPcalcMemGrowSize(gcgcol->pricingprob, i);
710 if( i > gcgcol->maxoriginalsepamastercuts )
711 {
713 gcgcol->maxoriginalsepamastercuts, newsize) );
714 }
715
716 gcgcol->maxoriginalsepamastercuts = newsize;
717
718 for( i = 0; i < nneworiginalsepamastercuts; ++i )
719 {
720 gcgcol->originalsepamastercuts[gcgcol->noriginalsepamastercuts] = neworiginalsepamastercuts[i];
721 ++(gcgcol->noriginalsepamastercuts);
722 }
723
724 return SCIP_OKAY;
725}
726
727/** update the column's stored coefficients for mastersepacut */
729 GCG_COL* gcgcol, /**< gcg column structure */
730 SCIP_Real* mastersepacutcoeffs, /**< pointer to array of new mastercut coefficients */
731 int nmastersepacutcoeffs /**< number of new mastercut coefficients */
732 )
733{
734 int i;
735
736 SCIPdebugMessage("append %i coefficients for master separator cuts\n", nmastersepacutcoeffs);
737
738 /* allocate memory for new coefficients (if necessary) */
739 if( gcgcol->mastersepacutscoeffssize < nmastersepacutcoeffs )
740 {
741 int newsize = SCIPcalcMemGrowSize(gcgcol->pricingprob, nmastersepacutcoeffs);
743 gcgcol->mastersepacutscoeffssize = newsize;
744 }
745
746 /* transfer coefficients to array */
747 SCIPdebugMessage("current number of coefficients %i\n", gcgcol->nmastersepacutcoeffs);
748 for( i = 0; i < nmastersepacutcoeffs; i++ )
749 {
750 SCIPdebugMessage("add %f at %i\n", mastersepacutcoeffs[i], i);
751 gcgcol->mastersepacutcoeffs[i] = mastersepacutcoeffs[i];
752 }
753 gcgcol->nmastersepacutcoeffs = nmastersepacutcoeffs;
754
755 return SCIP_OKAY;
756}
757
758
759/** get the column's number of stored coefficients for mastersepacuts */
761 GCG_COL* gcgcol /**< gcg column structure */
762 )
763{
764 return gcgcol->nmastersepacutcoeffs;
765}
766
767/** get the size of the column's array for mastersepacut coefficients */
769 GCG_COL* gcgcol /**< gcg column structure */
770 )
771{
772 return gcgcol->mastersepacutscoeffssize;
773}
774
775/** get the column's coefficients for the mastersepacuts */
777 GCG_COL* gcgcol /**< gcg column structure */
778 )
779{
780 return gcgcol->mastersepacutcoeffs;
781}
782
783/** return solution value of variable in gcg column */
785 GCG_COL* gcgcol, /**< gcg column */
786 SCIP_VAR* var /**< variable */
787 )
788{
789 SCIP_VAR** vars = NULL;
790 SCIP_Real* vals;
791 int nvars;
792 int pos;
793
794 if( GCGvarIsPricing(var) )
795 {
796 vars = gcgcol->vars;
797 vals = gcgcol->vals;
798 nvars = gcgcol->nvars;
799 }
800 else if( GCGvarIsInferredPricing(var) )
801 {
802 vars = gcgcol->inferredpricingvars;
803 vals = gcgcol->inferredpricingvals;
804 nvars = gcgcol->ninferredpricingvars;
805 }
806
807 if( vars != NULL && SCIPsortedvecFindPtr((void**) vars, SCIPvarComp, (void*) var, nvars, &pos) )
808 return vals[pos];
809
810 return 0.0;
811}
812
813/** returns whether the col's age exceeds the age limit */
815 GCG_COL* col, /**< col to check */
816 int agelimit /**< maximum age a col can reach before it is deleted from the pool, or -1 */
817 )
818{
819 assert(col != NULL);
820
821 return (agelimit >= 0 && col->age > agelimit);
822}
823
824/** compute parallelism of column to dual objective */
826 GCG* gcg, /**< GCG data structure */
827 GCG_COL* gcgcol, /**< gcg column */
828 SCIP_Real* para /**< pointer to store the parallelism of column to dual objective */
829 )
830{
831 int i;
832 int j;
833
834 GCG_EXTENDEDMASTERCONSDATA** activecuts;
835 SCIP_CONS** masterconss;
836 SCIP_ROW** originalsepamastercuts;
837 SCIP_Real dualobjnorm;
839
840 assert(gcg != NULL);
841
843
844 assert(gcgcol != NULL);
845
846 masterconss = GCGgetMasterConss(gcg);
847 originalsepamastercuts = GCGsepaGetOriginalSepaMastercuts(gcg);
848
849 *para = 0.0;
850
851 dualobjnorm = 0.0;
852
853 /* compute scalar of master values of gcg columns */
854 for( i = 0; i < gcgcol->nmastercoefs; ++i )
855 {
856 SCIP_Real lhs;
857 SCIP_Real rhs;
858
859 lhs = SCIPgetLhsLinear(masterprob, masterconss[i]);
860 rhs = SCIPgetRhsLinear(masterprob, masterconss[i]);
861
862 if( !SCIPisInfinity(masterprob, -lhs) )
863 {
864 dualobjnorm += SQR(lhs);
865
866 if( SCIPisPositive(masterprob, gcgcol->mastercoefs[i]) )
867 *para += gcgcol->mastercoefs[i] * lhs;
868 }
869 else if( !SCIPisInfinity(masterprob, rhs) )
870 {
871 dualobjnorm += SQR(rhs);
872
873 if(SCIPisNegative(masterprob, gcgcol->mastercoefs[i] ) )
874 *para += gcgcol->mastercoefs[i] * rhs;
875 }
876 }
877
878 for( i = 0; i < gcgcol->noriginalsepamastercuts; ++i )
879 {
880 SCIP_Real lhs;
881 SCIP_Real rhs;
882
883 if( !SCIProwIsInLP(originalsepamastercuts[i]) )
884 continue;
885
886 lhs = SCIProwGetLhs(originalsepamastercuts[i]);
887 rhs = SCIProwGetRhs(originalsepamastercuts[i]);
888
889 if( !SCIPisInfinity(masterprob, -lhs))
890 {
891 dualobjnorm += SQR(lhs);
892
894 *para += gcgcol->originalsepamastercuts[i] * lhs;
895 }
896 else if( !SCIPisInfinity(masterprob, rhs) )
897 {
898 dualobjnorm += SQR(rhs);
899
901 *para += gcgcol->originalsepamastercuts[i] * rhs;
902 }
903 }
904
905 for( i = 0; i < gcgcol->ninferredpricingvars; ++i )
906 {
907 SCIP_Real lhs;
908 SCIP_Real rhs;
909 SCIP_Real coef;
910 GCG_EXTENDEDMASTERCONSDATA* branchextendedmasterconsdata;
911
912 coef = gcgcol->inferredpricingvals[i];
914
915 branchextendedmasterconsdata = GCGinferredPricingVarGetExtendedmasterconsdata(gcgcol->inferredpricingvars[i]);
916 lhs = GCGextendedmasterconsGetLhs(gcg, branchextendedmasterconsdata);
917 rhs = GCGextendedmasterconsGetRhs(gcg, branchextendedmasterconsdata);
918
919 if( !SCIPisInfinity(masterprob, -lhs))
920 {
921 dualobjnorm += SQR(lhs);
922
923 if( SCIPisPositive(masterprob, coef) )
924 *para += coef * lhs;
925 }
926 else if( !SCIPisInfinity(masterprob, rhs) )
927 {
928 dualobjnorm += SQR(rhs);
929
930 if( SCIPisPositive(masterprob, coef) )
931 *para += coef * rhs;
932 }
933 }
934
935 /* consider cuts generated by separators */
936 activecuts = GCGgetActiveMastersepacuts(gcg);
937 for( j = 0; j < gcgcol->nmastersepacutcoeffs; j++ )
938 {
939 SCIP_ROW* mastercutrow;
940 SCIP_Real lhs;
941 SCIP_Real rhs;
942
943 if( !GCGextendedmasterconsIsActive(activecuts[j]) )
944 continue;
945
946 mastercutrow = GCGextendedmasterconsGetRow(activecuts[j]);
947 lhs = SCIProwGetLhs(mastercutrow);
948 rhs = SCIProwGetRhs(mastercutrow);
949
950 if( !SCIPisInfinity(masterprob, -lhs) )
951 {
952 dualobjnorm += SQR(lhs);
953
955 *para += gcgcol->mastersepacutcoeffs[j] * lhs;
956 }
957 else if( !SCIPisInfinity(masterprob, rhs) )
958 {
959 dualobjnorm += SQR(rhs);
960
962 *para += gcgcol->mastersepacutcoeffs[j] * rhs;
963 }
964 }
965
966 for( i = 0; i < GCGgetNPricingprobs(gcg); ++i )
967 dualobjnorm += SQR(GCGgetNIdenticalBlocks(gcg, i));
968
969 *para += SQR(GCGgetNIdenticalBlocks(gcg, gcgcol->probnr));
970
972
973 dualobjnorm = sqrt(dualobjnorm);
974 assert(!SCIPisInfinity(masterprob, dualobjnorm));
975 assert(SCIPisPositive(masterprob, dualobjnorm));
977
978 *para = (*para) / (dualobjnorm * gcgcol->norm);
979
980 return SCIP_OKAY;
981}
982
983/** compute orthogonality of two gcg columns */
985 GCG* gcg, /**< GCG data structure */
986 GCG_COL* gcgcol1, /**< first gcg column */
987 GCG_COL* gcgcol2, /**< second gcg column */
988 SCIP_Real* orth /**< pointer to store the orthogonality of two gcg columns */
989 )
990{
991 SCIP* scip;
992 int i;
993 int j;
994 SCIP_Real para = 0.0;
995 SCIP_Real norm1 = 0.0;
996 SCIP_Real norm2 = 0.0;
997
998 assert(gcg != NULL);
999 assert(gcgcol1 != NULL);
1000 assert(gcgcol2 != NULL);
1001
1003
1004 /* compute scalar of master values of gcg columns */
1005 for( i = 0; i < gcgcol1->nmastercoefs; ++i )
1006 {
1007 if( SCIPisPositive(scip, gcgcol1->mastercoefs[i] * gcgcol2->mastercoefs[i]) )
1008 para += gcgcol1->mastercoefs[i] * gcgcol2->mastercoefs[i];
1009
1010 if( SCIPisPositive(scip, gcgcol1->mastercoefs[i]) )
1011 norm1 += SQR(gcgcol1->mastercoefs[i]);
1012 if( SCIPisPositive(scip, gcgcol2->mastercoefs[i]) )
1013 norm2 += SQR(gcgcol2->mastercoefs[i]);
1014 }
1015
1016 for( i = 0; i < gcgcol1->noriginalsepamastercuts; ++i )
1017 {
1019 para += gcgcol1->originalsepamastercuts[i] * gcgcol2->originalsepamastercuts[i];
1020
1022 norm1 += SQR(gcgcol1->originalsepamastercuts[i]);
1024 norm2 += SQR(gcgcol2->originalsepamastercuts[i]);
1025 }
1026
1027 /* consider cuts generated by separators */
1028 assert(gcgcol1->nmastersepacutcoeffs == gcgcol2->nmastersepacutcoeffs);
1029 for( j = 0; j < gcgcol1->nmastersepacutcoeffs; j++ )
1030 {
1031 if( SCIPisPositive(scip, gcgcol1->mastersepacutcoeffs[j] * gcgcol2->mastersepacutcoeffs[j]) )
1032 para += gcgcol1->mastersepacutcoeffs[j] * gcgcol2->mastersepacutcoeffs[j];
1033
1034 if( SCIPisPositive(scip, gcgcol1->mastersepacutcoeffs[j]) )
1035 norm1 += SQR(gcgcol1->mastersepacutcoeffs[j]);
1036
1037 if( SCIPisPositive(scip, gcgcol2->mastersepacutcoeffs[j]) )
1038 norm2 += SQR(gcgcol2->mastersepacutcoeffs[j]);
1039 }
1040
1041 i = 0;
1042 j = 0;
1043 while( i < gcgcol1->ninferredpricingvars || j < gcgcol2->ninferredpricingvars )
1044 {
1045 if( i < gcgcol1->ninferredpricingvars && j < gcgcol2->ninferredpricingvars &&
1046 gcgcol1->inferredpricingvars[i] == gcgcol2->inferredpricingvars[j] )
1047 {
1048 SCIP_Real coef1 = gcgcol1->inferredpricingvals[i];
1049 SCIP_Real coef2 = gcgcol2->inferredpricingvals[j];
1050
1051 assert(!SCIPisZero(scip, coef1));
1052
1053 if( SCIPisPositive(scip, coef1 * coef2) )
1054 para += coef1 * coef2;
1055
1056 if( SCIPisPositive(scip, coef1) )
1057 norm1 += SQR(coef1);
1058 if( SCIPisPositive(scip, coef2) )
1059 norm2 += SQR(coef2);
1060 ++i;
1061 ++j;
1062 }
1063 else if( i < gcgcol1->ninferredpricingvars &&
1065 {
1066 if( SCIPisPositive(scip, gcgcol1->inferredpricingvals[i]) )
1067 norm1 += SQR(gcgcol1->inferredpricingvals[i]);
1068 ++i;
1069 }
1070 else
1071 {
1072 assert(j < gcgcol2->ninferredpricingvars);
1074 if( SCIPisPositive(scip, gcgcol2->inferredpricingvals[j]) )
1075 norm2 += SQR(gcgcol2->inferredpricingvals[j]);
1076 ++j;
1077 }
1078 }
1079
1080 for( i = 0; i < gcgcol1->nlinkvars; ++i )
1081 {
1082 SCIP_VAR* linkvar1;
1083 SCIP_Real linkval1;
1084 linkvar1 = gcgcol1->vars[gcgcol1->linkvars[i]];
1085 linkval1 = gcgcol1->vals[gcgcol1->linkvars[i]];
1086
1087 norm1 += SQR(linkval1);
1088
1089 for( j = 0; j < gcgcol2->nlinkvars; ++j )
1090 {
1091 SCIP_VAR* linkvar2;
1092 SCIP_Real linkval2;
1093 linkvar2 = gcgcol2->vars[gcgcol2->linkvars[j]];
1094 linkval2 = gcgcol2->vals[gcgcol2->linkvars[j]];
1095
1096 if( linkvar1 == linkvar2 )
1097 {
1098 para += linkval1 * linkval2;
1099 break;
1100 }
1101 }
1102 }
1103
1104 for( i = 0; i < gcgcol2->nlinkvars; ++i )
1105 {
1106 SCIP_Real linkval2;
1107
1108 linkval2 = gcgcol2->vals[gcgcol2->linkvars[i]];
1109
1110 norm2 += SQR(linkval2);
1111 }
1112
1113
1114 /* scalar for convexitiy constraints */
1115 if( gcgcol1->probnr == gcgcol2->probnr )
1116 para *= 1.0;
1117
1118 norm1 *= 1.0;
1119 norm2 *= 1.0;
1120
1121 norm1 = sqrt(norm1);
1122 norm2 = sqrt(norm2);
1123
1124 assert(SCIPisPositive(scip, norm1) && SCIPisPositive(scip, norm2));
1125
1126 para = para/(norm1*norm2);
1127
1128 *orth = 1.0 - para;
1129 return SCIP_OKAY;
1130}
1131
1132/** returns the inferred (coefficient) pricing variables solution values */
1134 GCG_COL* gcgcol /**< gcgcol */
1135 )
1136{
1137 return gcgcol->inferredpricingvals;
1138}
1139
1140/** returns the inferred (coefficient) pricing variables */
1142 GCG_COL* gcgcol /**< gcgcol */
1143 )
1144{
1145 return gcgcol->inferredpricingvars;
1146}
1147
1148/** returns the number of inferred (coefficient) pricing variables */
1150 GCG_COL* gcgcol /**< gcgcol */
1151 )
1152{
1153 return gcgcol->ninferredpricingvars;
1154}
1155
1156/** updates column such that it respect the given active cuts */
1158 GCG* gcg, /**< GCG data structure */
1159 GCG_COL* gcgcol, /**< gcg column structure */
1160 GCG_EXTENDEDMASTERCONSDATA** mastersepacuts, /**< active master sepa cuts */
1161 int nmastersepacuts, /**< number of active cuts */
1162 SCIP_Real* mastersepacutcoefs /**< master sepa cut coefficients */
1163 )
1164{
1165 int i;
1166
1167 /* @todo: improve this, currently all active cuts are added again */
1168
1169 SCIP_CALL( GCGcolSetMastersepacutCoeffs(gcgcol, mastersepacutcoefs, nmastersepacuts) );
1170
1171 for( i = gcgcol->ninferredpricingvars-1; i >= 0; --i )
1172 {
1174 assert(extendedmasterconsdata != NULL);
1176 {
1177 gcgcol->ninferredpricingvars--;
1179 if( i < gcgcol->ninferredpricingvars )
1180 {
1183 }
1184 }
1185 }
1186
1187 if( gcgcol->ninferredpricingvars + nmastersepacuts > gcgcol->maxinferredpricingvars )
1188 {
1189 int oldsize = gcgcol->maxinferredpricingvars;
1190 gcgcol->maxinferredpricingvars = SCIPcalcMemGrowSize(gcgcol->pricingprob, gcgcol->ninferredpricingvars + nmastersepacuts);
1193 }
1194
1195 for( i = 0; i < nmastersepacuts; ++i )
1196 {
1197 GCG_EXTENDEDMASTERCONSDATA* mastersepacut = mastersepacuts[i];
1198 GCG_PRICINGMODIFICATION* pricingmodification = GCGextendedmasterconsGetPricingModification(gcg, mastersepacut, gcgcol->probnr);
1199
1200 if( !SCIPisZero(gcgcol->pricingprob, mastersepacutcoefs[i]) )
1201 {
1202 gcgcol->inferredpricingvars[gcgcol->ninferredpricingvars] = GCGpricingmodificationGetCoefVar(pricingmodification);
1203 gcgcol->inferredpricingvals[gcgcol->ninferredpricingvars] = mastersepacutcoefs[i];
1205 gcgcol->ninferredpricingvars++;
1206 }
1207 }
1208
1209 SCIPsortPtrReal((void**)gcgcol->inferredpricingvars, (double*)gcgcol->inferredpricingvals, SCIPvarComp, gcgcol->ninferredpricingvars);
1210
1211 return SCIP_OKAY;
1212}
1213
1214SCIP_DECL_HASHGETKEY(GCGhashGetKeyCol)
1215{ /*lint --e{715}*/
1216 assert(elem != NULL);
1217
1218 /* the key of a col is the col itself */
1219 return elem;
1220}
1221
1222SCIP_DECL_HASHKEYEQ(GCGhashKeyEqCol)
1223{ /*lint --e{715}*/
1224 return GCGcolIsEq((GCG_COL*)key1, (GCG_COL*)key2);
1225}
1226
1227SCIP_DECL_HASHKEYVAL(GCGhashKeyValCol)
1228{ /*lint --e{715}*/
1229 GCG_COL* col;
1230 unsigned int keyval;
1231 int minindex;
1232 int maxindex;
1233
1234 col = (GCG_COL*)key;
1235 assert(col != NULL);
1236
1237 /* TODO: this hash function does not respect tolerances (except the hard coded of SCIPrealHashCode)
1238 * but it seems that SCIP does it the same way */
1239 if( col->nvars > 0 )
1240 {
1241 minindex = SCIPvarGetIndex(col->vars[0]);
1242 maxindex = SCIPvarGetIndex(col->vars[col->nvars-1]);
1243 }
1244 else
1245 {
1246 minindex = INT_MAX;
1247 maxindex = INT_MAX;
1248 }
1249 assert(minindex <= maxindex);
1250 keyval = SCIPhashSeven(col->probnr, col->nvars, col->isray,
1251 SCIPrealHashCode(col->nvars > 0 ? col->vals[0] : 0.0), minindex,
1252 SCIPrealHashCode(col->nvars > 0 ? col->vals[col->nvars-1] : 0.0), maxindex);
1253
1254 return keyval;
1255}
SCIP_RETCODE GCGbranchGetExtendedmasterconsCoeff(GCG *gcg, GCG_EXTENDEDMASTERCONSDATA *extendedmasterconsdata, SCIP_VAR **solvars, SCIP_Real *solvals, int nsolvars, int probnr, GCG_COL *gcgcol, SCIP_Real *coeff)
Definition branchgcg.c:61
SCIP_DECL_HASHGETKEY(SCIPhashGetKeyCons)
#define SCIP_Bool
#define SCIP_Real
#define ABS(x)
#define SQR(x)
#define TRUE
#define FALSE
int GCGgetNActiveMastersepacuts(GCG *gcg)
GCG_EXTENDEDMASTERCONSDATA ** GCGgetActiveMastersepacuts(GCG *gcg)
SCIP_VAR * GCGpricingmodificationGetCoefVar(GCG_PRICINGMODIFICATION *pricingmodification)
SCIP_Real GCGextendedmasterconsGetRhs(GCG *gcg, GCG_EXTENDEDMASTERCONSDATA *extendedmasterconsdata)
SCIP_ROW * GCGextendedmasterconsGetRow(GCG_EXTENDEDMASTERCONSDATA *extendedmasterconsdata)
SCIP_Bool GCGextendedmasterconsIsActive(GCG_EXTENDEDMASTERCONSDATA *extendedmasterconsdata)
GCG_EXTENDEDMASTERCONSTYPE GCGextendedmasterconsGetType(GCG_EXTENDEDMASTERCONSDATA *extendedmasterconsdata)
SCIP_Real GCGextendedmasterconsGetLhs(GCG *gcg, GCG_EXTENDEDMASTERCONSDATA *extendedmasterconsdata)
GCG_PRICINGMODIFICATION * GCGextendedmasterconsGetPricingModification(GCG *gcg, GCG_EXTENDEDMASTERCONSDATA *extendedmasterconsdata, int blocknr)
GCG interface methods.
SCIP_VAR ** GCGpricingVarGetOrigvars(SCIP_VAR *var)
Definition gcgvar.c:1100
int GCGpricingVarGetNOrigvars(SCIP_VAR *var)
Definition gcgvar.c:1082
int GCGcountInferredCoefPricingVars(SCIP_VAR **vars, int nvars)
Definition gcgvar.c:210
GCG_EXPORT SCIP_Bool GCGvarIsInferredPricing(SCIP_VAR *var)
Definition gcgvar.c:195
GCG_EXTENDEDMASTERCONSDATA * GCGinferredPricingVarGetExtendedmasterconsdata(SCIP_VAR *var)
Definition gcgvar.c:2070
SCIP_Real SCIPgetRhsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_Real SCIPgetLhsLinear(SCIP *scip, SCIP_CONS *cons)
int GCGgetNAppliedPricingproblemModifications(GCG *gcg, int probnr)
int GCGgetNActivePricingproblemModifications(GCG *gcg, int probnr)
SCIP_RETCODE GCGcolSetMastersepacutCoeffs(GCG_COL *gcgcol, SCIP_Real *mastersepacutcoeffs, int nmastersepacutcoeffs)
Definition gcgcol.c:728
SCIP_RETCODE GCGcolComputeNorm(GCG *gcg, GCG_COL *gcgcol)
Definition gcgcol.c:562
SCIP_Real * GCGcolGetMastercoefs(GCG_COL *gcgcol)
Definition gcgcol.c:509
int GCGcolGetMastersepacutCoeffsSize(GCG_COL *gcgcol)
Definition gcgcol.c:768
int GCGcolGetNOriginalSepaMastercuts(GCG_COL *gcgcol)
Definition gcgcol.c:683
SCIP_Real * GCGcolGetOriginalSepaMastercuts(GCG_COL *gcgcol)
Definition gcgcol.c:675
int GCGcolGetNLinkvars(GCG_COL *gcgcol)
Definition gcgcol.c:643
SCIP_Real * GCGcolGetVals(GCG_COL *gcgcol)
Definition gcgcol.c:451
SCIP_RETCODE GCGcolUpdateOriginalSepaMastercuts(GCG_COL *gcgcol, SCIP_Real *neworiginalsepamastercuts, int nneworiginalsepamastercuts)
Definition gcgcol.c:699
SCIP_Real * GCGcolGetInferredPricingVals(GCG_COL *gcgcol)
Definition gcgcol.c:1133
SCIP_RETCODE GCGcolSetInitializedCoefs(GCG_COL *gcgcol)
Definition gcgcol.c:617
SCIP_RETCODE GCGcreateGcgColFromSol(GCG *gcg, SCIP *pricingprob, SCIP *subproblem, SCIP_HASHMAP *varmap, GCG_COL **gcgcol, int prob, SCIP_SOL *sol, SCIP_Bool isray, SCIP_Real redcost)
Definition gcgcol.c:267
SCIP_Real GCGcolGetNorm(GCG_COL *gcgcol)
Definition gcgcol.c:691
void GCGcolUpdateRedcost(GCG_COL *gcgcol, SCIP_Real redcost, SCIP_Bool growold)
Definition gcgcol.c:491
SCIP_RETCODE GCGcolSetLinkvars(GCG_COL *gcgcol, int *linkvars, int nlinkvars)
Definition gcgcol.c:651
SCIP_VAR ** GCGcolGetVars(GCG_COL *gcgcol)
Definition gcgcol.c:443
SCIP_RETCODE GCGfreeGcgCol(GCG_COL **gcgcol)
Definition gcgcol.c:231
int GCGcolGetNMastersepacutCoeffs(GCG_COL *gcgcol)
Definition gcgcol.c:760
SCIP_Real * GCGcolGetMastersepaCutCoeffs(GCG_COL *gcgcol)
Definition gcgcol.c:776
SCIP_RETCODE GCGcreateGcgCol(GCG *gcg, SCIP *pricingprob, GCG_COL **gcgcol, int probnr, SCIP_VAR **vars, SCIP_Real *vals, int nvars, SCIP_Bool isray, SCIP_Real redcost)
Definition gcgcol.c:53
SCIP_Real GCGcolGetSolVal(GCG_COL *gcgcol, SCIP_VAR *var)
Definition gcgcol.c:784
int GCGcolGetNVars(GCG_COL *gcgcol)
Definition gcgcol.c:459
SCIP_Bool GCGcolIsRay(GCG_COL *gcgcol)
Definition gcgcol.c:467
SCIP * GCGcolGetPricingProb(GCG_COL *gcgcol)
Definition gcgcol.c:435
void GCGcolSetNorm(GCG_COL *gcgcol, SCIP_Real norm)
Definition gcgcol.c:553
int * GCGcolGetLinkvars(GCG_COL *gcgcol)
Definition gcgcol.c:635
SCIP_Bool GCGcolIsAged(GCG_COL *col, int agelimit)
Definition gcgcol.c:814
SCIP_Bool GCGcolGetInitializedCoefs(GCG_COL *gcgcol)
Definition gcgcol.c:627
SCIP_Real GCGcolGetRedcost(GCG_COL *gcgcol)
Definition gcgcol.c:475
SCIP_VAR ** GCGcolGetInferredPricingVars(GCG_COL *gcgcol)
Definition gcgcol.c:1141
SCIP_RETCODE GCGcolComputeDualObjPara(GCG *gcg, GCG_COL *gcgcol, SCIP_Real *para)
Definition gcgcol.c:825
SCIP_Bool GCGcolIsEq(GCG_COL *gcgcol1, GCG_COL *gcgcol2)
Definition gcgcol.c:371
int GCGcolGetProbNr(GCG_COL *gcgcol)
Definition gcgcol.c:427
SCIP_RETCODE GCGcolSetMastercoefs(GCG_COL *gcgcol, SCIP_Real *mastercoefs, int nmastercoefs)
Definition gcgcol.c:525
SCIP_RETCODE GCGcolUpdateActiveMastersepacuts(GCG *gcg, GCG_COL *gcgcol, GCG_EXTENDEDMASTERCONSDATA **mastersepacuts, int nmastersepacuts, SCIP_Real *mastersepacutcoefs)
Definition gcgcol.c:1157
int GCGcolGetNMastercoefs(GCG_COL *gcgcol)
Definition gcgcol.c:517
int GCGcolGetAge(GCG_COL *gcgcol)
Definition gcgcol.c:483
int GCGcolGetNInferredPricingVars(GCG_COL *gcgcol)
Definition gcgcol.c:1149
SCIP_RETCODE GCGcolComputeOrth(GCG *gcg, GCG_COL *gcgcol1, GCG_COL *gcgcol2, SCIP_Real *orth)
Definition gcgcol.c:984
GCG_EXPORT SCIP_CONS ** GCGgetMasterConss(GCG *gcg)
Definition relax_gcg.c:4228
GCG_EXPORT int GCGgetNIdenticalBlocks(GCG *gcg, int pricingprobnr)
Definition relax_gcg.c:4185
GCG_EXPORT int GCGgetNPricingprobs(GCG *gcg)
Definition relax_gcg.c:4113
SCIP * GCGgetMasterprob(GCG *gcg)
Definition gcg.cpp:99
SCIP_VAR ** SCIPgetOrigVars(SCIP *scip)
int SCIPgetNOrigVars(SCIP *scip)
void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin)
#define SCIPhashSeven(a, b, c, d, e, f, g)
SCIP_DECL_HASHKEYEQ(SCIPhashKeyEqString)
SCIP_DECL_HASHKEYVAL(SCIPhashKeyValString)
SCIP_DECL_SORTPTRCOMP(SCIPbendersComp)
int SCIPcalcMemGrowSize(SCIP *scip, int num)
#define SCIPallocBufferArray(scip, ptr, num)
#define SCIPallocBlockMemoryArray(scip, ptr, num)
#define SCIPreallocBlockMemoryArray(scip, ptr, oldnum, newnum)
#define SCIPfreeBlockMemory(scip, ptr)
#define SCIPfreeBlockMemoryArrayNull(scip, ptr, num)
#define SCIPallocBlockMemory(scip, ptr)
SCIP_Real SCIProwGetLhs(SCIP_ROW *row)
SCIP_Real SCIProwGetRhs(SCIP_ROW *row)
SCIP_Bool SCIProwIsInLP(SCIP_ROW *row)
SCIP_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var)
SCIP_Bool SCIPisPositive(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
SCIP_Real SCIPround(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisFeasIntegral(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisNegative(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisZero(SCIP *scip, SCIP_Real val)
SCIP_RETCODE SCIPvarGetOrigvarSum(SCIP_VAR **var, SCIP_Real *scalar, SCIP_Real *constant)
int SCIPvarGetIndex(SCIP_VAR *var)
SCIP_RETCODE SCIPreleaseVar(SCIP *scip, SCIP_VAR **var)
SCIP_Bool SCIPvarIsIntegral(SCIP_VAR *var)
int SCIPvarCompare(SCIP_VAR *var1, SCIP_VAR *var2)
SCIP_RETCODE SCIPcaptureVar(SCIP *scip, SCIP_VAR *var)
SCIP_Bool SCIPsortedvecFindPtr(void **ptrarray, SCIP_DECL_SORTPTRCOMP((*ptrcomp)), void *val, int len, int *pos)
void SCIPsortPtrReal(void **ptrarray, SCIP_Real *realarray, SCIP_DECL_SORTPTRCOMP((*ptrcomp)), int len)
SCIP_Bool GCGvarIsPricing(SCIP_VAR *var)
Definition gcgvar.c:159
static assert(heur !=NULL)
SCIP_CALL(SCIPgetExternBranchCands(origprob, &lpcands, &lpcandssol, NULL, &nlpcands, NULL, NULL, NULL, NULL))
SCIP_VAR * var
SCIP_VAR ** vars
int j
SCIP_Real solval
SCIPdebugMessage("feasibility pump finished [%d iterations done].\n", nloops)
int i
int nvars
SCIPfreeBufferArray(scip, &cycles)
SCIP_SOL * sol
#define NULL
SCIP_RETCODE GCGmastersepacutGetExtendedmasterconsCoeff(GCG *gcg, GCG_EXTENDEDMASTERCONSDATA *mastersepacut, SCIP_VAR **solvars, SCIP_Real *solvals, int nsolvars, int probnr, GCG_COL *gcgcol, SCIP_Real *coef)
GCG variable pricer.
public methods for working with gcg columns
SCIP_RETCODE GCGrelaxBranchGetAllActiveExtendedMasterConss(GCG *gcg, GCG_BRANCHRULE ***branchrules, GCG_BRANCHDATA ***branchdata, GCG_EXTENDEDMASTERCONSDATA ***extendedmasterconsdata, int *nextendedmasterconss)
Definition relax_gcg.c:3931
SCIP_ROW ** GCGsepaGetOriginalSepaMastercuts(GCG *gcg)
original separator
SCIP * pricingprob
SCIP_Real norm
SCIP_Real redcost
int nmastersepacutcoeffs
int * linkvars
int maxinferredpricingvars
SCIP_Bool initcoefs
int maxoriginalsepamastercuts
SCIP_VAR ** inferredpricingvars
int ninferredpricingvars
SCIP_Real * vals
int maxmastercoefs
SCIP_Real * originalsepamastercuts
int mastersepacutscoeffssize
SCIP_Bool isray
int maxlinkvars
int nmastercoefs
int nlinkvars
SCIP_Real * mastersepacutcoeffs
SCIP_Real * inferredpricingvals
int noriginalsepamastercuts
SCIP_VAR ** vars
SCIP_Real * mastercoefs
data structure to store columns (solutions from a pricing problem)
struct SCIP_Cons SCIP_CONS
@ GCG_EXTENDEDMASTERCONSTYPE_SEPA_ROW
struct GCG_ExtendedMasterConsData GCG_EXTENDEDMASTERCONSDATA
struct GCG_PricingModification GCG_PRICINGMODIFICATION
struct Gcg GCG
Definition type_gcg.h:44
struct GCG_Col GCG_COL
Definition type_gcgcol.h:44
struct SCIP_Row SCIP_ROW
struct SCIP_HashMap SCIP_HASHMAP
enum SCIP_Retcode SCIP_RETCODE
struct Scip SCIP
struct SCIP_Sol SCIP_SOL
struct SCIP_Var SCIP_VAR