GCG 4.1.1 (dev)

Generic Column Generation

Loading...
Searching...
No Matches
pricer_gcg.cpp
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 pricer_gcg.cpp
30 * @brief pricer for generic column generation
31 * @author Gerald Gamrath
32 * @author Martin Bergner
33 * @author Alexander Gross
34 * @author Christian Puchert
35 * @author Michael Bastubbe
36 * @author Jonas Witt
37 * @author Erik Muehmer
38 */
39
40/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
41/* #define SCIP_DEBUG */
42/* #define PRINTDUALSOLS */
43
46#include "gcg/gcgvarhistory.h"
47#include "gcg/pub_gcgvar.h"
48#include "gcg/type_branchgcg.h"
51#include "gcg/struct_gcg.h"
53#include "gcg/pub_gcg.hpp"
54#include <cassert>
55#include <cstring>
56
57/*lint -e64 disable useless and wrong lint warning */
58
59#ifdef __INTEL_COMPILER
60#ifndef _OPENMP
61#pragma warning disable 3180 /* disable wrong and useless omp warnings */
62#endif
63#endif
64#include "scip/scip.h"
65#include "gcg/gcg.h"
66
67#include "scip/cons_linear.h"
68#include "scip/cons_knapsack.h"
69
70#include "gcg/pricer_gcg.h"
71#include "gcg/objpricer_gcg.h"
72#include "gcg/sepa_original.h"
73#include "gcg/sepa_basis.h"
74
75#include "gcg/relax_gcg.h"
76#include "gcg/scip_misc.h"
77#include "gcg/pub_gcgvar.h"
78#include "gcg/pub_gcgcol.h"
79#include "gcg/pub_pricingjob.h"
80#include "gcg/pub_pricingprob.h"
81#include "gcg/pub_solver.h"
82#include "gcg/solver.h"
84#include "objscip/objscip.h"
85#include "gcg/objpricer_gcg.h"
89#include "gcg/branch_generic.h"
90#include "gcg/event_display.h"
91#include "gcg/pub_colpool.h"
92#include "gcg/gcgvarhistory.h"
93#include "gcg/struct_solver.h"
94#include "gcg/pricingcb.h"
95
96#ifdef SCIP_STATISTIC
97#include "scip/struct_scip.h"
98#include "scip/struct_stat.h"
99#endif
100
101#ifdef _OPENMP
102#include <omp.h>
103#include "gcg/struct_locks.h"
104#endif
105
106using namespace scip;
107
108#define PRICER_NAME "gcg"
109#define PRICER_DESC "pricer for gcg"
110#define PRICER_PRIORITY 5000000
111#define PRICER_DELAY TRUE /* only call pricer if all problem variables have non-negative reduced costs */
112
113#define DEFAULT_ABORTPRICINGINT TRUE /**< should the pricing be aborted when integral */
114#define DEFAULT_ABORTPRICINGGAP 0.00 /**< gap between dual bound and RMP objective at which pricing is aborted */
115#define DEFAULT_DISPINFOS FALSE /**< should additional information be displayed */
116#define DEFAULT_DISABLECUTOFF 2 /**< should the cutoffbound be applied in master LP solving? (0: on, 1:off, 2:auto) */
117#define DEFAULT_NTHREADS 1 /**< number of threads (0: up to omp_get_max_threads()) */
118#define DEFAULT_STABILIZATION TRUE /**< should stabilization be used */
119#define DEFAULT_STABILIZATIONTREE FALSE /**< should stabilization be used in nodes other than the root node*/
120#define DEFAULT_HYBRIDASCENT FALSE /**< should hybridization of smoothing with an ascent method be enabled */
121#define DEFAULT_HYBRIDASCENT_NOAGG FALSE /**< should hybridization of smoothing with an ascent method be enabled
122 * if pricing problems cannot be aggregated */
123
124#define DEFAULT_USECOLPOOL TRUE /**< should the colpool be checked for negative redcost cols before solving the pricing problems? */
125#define DEFAULT_PREVENTDUPLICATECOLS TRUE /**< should existing master variables be reused when transferring an original
126 * solution instead of creating duplicate columns? */
127#define DEFAULT_COLPOOL_AGELIMIT 100 /**< default age limit for columns in column pool */
128
129#define DEFAULT_PRICE_ORTHOFAC 0.0
130#define DEFAULT_PRICE_OBJPARALFAC 0.0
131#define DEFAULT_PRICE_REDCOSTFAC 1.0
132#define DEFAULT_PRICE_MINCOLORTH 0.0
133#define DEFAULT_PRICE_EFFICIACYCHOICE 0
134
135#define DEFAULT_USEARTIFICIALVARS FALSE /**< add artificial vars to master (instead of using Farkas pricing) */
136#define DEFAULT_USEMAXOBJ TRUE /**< default value for using maxobj for big M objective of artificial variables */
137#define DEFAULT_ONLYRELIABLEBIGM TRUE /**< default value for only using maxobj for big M objective of artificial variables if it is reliable */
138#define DEFAULT_FACTORUNRELIABLE 1000 /**< default factor to use for objective of unbounded variables */
139#define DEFAULT_BIGMARTIFICIAL 1000 /**< default value for big M objective of artificial variables (if maxobj is not used)*/
140
141#define EVENTHDLR_NAME "probdatavardeleted"
142#define EVENTHDLR_DESC "event handler for variable deleted event"
143
144/** small macro to simplify printing pricer information */
145#define GCGpricerPrintInfo(scip, pricerdata, ...) do { \
146 if( pricerdata->dispinfos ) { \
147 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, __VA_ARGS__);\
148 } else {\
149 SCIPdebugMessage(__VA_ARGS__); \
150 }\
151 }while( FALSE )
152
153#define PRICER_STAT_ARRAYLEN_TIME 1024 /**< length of the array for Time histogram representation */
154#define PRICER_STAT_BUCKETSIZE_TIME 10 /**< size of the buckets for Time histogram representation */
155#define PRICER_STAT_ARRAYLEN_VARS 1024 /**< length of the array for foundVars histogram representation */
156#define PRICER_STAT_BUCKETSIZE_VARS 1 /**< size of the buckets for foundVars histogram representation */
157
158/*
159 * Data structures
160 */
161
162/** variable pricer data */
164{
165 int npricingprobs; /**< number of pricing problems */
166 SCIP** pricingprobs; /**< pointers to the pricing problems */
167 SCIP_Real* dualsolconv; /**< array of dual solutions for the convexity constraints */
168 SCIP_Real* solvals; /**< solution values of variables in the pricing problems */
169 int maxsolvals; /**< capacity of solvals */
170 int* npointsprob; /**< number of variables representing points created by the pricing probs */
171 int* nraysprob; /**< number of variables representing rays created by the pricing probs */
172 SCIP_Longint currnodenr; /**< current node number in the masterproblem */
173 SCIP_HASHMAP* mapcons2idx; /**< hashmap mapping constraints to their index in the conss array */
174 int npricingprobsnotnull; /**< number of non-Null pricing problems*/
175 int npricingloopiters; /**< number of started pricing/stabilization loop iterations (resets before the loop starts) */
176
177 SCIP_VAR** pricedvars; /**< array of all priced variables */
178 int npricedvars; /**< number of priced variables */
179 int maxpricedvars; /**< maximal number of priced variables */
180
181 /* always points to the most recently added priced variable */
182 GCG_VARHISTORY* varhistory; /**< pointer to the history of priced variables */
183
184 SCIP_VAR** artificialvars; /**< array of artificial variables */
185 int nartificialvars; /**< number of artificial variables */
186 int maxartificialvars; /**< capacity of artificialvars */
187 SCIP_Bool artificialused; /**< returns if artificial variables are used in current node's LP solution */
188
189 SCIP_Real** realdualvalues; /**< real dual values for pricing variables */
190 int* nrealdualvalues; /**< capacities of realdualvalues */
191
192 SCIP_Real dualweight; /**< the weighting applied to the dual variables */
193 SCIP_Real* relaxweight; /**< the Lagrangian relaxation weight applied to master constraints, or NULL */
194 SCIP_Bool relaxobjective; /**< are relaxation weights applied to the pricing objective */
195
196 /* variables used for statistics */
197 SCIP_CLOCK* freeclock; /**< time for freeing pricing problems */
198 SCIP_CLOCK* transformclock; /**< time for transforming pricing problems */
199 SCIP_CLOCK* duplicatecolclock; /**< time for detecting duplicate columns when transferring original solutions */
200 int nduplicatecols; /**< number of master variables not created because an identical column existed */
201 int solvedsubmipsoptimal; /**< number of optimal pricing runs */
202 int solvedsubmipsheur; /**< number of heuristical pricing runs*/
203 int calls; /**< number of total pricing calls */
204 SCIP_Longint pricingiters; /**< sum of all pricing simplex iterations */
205
206 /* solver data */
207 GCG_SOLVER** solvers; /**< pricing solvers array */
208 int nsolvers; /**< number of pricing solvers */
209
210 /* event handler */
211 SCIP_EVENTHDLR* eventhdlr; /**< event handler */
212
213 /* pricing callbacks */
214 GCG_PRICINGCB** pricingcbs; /**< an array to store the pricing callback plugins */
215 int npricingcbs; /**< the number of available pricing callback plugins */
216
217 /* parameter values */
218 SCIP_VARTYPE vartype; /**< vartype of created master variables */
219 int nroundsredcost; /**< number of reduced cost rounds */
220 SCIP_Bool abortpricingint; /**< should the pricing be aborted on integral solutions? */
221 SCIP_Bool dispinfos; /**< should pricing information be displayed? */
222 int disablecutoff; /**< should the cutoffbound be applied in master LP solving (0: on, 1:off, 2:auto)? */
223 SCIP_Real abortpricinggap; /**< gap between dual bound and RMP objective at which pricing is aborted */
224 SCIP_Bool stabilization; /**< should stabilization be used */
225 SCIP_Bool stabilizationtree; /**< should stabilization be used in nodes other than the root node */
226 SCIP_Bool usecolpool; /**< should the colpool be checked for negative redcost cols before solving the pricing problems? */
227 SCIP_Bool preventduplicatecols; /**< should existing master variables be reused when transferring an original solution
228 * instead of creating duplicate columns? */
229 SCIP_Bool useartificialvars; /**< use artificial variables to make RMP feasible (instead of applying Farkas pricing) */
230 SCIP_Real maxobj; /**< maxobj bound that can be used for big M objective of artificial variables */
231 SCIP_Bool usemaxobj; /**< use maxobj for big M objective of artificial variables */
232 SCIP_Bool onlyreliablebigm; /**< only use maxobj for big M objective of artificial variables if it is reliable */
233 SCIP_Real factorunreliable; /**< factor to use for objective of unbounded variables */
234 SCIP_Real bigmartificial; /**< value for for big M objective of artificial variables (if maxobj is not used) */
235 SCIP_Bool hybridascent; /**< should hybridization of smoothing with an ascent method be enabled */
236 SCIP_Bool hybridascentnoagg; /**< should hybridization of smoothing with an ascent method be enabled
237 * if pricing problems cannot be aggregation */
238 int colpoolagelimit; /**< agelimit of columns in colpool */
239
240 /* price storage */
241 SCIP_Real redcostfac; /**< factor of -redcost/norm in score function */
242 SCIP_Real objparalfac; /**< factor of objective parallelism in score function */
243 SCIP_Real orthofac; /**< factor of orthogonalities in score function */
244 SCIP_Real mincolorth; /**< minimal orthogonality of columns to add
245 (with respect to columns added in the current round) */
246 SCIP_Real maxpricecols; /**< maximum number of columns per round */
247 SCIP_Real maxpricecolsfarkas; /**< maximum number of columns per Farkas round */
248 GCG_EFFICIACYCHOICE efficiacychoice; /**< choice to base efficiacy on */
249 int* nefficaciouscols; /**< number of found (efficacious) cols per pricing problem */
250
251 /* statistics */
252 int oldvars; /**< Vars of last pricing iteration */
253 int* farkascallsdist; /**< Calls of each farkas pricing problem */
254 int* farkasfoundvars; /**< Found vars of each farkas pricing problem */
255 double* farkasnodetimedist; /**< Time spend in each farkas pricing problem */
256
257 int* redcostcallsdist; /**< Calls of each redcost pricing problem */
258 int* redcostfoundvars; /**< Found vars of each redcost pricing problem */
259 double* redcostnodetimedist; /**< Time spend in each redcost pricing problem */
260 double rootnodedegeneracy; /**< degeneracy of the root node */
261 double avgrootnodedegeneracy; /**< average degeneray of all nodes */
262 int ndegeneracycalcs; /**< number of observations */
263
264 int* nactivepricingmods; /**< number of active pricing modifications per pricing problem */
265 int* nappliedpricingmods;/**< number of actually applied pricing modifications per pricing problem*/
266
267#ifdef _OPENMP
268 /* parallelization */
269 int maxnthreads; /**< maximal number of threads used to parallelize pricing */
270 GCG_LOCKS* locks; /**< OpenMP locks */
271#endif
272
273#ifdef SCIP_STATISTIC
274 int nrootbounds; /**< number of stored bounds */
275 SCIP_Real* rootpbs; /**< array of primal bounds for the root LP, one bound for each pricing call */
276 SCIP_Real* rootdbs; /**< array of dual bounds for the root LP, one bound for each pricing call */
277 SCIP_Real* roottimes; /**< array of times spent for root LP */
278 SCIP_Real* rootdualdiffs; /**< array of differences to last dual solution */
279 int maxrootbounds; /**< maximal number of bounds */
280 SCIP_Real rootfarkastime; /**< time of last Farkas call */
281 SCIP_Real dualdiff; /**< difference to last dual solution */
282 int dualdiffround; /**< value of nrootbounds when difference to last dual solution was computed */
283 SCIP_SOL* rootlpsol; /**< optimal root LP solution */
284 SCIP_Real*** dualvalues; /**< array of dual values for pricing variables for each root redcost call*/
285 SCIP_Real** dualsolconvs; /**< array of dual solutions for the convexity constraints for each root redcost call*/
286 int* nodetimehist; /**< Histogram of nodetime distribution */
287 int* foundvarshist; /**< Histogram of foundvars distribution */
288#endif
289};
290
292{
293 GCG* gcg; /**< GCG data structure */
294};
295
296/** key identifying the column represented by a master variable */
298{
299 SCIP_VAR* mastervar; /**< master variable represented by this key, or NULL for a lookup key */
300 SCIP_VAR** vars; /**< original variables with nonzero value, sorted by problem index */
301 SCIP_Real* vals; /**< values of the original variables */
302 int nvars; /**< number of original variables with nonzero value */
303 int block; /**< pricing problem the column belongs to */
304};
306
307
308/** gets the key of a master variable key (the key is the element itself) */
309static
310SCIP_DECL_HASHGETKEY(hashGetKeyMastervarkey)
311{ /*lint --e{715}*/
312 return elem;
313}
314
315/** returns whether two master variable keys describe the same column */
316static
317SCIP_DECL_HASHKEYEQ(hashKeyEqMastervarkey)
318{ /*lint --e{715}*/
319 GCG_MASTERVARKEY* mvkey1;
320 GCG_MASTERVARKEY* mvkey2;
321 int i;
322
323 mvkey1 = (GCG_MASTERVARKEY*)key1;
324 mvkey2 = (GCG_MASTERVARKEY*)key2;
325
326 if( mvkey1->block != mvkey2->block || mvkey1->nvars != mvkey2->nvars )
327 return FALSE;
328
329 for( i = 0; i < mvkey1->nvars; ++i )
330 {
331 if( mvkey1->vars[i] != mvkey2->vars[i] || !SCIPisEQ((SCIP*)userptr, mvkey1->vals[i], mvkey2->vals[i]) )
332 return FALSE;
333 }
334
335 return TRUE;
336}
337
338/** returns the hash value of a master variable key
339 *
340 * @note mirrors GCGhashKeyValCol; like that one it does not respect tolerances
341 */
342static
343SCIP_DECL_HASHKEYVAL(hashKeyValMastervarkey)
344{ /*lint --e{715}*/
345 GCG_MASTERVARKEY* mvkey;
346 int minindex;
347 int maxindex;
348
349 mvkey = (GCG_MASTERVARKEY*)key;
350 assert(mvkey != NULL);
351
352 if( mvkey->nvars > 0 )
353 {
354 minindex = SCIPvarGetIndex(mvkey->vars[0]);
355 maxindex = SCIPvarGetIndex(mvkey->vars[mvkey->nvars-1]);
356 }
357 else
358 {
359 minindex = INT_MAX;
360 maxindex = INT_MAX;
361 }
362
363 return SCIPhashSeven(mvkey->block, mvkey->nvars, 0,
364 SCIPrealHashCode(mvkey->nvars > 0 ? mvkey->vals[0] : 0.0), minindex,
365 SCIPrealHashCode(mvkey->nvars > 0 ? mvkey->vals[mvkey->nvars-1] : 0.0), maxindex);
366}
367
368/** fills a master variable key describing the column of the given master variable
369 *
370 * GCGcreateMasterVar stores either only nonzero entries, or - for a column without any nonzero entry - every
371 * pricing variable with value 0 (its `trivialsol` case).
372 *
373 * @return TRUE if the key describes the variable, FALSE if the variable mixes zero and nonzero entries and can
374 * therefore not be described without compaction.
375 */
376static
378 SCIP* masterprob, /**< master SCIP data structure */
379 SCIP_VAR* mastervar, /**< master variable to describe */
380 GCG_MASTERVARKEY* mvkey /**< key to fill */
381 )
382{
383 SCIP_VAR** origvars;
384 SCIP_Real* origvals;
385 int norigvars;
386 int nnonz;
387 int i;
388
390
394
395 nnonz = 0;
396 for( i = 0; i < norigvars; ++i )
397 {
398 if( !SCIPisZero(masterprob, origvals[i]) )
399 ++nnonz;
400 }
401
402 if( nnonz != 0 && nnonz != norigvars )
403 return FALSE;
404
405 mvkey->mastervar = mastervar;
407 mvkey->nvars = nnonz;
408 mvkey->vars = nnonz > 0 ? origvars : NULL;
409 mvkey->vals = nnonz > 0 ? origvals : NULL;
410
411 return TRUE;
412}
413
414/** information method for a parameter change of disablecutoff */
415static
416SCIP_DECL_PARAMCHGD(paramChgdDisablecutoff)
417{ /*lint --e{715}*/
419 int newval;
420
422 newval = SCIPparamGetInt(param);
423
424 SCIP_CALL( SCIPsetIntParam(masterprob, "lp/disablecutoff", newval) );
425
426 return SCIP_OKAY;
427}
428
429
430/*
431 * Callback methods of event handler
432 */
433
434/** destructor of event handler to free user data (called when SCIP is exiting) */
435static
436SCIP_DECL_EVENTFREE(eventFreeVardeleted)
437{
438 SCIP_EVENTHDLRDATA* eventhdlrdata;
439 assert(eventhdlr != NULL);
440
441 eventhdlrdata = SCIPeventhdlrGetData(eventhdlr);
442 assert(eventhdlrdata != NULL);
443 SCIPfreeBlockMemory(scip, &eventhdlrdata);
444 return SCIP_OKAY;
445}
446
447/** initialization method of event handler (called after problem was transformed) */
448#define eventInitVardeleted NULL
449
450/** deinitialization method of event handler (called before transformed problem is freed) */
451#define eventExitVardeleted NULL
452
453/** solving process initialization method of event handler (called when branch and bound process is about to begin) */
454#define eventInitsolVardeleted NULL
455
456/** solving process deinitialization method of event handler (called before branch and bound process data is freed) */
457#define eventExitsolVardeleted NULL
458
459/** frees specific event data */
460#define eventDeleteVardeleted NULL
461
462/** execution method of event handler */
463static
464SCIP_DECL_EVENTEXEC(eventExecVardeleted)
465{ /*lint --e{715}*/
466 SCIP_VAR* var;
467 ObjPricerGcg* pricer;
468 SCIP_PRICERDATA* pricerdata;
469 SCIP_VAR** origvars;
470 SCIP_EVENTHDLRDATA* eventhdlrdata;
471 int i;
472
473 eventhdlrdata = SCIPeventhdlrGetData(eventhdlr);
474 assert(eventhdlrdata != NULL);
475
476 pricer = GCGgetObjPricer(eventhdlrdata->gcg);
477 assert(pricer != NULL);
478
479 pricerdata = pricer->getPricerdata();
480 assert(pricerdata != NULL);
481
483 var = SCIPeventGetVar(event);
484 assert(var != NULL);
485
486 SCIPdebugMessage("remove master variable %s from pricerdata and corresponding original variables\n", SCIPvarGetName(var));
487
489 origvars = GCGmasterVarGetOrigvars(var);
490 assert(origvars != NULL);
491
492 /* remove master variable from corresponding pricing original variables */
493 for( i = 0; i < GCGmasterVarGetNOrigvars(var); ++i )
494 {
495 SCIP_CALL( GCGoriginalVarRemoveMasterVar(pricer->getGcg(), origvars[i], var) );
496 }
497
498 /* remove variable from array of stored priced variables */
500 assert(i < pricerdata->npricedvars);
501
502 if( i >= 0 )
503 {
504 assert(pricerdata->pricedvars[i] == var);
505
506 /* drop vardeleted event on variable */
507 SCIP_CALL(
508 SCIPdropVarEvent(scip, pricerdata->pricedvars[i], SCIP_EVENTTYPE_VARDELETED, pricerdata->eventhdlr, NULL, -1));
509
510 SCIP_CALL(SCIPreleaseVar(scip, &(pricerdata->pricedvars[i])));
511 (pricerdata->npricedvars)--;
512 assert(pricerdata->pricedvars[pricerdata->npricedvars] != NULL || i == pricerdata->npricedvars);
513 pricerdata->pricedvars[i] = pricerdata->pricedvars[pricerdata->npricedvars];
514 if( i < pricerdata->npricedvars )
515 GCGmasterVarSetIndex(pricerdata->pricedvars[i], i);
516 (pricerdata->oldvars)--;
517
518#ifndef NDEBUG
519 for ( ; i < pricerdata->npricedvars; ++i )
520 {
521 assert(pricerdata->pricedvars[i] != var);
522 }
523#endif
524 }
525
526 return SCIP_OKAY;
527}
528
529
530/*
531 * Local methods
532 */
533
534/** return TRUE or FALSE whether the master LP is solved to optimality */
535SCIP_Bool ObjPricerGcg::isMasterLPOptimal() const
536{
538
540}
541
542/** get the number of columns to be added to the master LP in the current pricing round */
544{
545 assert(pricingtype != NULL);
546
547 return pricingtype->getMaxcolsround();
548}
549
550/** get the number of columns per pricing problem to be added to the master LP in the current pricing round */
552{
553 assert(pricingtype != NULL);
554
555 return pricingtype->getMaxcolsprob();
556}
557
558/** ensures size of pricedvars array */
559SCIP_RETCODE ObjPricerGcg::ensureSizePricedvars(
560 int size /**< needed size */
561 )
562{
565
566 if( pricerdata->maxpricedvars < size )
567 {
568 int oldsize = pricerdata->maxpricedvars;
571 }
573
574 return SCIP_OKAY;
575}
576
577
578#ifdef SCIP_STATISTIC
579/** ensures size of root bounds arrays */
580SCIP_RETCODE ObjPricerGcg::ensureSizeRootBounds(
581 int size /**< needed size */
582 )
583{
584 assert(pricerdata != NULL);
585 assert(pricerdata->rootdbs != NULL);
586 assert(pricerdata->rootpbs != NULL);
587 assert(pricerdata->roottimes != NULL);
588 assert(pricerdata->rootdualdiffs != NULL);
589 assert(pricerdata->dualvalues != NULL);
590 assert(pricerdata->dualsolconvs != NULL);
591
592 if( pricerdata->maxrootbounds < size )
593 {
594 int oldsize = pricerdata->maxrootbounds;
595 pricerdata->maxrootbounds = SCIPcalcMemGrowSize(scip_, size);
596 SCIP_CALL( SCIPreallocBlockMemoryArray(scip_, &(pricerdata->rootpbs), oldsize, pricerdata->maxrootbounds) );
597 SCIP_CALL( SCIPreallocBlockMemoryArray(scip_, &(pricerdata->rootdbs), oldsize, pricerdata->maxrootbounds) );
598 SCIP_CALL( SCIPreallocBlockMemoryArray(scip_, &(pricerdata->roottimes), oldsize, pricerdata->maxrootbounds) );
599 SCIP_CALL( SCIPreallocBlockMemoryArray(scip_, &(pricerdata->rootdualdiffs), oldsize, pricerdata->maxrootbounds) );
600 SCIP_CALL( SCIPreallocBlockMemoryArray(scip_, &(pricerdata->dualvalues), oldsize, pricerdata->maxrootbounds) );
601 SCIP_CALL( SCIPreallocBlockMemoryArray(scip_, &(pricerdata->dualsolconvs), oldsize, pricerdata->maxrootbounds) );
602 }
603 assert(pricerdata->maxrootbounds >= size);
604
605 return SCIP_OKAY;
606}
607#endif
608
609#ifdef SCIP_STATISTIC
610/** gets the NodeTimeDistribution in the form of a histogram */
611static
612void GCGpricerGetNodeTimeHistogram(
613 SCIP_PRICERDATA* pricerdata, /**< pricerdata data structure */
614 SCIP_Real time /**< time the pricingproblem needed */
615 )
616{
617 int i;
618 assert(pricerdata != NULL);
619 /* 1000* because mapping milliseconds on the index i */
620 i = 1000*time/PRICER_STAT_BUCKETSIZE_TIME; /*lint !e524 */
621
623 {
625 }
626
628 assert(i >= 0);
629 pricerdata->nodetimehist[i]++;
630
631}
632
633
634/** gets the FoundVarsDistribution in form of a histogram */
635static
636void GCGpricerGetFoundVarsHistogram(
637 SCIP_PRICERDATA* pricerdata, /**< pricerdata data structure */
638 int foundvars /**< foundVars in pricingproblem */
639 )
640{
641 int i;
642 assert(pricerdata != NULL);
643 i = foundvars/PRICER_STAT_BUCKETSIZE_VARS;
645 {
647 }
648
650 assert(i >= 0);
651 pricerdata->foundvarshist[i]++;
652
653}
654
655
656/** gets the statistics of the pricingprobs like calls, foundvars and time */
657static
658void GCGpricerCollectStatistic(
659 SCIP_PRICERDATA* pricerdata, /**< pricerdata data structure */
660 GCG_PRICETYPE type, /**< type of pricing: optimal or heuristic */
661 int probindex, /**< index of the pricingproblem */
662 SCIP_Real time /**< time the pricingproblem needed */
663 )
664{
665 int foundvars;
666 assert(pricerdata != NULL);
667 foundvars = pricerdata->npricedvars - pricerdata->oldvars;
668
669 if( type == GCG_PRICETYPE_FARKAS )
670 {
671
672 pricerdata->farkascallsdist[probindex]++; /*Calls*/
673 pricerdata->farkasfoundvars[probindex] += foundvars;
674 pricerdata->farkasnodetimedist[probindex] += time; /*Time*/
675
676 }
677 else if( type == GCG_PRICETYPE_REDCOST )
678 {
679
680 pricerdata->redcostcallsdist[probindex]++;
681 pricerdata->redcostfoundvars[probindex] += foundvars;
682 pricerdata->redcostnodetimedist[probindex] += time;
683
684 }
685
686 GCGpricerGetNodeTimeHistogram(pricerdata, time);
687 GCGpricerGetFoundVarsHistogram(pricerdata, foundvars);
688
689 pricerdata->oldvars = pricerdata->npricedvars;
690}
691#endif
692
693/** frees all solvers */
694SCIP_RETCODE ObjPricerGcg::solversFree()
695{
696 int i;
697 assert(pricerdata != NULL);
698 assert((pricerdata->solvers == NULL) == (pricerdata->nsolvers == 0));
700
701 for( i = 0; i < pricerdata->nsolvers; i++ )
702 {
704 }
705
706 return SCIP_OKAY;
707}
708
709/** calls the init method on all solvers */
710SCIP_RETCODE ObjPricerGcg::solversInit()
711{
712 int i;
713 assert(pricerdata != NULL);
714 assert((pricerdata->solvers == NULL) == (pricerdata->nsolvers == 0));
716
717 for( i = 0; i < pricerdata->nsolvers; i++ )
718 {
720 }
721
722 return SCIP_OKAY;
723}
724
725/** calls the exit method on all solvers */
726SCIP_RETCODE ObjPricerGcg::solversExit()
727{
728 int i;
729 assert(pricerdata != NULL);
730 assert((pricerdata->solvers == NULL) == (pricerdata->nsolvers == 0));
732
733 for( i = 0; i < pricerdata->nsolvers; i++ )
734 {
736 }
737
738 return SCIP_OKAY;
739}
740
741/** calls the initsol method on all solvers */
742SCIP_RETCODE ObjPricerGcg::solversInitsol()
743{
744 int i;
745 assert(pricerdata != NULL);
746
747 if( pricerdata->npricingprobs == 0 )
748 return SCIP_OKAY;
749
750 assert((pricerdata->solvers == NULL) == (pricerdata->nsolvers == 0));
752
753 for( i = 0; i < pricerdata->nsolvers; i++ )
754 {
756 }
757
758 return SCIP_OKAY;
759}
760
761/** calls the exitsol method of all solvers */
762SCIP_RETCODE ObjPricerGcg::solversExitsol()
763{
764 int i;
765 assert(pricerdata != NULL);
766 assert((pricerdata->solvers == NULL) == (pricerdata->nsolvers == 0));
768
769 if( pricerdata->npricingprobs == 0 )
770 return SCIP_OKAY;
771
772 for( i = 0; i < pricerdata->nsolvers; i++ )
773 {
775 }
776
777 return SCIP_OKAY;
778}
779
780/** frees all pricing callback plugins */
781SCIP_RETCODE ObjPricerGcg::pricingcbsFree()
782{
783 int i;
784 assert(pricerdata != NULL);
785 assert((pricerdata->pricingcbs == NULL) == (pricerdata->npricingcbs == 0));
786
787 if( pricerdata->npricingcbs == 0 )
788 return SCIP_OKAY;
789
790 assert(pricerdata->pricingcbs != NULL);
791
792 for( i = 0; i < pricerdata->npricingcbs; i++ )
793 {
795 }
796
797 return SCIP_OKAY;
798}
799
800/** calls the init method on all pricing callback plugins */
801SCIP_RETCODE ObjPricerGcg::pricingcbsInit()
802{
803 int i;
804 assert(pricerdata != NULL);
805 assert((pricerdata->pricingcbs == NULL) == (pricerdata->npricingcbs == 0));
806
807 if( pricerdata->npricingcbs == 0 )
808 return SCIP_OKAY;
809
810 assert(pricerdata->pricingcbs != NULL);
811
812 for( i = 0; i < pricerdata->npricingcbs; i++ )
813 {
815 }
816
817 return SCIP_OKAY;
818}
819
820/** calls the exit method on all pricing callback plugins */
821SCIP_RETCODE ObjPricerGcg::pricingcbsExit()
822{
823 int i;
824 assert(pricerdata != NULL);
825 assert((pricerdata->pricingcbs == NULL) == (pricerdata->npricingcbs == 0));
826
827 if( pricerdata->npricingcbs == 0 )
828 return SCIP_OKAY;
829
830 assert(pricerdata->pricingcbs != NULL);
831
832 for( i = 0; i < pricerdata->npricingcbs; i++ )
833 {
835 }
836
837 return SCIP_OKAY;
838}
839
840/** calls the initsol method on all pricing callback plugins */
841SCIP_RETCODE ObjPricerGcg::pricingcbsInitsol()
842{
843 int i;
844 assert(pricerdata != NULL);
845
846 /* if there are no pricing problems, then the pricing callback methods are not required */
847 if( pricerdata->npricingprobs == 0 )
848 return SCIP_OKAY;
849
850 assert((pricerdata->pricingcbs == NULL) == (pricerdata->npricingcbs == 0));
851
852 if( pricerdata->npricingcbs == 0 )
853 return SCIP_OKAY;
854
855 assert(pricerdata->pricingcbs != NULL);
856
857 for( i = 0; i < pricerdata->npricingcbs; i++ )
858 {
860 }
861
862 return SCIP_OKAY;
863}
864
865/** calls the exitsol method of all pricing callback plugins */
866SCIP_RETCODE ObjPricerGcg::pricingcbsExitsol()
867{
868 int i;
869 assert(pricerdata != NULL);
870 assert((pricerdata->pricingcbs == NULL) == (pricerdata->npricingcbs == 0));
871
872 /* if there are no pricing problems, then the pricing callback methods are not required */
873 if( pricerdata->npricingcbs == 0 )
874 return SCIP_OKAY;
875
876 assert(pricerdata->pricingcbs != NULL);
877
878 if( pricerdata->npricingprobs == 0 )
879 return SCIP_OKAY;
880
881 for( i = 0; i < pricerdata->npricingcbs; i++ )
882 {
884 }
885
886 return SCIP_OKAY;
887}
888
889/** calls pre-pricing method of the pricing callback plugins */
890SCIP_RETCODE ObjPricerGcg::pricingcbsPrepricing(
891 SCIP_PRICER* pricer, /**< the pointer to the calling pricer */
892 GCG_PRICETYPE type, /**< the type of pricing, either redcost or farkas */
893 SCIP_Bool* abort /**< flag to set whether the pricing should be aborted */
894 )
895{
896 int i;
898
899 assert(pricer != NULL);
900 assert(pricerdata != NULL);
901 assert((pricerdata->pricingcbs == NULL) == (pricerdata->npricingcbs == 0));
902
903 assert(abort != NULL);
904
905 (*abort) = FALSE;
906
907 /* if there are no pricing problems, then the pricing callback methods are not required */
908 if( pricerdata->npricingcbs == 0 )
909 return SCIP_OKAY;
910
911 assert(pricerdata->pricingcbs != NULL);
912
913 for( i = 0; i < pricerdata->npricingcbs; i++ )
914 {
915 SCIP_Bool locabort = FALSE;
916
917 /* the pricing callback methods are only called if the plugin is enabled */
919 {
920 SCIP_CALL( GCGpricingcbPrepricing(gcg, pricerdata->pricingcbs[i], pricer, type, &locabort, &result) );
921
922 /* if one of the prepricing methods calls for an abort of the pricing, then pricing is aborted. */
923 (*abort) = (*abort) || locabort;
924
925 /* if the pricing callback plugin is to be executed exclusively, then no other callback plugins are executed.
926 * However, this only takes effect for the highest priority pricing callback plugin. For all pricing callback
927 * plugins that have the second highest and lower priority, the exclusive flag is ignored.
928 */
930 break;
931 }
932 }
933
934 return SCIP_OKAY;
935}
936
937/** calls post-pricing method of the pricing callback plugins */
938SCIP_RETCODE ObjPricerGcg::pricingcbsPostpricing(
939 SCIP_PRICER* pricer, /**< the pointer to the calling pricer */
940 GCG_PRICETYPE type /**< the type of pricing, either redcost or farkas */
941 )
942{
943 int i;
945
946 assert(pricer != NULL);
947 assert(pricerdata != NULL);
948 assert((pricerdata->pricingcbs == NULL) == (pricerdata->npricingcbs == 0));
949
950 /* if there are no pricing problems, then the pricing callback methods are not required */
951 if( pricerdata->npricingcbs == 0 )
952 return SCIP_OKAY;
953
954 assert(pricerdata->pricingcbs != NULL);
955
956 for( i = 0; i < pricerdata->npricingcbs; i++ )
957 {
958 /* the pricing callback methods are only called if the plugin is enabled */
960 {
962
963 /* if the pricing callback plugin is to be executed exclusively, then no other callback plugins are executed.
964 * However, this only takes effect for the highest priority pricing callback plugin. For all pricing callback
965 * plugins that have the second highest and lower priority, the exclusive flag is ignored.
966 */
968 break;
969 }
970 }
971
972 return SCIP_OKAY;
973}
974
975/** returns the gegeneracy of the masterproblem */
976SCIP_RETCODE ObjPricerGcg::computeCurrentDegeneracy(
977 double* degeneracy /**< pointer to store degeneracy */
978 )
979{
980 int nrows;
981 SCIP_COL** cols;
982 SCIP_ROW** rows;
983 int i;
984 int countz = 0;
985 int* indizes = NULL;
986
987 assert(degeneracy != NULL);
988
989 nrows = SCIPgetNLPRows(scip_);
990
991 if( nrows > 0 ) {
992 cols = SCIPgetLPCols(scip_);
993 rows = SCIPgetLPRows(scip_);
994
995 SCIP_CALL(SCIPallocBufferArray(scip_, &indizes, (size_t) nrows));
996
997 /* gives indices of Columns in Basis and indices of vars in Basis */
999
1000 for (i = 0; i < nrows; i++) {
1001 SCIP_Real currentVal;
1002 int colindex = indizes[i];
1003
1004 /* is column if >= 0 it is column in basis, < 0 is for row */
1005 if (colindex >= 0) {
1006 SCIP_COL *col;
1007 col = cols[colindex];
1008 currentVal = SCIPcolGetPrimsol(col);
1009
1010 if (SCIPisEQ(scip_, currentVal, SCIPcolGetLb(col)) || SCIPisEQ(scip_, currentVal, SCIPcolGetUb(col)))
1011 countz++;
1012 } else {
1013 SCIP_ROW *row = rows[-indizes[i] - 1];
1014
1015 currentVal = SCIPgetRowActivity(scip_, row);
1016
1017 if (SCIPisEQ(scip_, currentVal, SCIProwGetRhs(row)) || SCIPisEQ(scip_, currentVal, SCIProwGetLhs(row)))
1018 countz++;
1019 }
1020 }
1021 SCIPfreeBufferArray(scip_, &indizes);
1022
1023 /* Degeneracy in % */
1024 *degeneracy = ((double) countz / nrows);
1025 } else {
1026 *degeneracy = 0.0;
1027 }
1028
1029 assert(*degeneracy <= 1.0 && *degeneracy >= 0);
1030
1031 return SCIP_OKAY;
1032}
1033
1034/** set subproblem memory limit */
1035SCIP_RETCODE ObjPricerGcg::setPricingProblemMemorylimit(
1036 SCIP* pricingscip /**< SCIP of the pricingproblem */
1037 )
1038{
1039 SCIP_Real memlimit;
1040
1041 assert(pricingscip != NULL);
1042
1044
1045 SCIP_CALL( SCIPgetRealParam(origprob, "limits/memory", &memlimit) );
1046
1047 if( memlimit < SCIP_MEM_NOLIMIT )
1048 {
1049 GCG_SET_LOCK(&pricerdata->locks->pricinglimitslock);
1050 memlimit -= SCIPgetMemUsed(origprob)/1048576.0 + GCGgetPricingprobsMemUsed(gcg);
1051 GCG_UNSET_LOCK(&pricerdata->locks->pricinglimitslock);
1052
1053 memlimit -= SCIPgetMemUsed(pricingscip)/1048576.0;
1054 if( memlimit < 0 )
1055 memlimit = 0.0;
1056 SCIP_CALL( SCIPsetRealParam(pricingscip, "limits/memory", memlimit) );
1057 }
1058
1059 return SCIP_OKAY;
1060}
1061
1062
1063/** for a pricing problem, get the dual solution value or Farkas value of the convexity constraint */
1065 PricingType* pricetype, /**< Farkas or Reduced cost pricing */
1066 int probnr /**< index of corresponding pricing problem */
1067 )
1068{
1069 if( !GCGisPricingprobRelevant(gcg, probnr) )
1070 return -1.0 * SCIPinfinity(scip_);
1071 else
1072 return pricetype->consGetDual(GCGgetConvCons(gcg, probnr));
1073}
1074
1075/** computes the pricing problem objectives
1076 * @todo this method could use more parameters as it is private
1077 */
1079 PricingType* pricetype, /**< Farkas or Reduced cost pricing */
1080 SCIP_Bool stabilize /**< do we use stabilization ? */
1081 )
1082{
1083 SCIP_CONS** origconss = NULL;
1084 SCIP_CONS** masterconss = NULL;
1085 int nmasterconss;
1086 SCIP_VAR** probvars = NULL;
1087 int nprobvars;
1088 SCIP_Real** objs = NULL;
1089
1090 SCIP_ROW** originalsepamastercuts = NULL;
1091 int noriginalsepamastercuts;
1092 SCIP_ROW** originalsepaorigcuts = NULL;
1093 SCIP_COL** cols = NULL;
1094 SCIP_Real* consvals = NULL;
1095 SCIP_Real dualsol;
1096 SCIP_Real realdualsol;
1097 SCIP_Real dualweight;
1098 SCIP_Real* relaxweight;
1099
1100 SCIP_VAR** consvars = NULL;
1101 int nconsvars;
1102 int i;
1103 int j;
1104 int priceridx;
1105
1106 GCG_EXTENDEDMASTERCONSDATA** branchextendedmasterconsdata = NULL;
1107 int nbranchextendedmasterconsdata = 0;
1108
1110 assert(stabilization != NULL);
1111
1112 /* get the constraints of the master problem and the corresponding constraints in the original problem */
1113 nmasterconss = GCGgetNMasterConss(gcg);
1114 masterconss = GCGgetMasterConss(gcg);
1115 origconss = GCGgetOrigMasterConss(gcg);
1116
1117 /* the dual weight and the relaxation weight may be set when performing pricing with a Lagrangian relaxation
1118 * objective
1119 */
1120 dualweight = pricerdata->dualweight;
1121 relaxweight = pricerdata->relaxweight;
1122
1124
1125 /* set objective value of all variables in the pricing problems to 0 (for farkas pricing) /
1126 * to the original objective of the variable (for redcost pricing)
1127 */
1128 for( i = 0; i < pricerdata->npricingprobs; i++ )
1129 {
1130 if( pricerdata->pricingprobs[i] == NULL )
1131 continue;
1134
1136
1137 for( j = 0; j < nprobvars; j++ )
1138 {
1139 assert(GCGvarGetBlock(probvars[j]) == i);
1140
1141 if( GCGvarIsInferredPricing(probvars[j]) )
1142 continue;
1143
1145
1146 priceridx = SCIPvarGetIndex(probvars[j]);
1147 objs[i][priceridx] = pricetype->varGetObj(probvars[j]);
1148
1149 assert(priceridx >= 0 && priceridx < pricerdata->nrealdualvalues[i]);
1150 pricerdata->realdualvalues[i][priceridx] = objs[i][priceridx];
1151#ifdef PRINTDUALSOLS
1152 if( !SCIPisZero(scip_, pricerdata->realdualvalues[i][priceridx]) )
1153 {
1154 SCIPdebugMessage("pricingobj var <%s> %g (-> realdualvalues)\n", SCIPvarGetName(probvars[j]),
1155 pricerdata->realdualvalues[i][priceridx]);
1156 }
1157#endif
1158 }
1159 }
1160
1161 /* compute reduced cost for linking variable constraints and update objectives in the pricing problems
1162 * go through constraints, and select correct variable
1163 */
1164
1165 int nlinkconss;
1166 SCIP_CONS** linkconss = NULL;
1167 int* linkconssblock = NULL;
1168 nlinkconss = GCGgetNVarLinkingconss(gcg);
1169 linkconss = GCGgetVarLinkingconss(gcg);
1170 linkconssblock = GCGgetVarLinkingconssBlock(gcg);
1171
1172 for( i = 0; i < nlinkconss; ++i)
1173 {
1174 SCIP_VAR** linkconsvars = NULL;
1175 SCIP_CONS* linkcons = linkconss[i];
1176 int block = linkconssblock[i];
1177
1178 linkconsvars = SCIPgetVarsLinear(scip_, linkcons);
1179
1180 SCIP_VAR* linkvar = linkconsvars[0];
1181
1182 SCIP_VAR* pricingvar = GCGlinkingVarGetPricingVars(GCGmasterVarGetOrigvars(linkvar)[0])[block];
1183 assert(GCGvarIsPricing(pricingvar));
1184 if( stabilize )
1185 {
1186 dualsol = stabilization->linkingconsGetDual(i);
1187 }
1188 else
1189 {
1190 dualsol = pricetype->consGetDual(linkcons);
1191 }
1192
1193 /* add dual solution value to the pricing variable:
1194 * lambda variables get coef -1 in linking constraints --> add dualsol
1195 */
1196 priceridx = SCIPvarGetIndex(pricingvar);
1197 assert(priceridx >= 0 && priceridx < pricerdata->nrealdualvalues[block]);
1198 objs[block][priceridx] += dualweight * dualsol;
1199 pricerdata->realdualvalues[block][priceridx] += pricetype->consGetDual(linkcons);
1200
1201#ifdef PRINTDUALSOLS
1202 if( !SCIPisZero(scip_, pricetype->consGetDual(linkcons)) || !SCIPisZero(scip_, dualsol) )
1203 {
1204 SCIPdebugMessage("pricingobj var <%s> %g (cons <%s>), realdualvalues + %g -> %g\n", SCIPvarGetName(pricingvar),
1205 dualsol, SCIPconsGetName(linkcons), pricetype->consGetDual(linkcons),
1206 pricerdata->realdualvalues[block][priceridx]);
1207 }
1208#endif
1209 }
1210
1211 /* compute reduced cost and update objectives in the pricing problems */
1212 for( i = 0; i < nmasterconss; i++ )
1213 {
1214 realdualsol = pricetype->consGetDual(masterconss[i]);
1215 if( stabilize )
1216 {
1217 SCIP_CALL( stabilization->consGetDual(i, &dualsol) );
1218 }
1219 else
1220 {
1221 dualsol = realdualsol;
1222 }
1223
1224#ifdef PRINTDUALSOLS
1225 if ( !SCIPisZero(scip_, dualsol) )
1226 {
1227 SCIPdebugMessage("mastercons <%s> dualsol: %g\n", SCIPconsGetName(masterconss[i]), dualsol);
1228 }
1229#endif
1230
1231 /* for all variables in the constraint, modify the objective of the corresponding variable in a pricing problem */
1232 nconsvars = GCGconsGetNVars(origprob, origconss[i]);
1233 SCIP_CALL( SCIPallocBufferArray(scip_, &consvars, nconsvars) );
1234 SCIP_CALL( SCIPallocBufferArray(scip_, &consvals, nconsvars) );
1235 GCGconsGetVars(origprob, origconss[i], consvars, nconsvars);
1236 GCGconsGetVals(origprob, origconss[i], consvals, nconsvars);
1237 for( j = 0; j < nconsvars; j++ )
1238 {
1239 int blocknr;
1240 blocknr = GCGvarGetBlock(consvars[j]);
1241 assert(GCGvarIsOriginal(consvars[j]));
1242 /* nothing to be done if variable belongs to redundant block or variable was directly transferred to the master
1243 * or variable is linking variable (which means, the directly transferred copy is part of the master cons)
1244 */
1245 if( blocknr >= 0 && pricerdata->pricingprobs[blocknr] != NULL )
1246 {
1247 SCIP_VAR* pricingvar = GCGoriginalVarGetPricingVar(consvars[j]);
1248 assert(pricingvar != NULL);
1249 priceridx = SCIPvarGetIndex(pricingvar);
1250
1251 /* modify the objective of the corresponding variable in the pricing problem */
1252 objs[blocknr][priceridx] -= dualweight * dualsol * consvals[j];
1253
1254 assert(priceridx >= 0 && priceridx < pricerdata->nrealdualvalues[blocknr]);
1255 pricerdata->realdualvalues[blocknr][priceridx] -= consvals[j] * realdualsol;
1256
1257 /* adding a weight for the Lagrangian relaxation of the master constraints */
1258 if( !SCIPisEQ(scip_, relaxweight[i], 0.0) )
1259 {
1260 objs[blocknr][priceridx] += relaxweight[i] * consvals[j];
1261 }
1262
1263#ifdef PRINTDUALSOLS
1264 if( !SCIPisZero(scip_, dualsol) || !SCIPisZero(scip_, consvals[j] * realdualsol) )
1265 {
1266 SCIPdebugMessage("pricingobj var <%s> %g, realdualvalues + %g -> %g\n",
1267 SCIPvarGetName(pricingvar), dualsol,
1268 -1.0 * consvals[j] * realdualsol,
1269 pricerdata->realdualvalues[blocknr][priceridx]);
1270 }
1271#endif
1272 }
1273 }
1274 SCIPfreeBufferArray(scip_, &consvals);
1275 SCIPfreeBufferArray(scip_, &consvars);
1276 }
1277
1278 /* get the cuts of the master problem and the corresponding cuts in the original problem */
1279 originalsepamastercuts = GCGsepaGetOriginalSepaMastercuts(gcg);
1280 noriginalsepamastercuts = GCGsepaGetNOriginalSepaCuts(gcg);
1281 originalsepaorigcuts = GCGsepaGetOriginalSepaOrigcuts(gcg);
1282
1283 assert(originalsepamastercuts != NULL);
1284 assert(originalsepaorigcuts != NULL);
1285
1286 /* compute reduced cost and update objectives in the pricing problems */
1287 for( i = 0; i < noriginalsepamastercuts; i++ )
1288 {
1289 realdualsol = pricetype->rowGetDual(originalsepamastercuts[i]);
1290 if( stabilize )
1291 {
1292 SCIP_CALL( stabilization->rowGetDual(i, &dualsol) );
1293 }
1294 else
1295 {
1296 dualsol = realdualsol;
1297 }
1298
1299#ifdef PRINTDUALSOLS
1300 if ( !SCIPisZero(scip_, dualsol) )
1301 {
1302 SCIPdebugMessage("mastercut <%s> dualsol: %g\n", SCIProwGetName(originalsepamastercuts[i]), dualsol);
1303 }
1304#endif
1305
1306 /* get columns and vals of the cut */
1307 nconsvars = SCIProwGetNNonz(originalsepaorigcuts[i]);
1308 cols = SCIProwGetCols(originalsepaorigcuts[i]);
1309 consvals = SCIProwGetVals(originalsepaorigcuts[i]);
1310
1311 /* get the variables corresponding to the columns in the cut */
1312 SCIP_CALL( SCIPallocBufferArray(scip_, &consvars, nconsvars) );
1313 for( j = 0; j < nconsvars; j++ )
1314 consvars[j] = SCIPcolGetVar(cols[j]);
1315
1316 /* for all variables in the cut, modify the objective of the corresponding variable in a pricing problem */
1317 for( j = 0; j < nconsvars; j++ )
1318 {
1319 int blocknr;
1320 blocknr = GCGvarGetBlock(consvars[j]);
1321 assert(GCGvarIsOriginal(consvars[j]));
1322 /* nothing to be done if variable belongs to redundant block or
1323 * variable was directly transferred to the master
1324 * or variable is linking variable (which means, the directly transferred copy is part of the master cut) */
1325 if( blocknr >= 0 && pricerdata->pricingprobs[blocknr] != NULL )
1326 {
1327 SCIP_VAR* pricingvar = GCGoriginalVarGetPricingVar(consvars[j]);
1328 assert(pricingvar != NULL);
1329 priceridx = SCIPvarGetIndex(pricingvar);
1330
1331 /* modify the objective of the corresponding variable in the pricing problem */
1332 objs[blocknr][priceridx] -= dualweight * dualsol * consvals[j];
1333
1334 assert(priceridx >= 0 && priceridx < pricerdata->nrealdualvalues[blocknr]);
1335 pricerdata->realdualvalues[blocknr][priceridx]-= consvals[j] * realdualsol;
1336
1337#ifdef PRINTDUALSOLS
1338 if( !SCIPisZero(scip_, dualsol) || !SCIPisZero(scip_, consvals[j] * realdualsol) )
1339 {
1340 SCIPdebugMessage("pricingobj var <%s> %g, realdualvalues + %g -> %g\n",
1341 SCIPvarGetName(pricingvar),
1342 dualsol, -1.0 * consvals[j] * realdualsol, pricerdata->realdualvalues[blocknr][priceridx]);
1343 }
1344#endif
1345 }
1346 }
1347 SCIPfreeBufferArray(scip_, &consvars);
1348 }
1349
1350 SCIP_CALL( GCGrelaxBranchGetAllActiveExtendedMasterConss(gcg, NULL, NULL, &branchextendedmasterconsdata, &nbranchextendedmasterconsdata) );
1351 assert(nbranchextendedmasterconsdata == 0 || branchextendedmasterconsdata != NULL);
1352
1353 /* extended master conss: determine dual values and call update function */
1354 for( i = 0; i < nbranchextendedmasterconsdata; i++ )
1355 {
1356 if( stabilize )
1357 {
1358 dualsol = stabilization->branchmasterconsGetDual(i);
1359 }
1360 else
1361 {
1362 dualsol = pricetype->extendedmasterconsGetDual(branchextendedmasterconsdata[i]);
1363 }
1364
1365#ifdef PRINTDUALSOLS
1366 if ( !SCIPisZero(scip_, dualsol) )
1367 {
1368 SCIPdebugMessage("extendedmasterconsdata <%s> dualsol: %g\n", GCGextendedmasterconsGetName(branchextendedmasterconsdata[i]), dualsol);
1369 }
1370#endif
1371
1372 SCIP_CALL( GCGextendedmasterconsUpdateDualValue(gcg, branchextendedmasterconsdata[i], dualweight * dualsol) );
1373 }
1374
1375 /* master cuts generated by separators */
1376 GCG_EXTENDEDMASTERCONSDATA** activecuts;
1377 int nactivecuts;
1378
1379 activecuts = GCGgetActiveMastersepacuts(gcg);
1380 nactivecuts = GCGgetNActiveMastersepacuts(gcg);
1381
1382 for( i = 0; i < nactivecuts; i++ )
1383 {
1384 /* inactive cuts have no effect on the pricing problems */
1385 assert( GCGextendedmasterconsIsActive(activecuts[i]) );
1386 if( stabilize )
1387 {
1388 /* @todo: implement stabilization for mastercuts?*/
1389 dualsol = pricetype->extendedmasterconsGetDual(activecuts[i]);
1390 }
1391 else
1392 {
1393 dualsol = pricetype->extendedmasterconsGetDual(activecuts[i]);
1394 }
1395
1396#ifdef PRINTDUALSOLS
1397 if ( !SCIPisZero(scip_, dualsol) )
1398 {
1399 SCIPdebugMessage("extendedmasterconsdata <%s> dualsol: %g\n", GCGextendedmasterconsGetName(activecuts[i]), dualsol);
1400 }
1401#endif
1402
1403 /* modify the objective of pricing problems affected by this master separator cut */
1404 SCIP_CALL( GCGextendedmasterconsUpdateDualValue(gcg, activecuts[i], dualweight * dualsol) );
1405 }
1406
1407 /* get dual solutions / farkas values of the convexity constraints */
1408 for( i = 0; i < pricerdata->npricingprobs; i++ )
1409 {
1411
1412 if( pricerdata->pricingprobs[i] == NULL )
1413 {
1415 continue;
1416 }
1417
1418 pricerdata->dualsolconv[i] = dualweight * pricetype->consGetDual(GCGgetConvCons(gcg, i));
1419
1420#ifdef PRINTDUALSOLS
1422 {
1423 SCIPdebugMessage("convcons <%s> dualsol: %g\n", SCIPconsGetName(GCGgetConvCons(gcg, i)), pricerdata->dualsolconv[i]);
1424 }
1425#endif
1426 }
1427
1428 for( i = pricerdata->npricingprobs-1; i >= 0; --i )
1429 {
1430 if( pricerdata->pricingprobs[i] == NULL )
1431 continue;
1434
1435 for( j = 0; j < nprobvars; j++ )
1436 {
1437 assert(GCGvarGetBlock(probvars[j]) == i);
1438
1439 if( GCGvarIsInferredPricing(probvars[j]) )
1440 continue;
1441
1442 priceridx = SCIPvarGetIndex(probvars[j]);
1443 SCIP_CALL( SCIPchgVarObj(pricerdata->pricingprobs[i], probvars[j], objs[i][priceridx]) );
1444 }
1445
1446 SCIPfreeBufferArray(scip_, &objs[i]);
1447 }
1448 SCIPfreeBufferArray(scip_, &objs);
1449
1450 return SCIP_OKAY;
1451}
1452
1453/** add master variable to all constraints */
1454SCIP_RETCODE ObjPricerGcg::addVariableToMasterconstraints(
1455 SCIP_VAR* newvar, /**< The new variable to add */
1456 int prob, /**< number of the pricing problem the solution belongs to */
1457 SCIP_VAR** solvars, /**< array of variables with non-zero value in the solution of the pricing problem */
1458 SCIP_Real* solvals, /**< array of values in the solution of the pricing problem for variables in array solvars*/
1459 int nsolvars /**< number of variables in array solvars */
1460 )
1461{
1462 int i;
1463 int c;
1464 int idx;
1465
1466 SCIP_CONS** masterconss = NULL;
1467 int nmasterconss;
1468 SCIP_Real* mastercoefs = NULL;
1469 SCIP_CONS* linkcons = NULL;
1470
1472
1473 nmasterconss = GCGgetNMasterConss(gcg);
1474 masterconss = GCGgetMasterConss(gcg);
1475
1476 SCIP_CALL( SCIPallocBufferArray(scip_, &mastercoefs, nmasterconss) ); /*lint !e530*/
1477 BMSclearMemoryArray(mastercoefs, nmasterconss);
1478
1479 /* compute coef of the variable in the master constraints */
1480 for( i = 0; i < nsolvars; i++ )
1481 {
1482 if( !SCIPisZero(scip_, solvals[i]) )
1483 {
1484 SCIP_CONS** linkconss;
1485 SCIP_VAR** origvars;
1486 SCIP_Real* coefs;
1487 int ncoefs;
1488
1489 if( GCGvarIsInferredPricing(solvars[i]) )
1490 continue;
1491
1492 assert(GCGvarIsPricing(solvars[i]));
1493 origvars = GCGpricingVarGetOrigvars(solvars[i]);
1494 assert(GCGvarIsOriginal(origvars[0]));
1495
1496 coefs = GCGoriginalVarGetCoefs(origvars[0]);
1497 ncoefs = GCGoriginalVarGetNCoefs(origvars[0]);
1498 assert(!SCIPisInfinity(scip_, solvals[i]));
1499
1500 /* original variable is a linking variable, just add it to the linkcons */
1501 if( GCGoriginalVarIsLinking(origvars[0]) )
1502 {
1503#ifndef NDEBUG
1504 SCIP_VAR** pricingvars;
1505 pricingvars = GCGlinkingVarGetPricingVars(origvars[0]);
1506#endif
1507 linkconss = GCGlinkingVarGetLinkingConss(origvars[0]);
1508
1509 /* the linking constraints could be NULL if the Benders' decomposition is used. */
1510 if( linkconss != NULL )
1511 {
1512 assert(pricingvars[prob] == solvars[i]);
1513 assert(linkconss[prob] != NULL);
1514 SCIP_CALL( SCIPaddCoefLinear(scip_, linkconss[prob], newvar, -solvals[i]) );
1515 }
1516 continue;
1517 }
1518
1519 /* for each coef, add coef * solval to the coef of the new variable for the corresponding constraint */
1520 for( c = 0; c < ncoefs; c++ )
1521 {
1522 linkconss = GCGoriginalVarGetMasterconss(origvars[0]);
1523 assert(!SCIPisZero(scip_, coefs[c]));
1524 SCIP_CALL( SCIPgetTransformedCons(scip_, linkconss[c], &linkcons) );
1525
1526 idx = (int)(size_t)SCIPhashmapGetImage(pricerdata->mapcons2idx, linkcons); /*lint !e507*/
1527 assert(0 <= idx && idx < nmasterconss);
1528 assert(masterconss[idx] == linkcons);
1529 mastercoefs[idx] += coefs[c] * solvals[i];
1530 }
1531
1532 }
1533 }
1534
1535 /* add the variable to the master constraints */
1536 for( i = 0; i < nmasterconss; i++ )
1537 {
1538 if( !SCIPisZero(scip_, mastercoefs[i]) )
1539 {
1540 assert(!SCIPisInfinity(scip_, mastercoefs[i]) && !SCIPisInfinity(scip_, -mastercoefs[i]));
1541 SCIP_CALL( SCIPaddCoefLinear(scip_, masterconss[i], newvar, mastercoefs[i]) );
1542 }
1543 }
1544
1545 SCIPfreeBufferArray(scip_, &mastercoefs);
1546 return SCIP_OKAY;
1547}
1548
1549/** add master variable to all constraints */
1550SCIP_RETCODE ObjPricerGcg::addVariableToMasterconstraintsFromGCGCol(
1551 SCIP_VAR* newvar, /**< The new variable to add */
1552 GCG_COL* gcgcol /**< GCG column data structure */
1553 )
1554{
1555 SCIP_CONS** masterconss;
1556 int nmasterconss;
1557 SCIP_Real* mastercoefs;
1558 int nlinkvars;
1559 int* linkvars;
1560
1561 SCIP_VAR** solvars; /* array of variables with non-zero value in the solution of the pricing problem */
1562 SCIP_Real* solvals; /* array of values in the solution of the pricing problem for variables in array solvars*/
1563#ifndef NDEBUG
1564 int nsolvars; /* number of variables in array solvars */
1565#endif
1566
1567 int i;
1568 int prob;
1569
1570 assert(pricerdata != NULL);
1571
1572 nmasterconss = GCGgetNMasterConss(gcg);
1573 masterconss = GCGgetMasterConss(gcg);
1574
1576
1577 mastercoefs = GCGcolGetMastercoefs(gcgcol);
1578
1579 nlinkvars = GCGcolGetNLinkvars(gcgcol);
1580 linkvars = GCGcolGetLinkvars(gcgcol);
1581 solvars = GCGcolGetVars(gcgcol);
1582 solvals = GCGcolGetVals(gcgcol);
1583#ifndef NDEBUG
1584 nsolvars = GCGcolGetNVars(gcgcol);
1585#endif
1586
1587 prob = GCGcolGetProbNr(gcgcol);
1588
1589 /* compute coef of the variable in the master constraints */
1590 for( i = 0; i < nlinkvars; i++ )
1591 {
1592 SCIP_CONS** linkconss;
1593 SCIP_VAR** origvars;
1594
1595 assert(linkvars[i] < nsolvars );
1596 assert(GCGvarIsPricing(solvars[linkvars[i]]));
1597 origvars = GCGpricingVarGetOrigvars(solvars[linkvars[i]]);
1598 assert(GCGvarIsOriginal(origvars[0]));
1599
1600 assert(!SCIPisInfinity(scip_, solvals[linkvars[i]]));
1601
1602 assert(GCGoriginalVarIsLinking(origvars[0]));
1603 /* original variable is a linking variable, just add it to the linkcons */
1604#ifndef NDEBUG
1605 SCIP_VAR** pricingvars;
1606 pricingvars = GCGlinkingVarGetPricingVars(origvars[0]);
1607#endif
1608 linkconss = GCGlinkingVarGetLinkingConss(origvars[0]);
1609
1610 assert(pricingvars[prob] == solvars[linkvars[i]]);
1611 assert(linkconss[prob] != NULL);
1612 SCIP_CALL( SCIPaddCoefLinear(scip_, linkconss[prob], newvar, -solvals[linkvars[i]]) );
1613 }
1614
1615 /* add the variable to the master constraints */
1616 for( i = 0; i < nmasterconss; i++ )
1617 {
1618 if( !SCIPisZero(scip_, mastercoefs[i]) )
1619 {
1620 assert(!SCIPisInfinity(scip_, mastercoefs[i]) && !SCIPisInfinity(scip_, -mastercoefs[i]));
1621 SCIP_CALL( SCIPaddCoefLinear(scip_, masterconss[i], newvar, mastercoefs[i]) );
1622 }
1623 }
1624
1625 return SCIP_OKAY;
1626}
1627
1628
1629/** compute master coefficients of column */
1631 GCG_COL* gcgcol /**< GCG column data structure */
1632 )
1633{
1634 int i;
1635
1636 SCIP_VAR** solvars = NULL;
1637 SCIP_Real* solvals = NULL;
1638 int nsolvars;
1639
1640 int c;
1641 int idx;
1642
1643 assert(scip_ != NULL);
1644 assert(gcgcol != NULL);
1645
1646 nsolvars = GCGcolGetNVars(gcgcol);
1647 solvars = GCGcolGetVars(gcgcol);
1648 solvals = GCGcolGetVals(gcgcol);
1649
1650 int nmasterconss;
1651 SCIP_Real* mastercoefs = NULL;
1652 SCIP_CONS* linkcons = NULL;
1653 SCIP* pricingprob = NULL;
1654
1655 int* linkvars = NULL;
1656 int nlinkvars;
1657
1658 pricingprob = GCGcolGetPricingProb(gcgcol);
1659
1660 nmasterconss = GCGgetNMasterConss(gcg);
1661
1662 assert(GCGcolGetNMastercoefs(gcgcol) == 0 || GCGcolGetNMastercoefs(gcgcol) == nmasterconss);
1663
1664 if( GCGcolGetInitializedCoefs(gcgcol) )
1665 {
1666// SCIPdebugMessage("Coefficients already computed, nmastercoefs = %d\n", GCGcolGetNMastercoefs(gcgcol));
1667 return SCIP_OKAY;
1668 }
1669
1670 if( nmasterconss > 0)
1671 {
1672 SCIP_CALL( SCIPallocBufferArray(pricingprob, &mastercoefs, nmasterconss) ); /*lint !e530*/
1673 BMSclearMemoryArray(mastercoefs, nmasterconss);
1674 }
1675
1676 SCIP_CALL( SCIPallocBufferArray(pricingprob, &linkvars, nsolvars) ); /*lint !e530*/
1677
1678 nlinkvars = 0;
1679
1680 /* compute coef of the variable in the master constraints */
1681 for( i = 0; i < nsolvars; i++ )
1682 {
1683 if( !SCIPisZero(origprob, solvals[i]) )
1684 {
1685 SCIP_CONS** linkconss;
1686 SCIP_VAR** origvars;
1687 SCIP_Real* coefs;
1688 int ncoefs;
1689
1690 assert(GCGvarIsPricing(solvars[i]));
1691 origvars = GCGpricingVarGetOrigvars(solvars[i]);
1692 assert(GCGvarIsOriginal(origvars[0]));
1693
1694 coefs = GCGoriginalVarGetCoefs(origvars[0]);
1695 ncoefs = GCGoriginalVarGetNCoefs(origvars[0]);
1696 assert(!SCIPisInfinity(origprob, solvals[i]));
1697
1698 /* original variable is a linking variable, just add it to the linkcons */
1699 if( GCGoriginalVarIsLinking(origvars[0]) )
1700 {
1701 linkvars[nlinkvars] = i;
1702 ++nlinkvars;
1703
1704 continue;
1705 }
1706
1707 /* for each coef, add coef * solval to the coef of the new variable for the corresponding constraint */
1708 for( c = 0; c < ncoefs; c++ )
1709 {
1710 linkconss = GCGoriginalVarGetMasterconss(origvars[0]);
1711 assert(!SCIPisZero(origprob, coefs[c]));
1712 SCIP_CALL( SCIPgetTransformedCons(scip_, linkconss[c], &linkcons) );
1713
1714 idx = (int)(size_t)SCIPhashmapGetImage(pricerdata->mapcons2idx, linkcons); /*lint !e507*/
1715 assert(0 <= idx && idx < nmasterconss);
1716 assert(!SCIPisInfinity(scip_, ABS(coefs[c] * solvals[i])));
1717 mastercoefs[idx] += coefs[c] * solvals[i];
1718 assert(!SCIPisInfinity(scip_, ABS(mastercoefs[idx])));
1719 }
1720 }
1721 }
1722
1723 SCIP_CALL( GCGcolSetMastercoefs(gcgcol, mastercoefs, nmasterconss) );
1724
1725 SCIP_CALL( GCGcolSetLinkvars(gcgcol, linkvars, nlinkvars) );
1726
1728
1729 SCIPfreeBufferArray(pricingprob, &linkvars); /*lint !e530*/
1730
1731 if( nmasterconss > 0)
1732 SCIPfreeBufferArray(pricingprob, &mastercoefs); /*lint !e530*/
1733
1734 return SCIP_OKAY;
1735}
1736
1737/** add variable with computed coefficients to the original separator cuts */
1738SCIP_RETCODE ObjPricerGcg::addVariableToOriginalSepaCuts(
1739 SCIP_VAR* newvar, /**< The new variable to add */
1740 int prob, /**< number of the pricing problem the solution belongs to */
1741 SCIP_VAR** solvars, /**< array of variables with non-zero value in the solution of the pricing problem */
1742 SCIP_Real* solvals, /**< array of values in the solution of the pricing problem for variables in array solvars*/
1743 int nsolvars /**< number of variables in array solvars */
1744 )
1745{
1746 SCIP_ROW** originalsepamastercuts;
1747 int noriginalsepamastercuts;
1748 SCIP_ROW** originalsepaorigcuts;
1749
1750 SCIP_COL** cols;
1751 SCIP_Real conscoef;
1752 SCIP_VAR* var;
1753 SCIP_Real* consvals;
1754
1755 int i;
1756 int j;
1757 int k;
1758
1759 assert(scip_ != NULL);
1760 assert(newvar != NULL);
1761 assert(solvars != NULL || nsolvars == 0);
1762 assert(solvals != NULL || nsolvars == 0);
1763
1764 /* get the cuts of the master problem and the corresponding cuts in the original problem */
1765 originalsepamastercuts = GCGsepaGetOriginalSepaMastercuts(gcg);
1766 noriginalsepamastercuts = GCGsepaGetNOriginalSepaCuts(gcg);
1767 originalsepaorigcuts = GCGsepaGetOriginalSepaOrigcuts(gcg);
1768
1769 assert(originalsepamastercuts != NULL);
1770 assert(originalsepaorigcuts != NULL);
1771
1772 /* compute coef of the variable in the cuts and add it to the cuts */
1773 for( i = 0; i < noriginalsepamastercuts; i++ )
1774 {
1775 if( !SCIProwIsInLP(originalsepamastercuts[i]) )
1776 continue;
1777
1778 /* get columns of the cut and their coefficients */
1779 cols = SCIProwGetCols(originalsepaorigcuts[i]);
1780 consvals = SCIProwGetVals(originalsepaorigcuts[i]);
1781
1782 conscoef = 0;
1783
1784 for( j = 0; j < SCIProwGetNNonz(originalsepaorigcuts[i]); j++ )
1785 {
1786 int blocknr;
1787 var = SCIPcolGetVar(cols[j]);
1788 blocknr = GCGvarGetBlock(var);
1790
1791 /* if the belongs to the same block and is no linking variable, update the coef */
1792 if( blocknr == prob )
1793 for( k = 0; k < nsolvars; k++ )
1794 if( solvars[k] == GCGoriginalVarGetPricingVar(var) )
1795 {
1796 conscoef += (consvals[j] * solvals[k]);
1797 break;
1798 }
1799 }
1800
1801 if( !SCIPisZero(scip_, conscoef) )
1802 SCIP_CALL( SCIPaddVarToRow(scip_ , originalsepamastercuts[i], newvar, conscoef) );
1803 }
1804
1805 return SCIP_OKAY;
1806}
1807
1808/** add variable with computed coefficients to the original separator cuts */
1809SCIP_RETCODE ObjPricerGcg::addVariableToOriginalSepaCutsFromGCGCol(
1810 SCIP_VAR* newvar, /**< The new variable to add */
1811 GCG_COL* gcgcol /**< GCG column data structure */
1812 )
1813{
1814 SCIP_ROW** originalsepamastercuts;
1815 int noriginalsepamastercuts;
1816 SCIP_Real* originalsepamastercutcoefs;
1817 int i;
1818
1819 assert(scip_ != NULL);
1820 assert(newvar != NULL);
1821
1822 /* get the cuts of the master problem and the corresponding cuts in the original problem */
1823 originalsepamastercuts = GCGsepaGetOriginalSepaMastercuts(gcg);
1824 noriginalsepamastercuts = GCGsepaGetNOriginalSepaCuts(gcg);
1825
1826 assert(originalsepamastercuts != NULL);
1827
1829
1830 originalsepamastercutcoefs = GCGcolGetOriginalSepaMastercuts(gcgcol);
1831
1832 /* compute coef of the variable in the cuts and add it to the cuts */
1833 for( i = 0; i < noriginalsepamastercuts; i++ )
1834 {
1835 if( !SCIProwIsInLP(originalsepamastercuts[i]) )
1836 continue;
1837
1838 if( !SCIPisZero(scip_, originalsepamastercutcoefs[i]) )
1839 SCIP_CALL( SCIPaddVarToRow(scip_ , originalsepamastercuts[i], newvar, originalsepamastercutcoefs[i]) );
1840 }
1841
1842 return SCIP_OKAY;
1843}
1844
1845/** add variable with computed coefficients to the master separator cuts */
1847 SCIP_VAR* newvar, /**< the new master variable to add to master cuts*/
1848 GCG_COL* gcgcol /**< GCG column data structure which generated the master variable */
1849 )
1850{
1851 GCG_EXTENDEDMASTERCONSDATA** activecuts;
1852 SCIP_Real* mastersepacutcoeffs;
1853 int nactivecuts;
1854 int j;
1855
1856 assert(scip_ != NULL);
1857 assert(newvar != NULL);
1858 assert(gcgcol != NULL);
1859
1860 /* compute new variable coefficient for each cut */
1862 mastersepacutcoeffs = GCGcolGetMastersepaCutCoeffs(gcgcol);
1863 activecuts = GCGgetActiveMastersepacuts(gcg);
1864 nactivecuts = GCGgetNActiveMastersepacuts(gcg);
1865
1866 /* add the variable to the active cuts using the previously computed coefficients */
1867 for( j = 0; j < nactivecuts; j++ )
1868 {
1869 SCIP_ROW* row;
1870
1871 row = GCGextendedmasterconsGetRow(activecuts[j]);
1872 assert(row != NULL);
1873
1874 /* skip cuts which are not active */
1875 if( !SCIProwIsInLP(row) )
1876 continue;
1877
1878 /* add master var to cut with pre-computed coefficient */
1879 //SCIPinfoMessage(scip_, NULL, "add var %s: %f\n", SCIPvarGetName(newvar), mastersepacutcoeffs[j]);
1880 if( !SCIPisZero(scip_, mastersepacutcoeffs[j]) )
1881 SCIP_CALL( SCIPaddVarToRow(scip_, row, newvar, mastersepacutcoeffs[j]) );
1882 }
1883
1884 return SCIP_OKAY;
1885}
1886
1887/** compute coefficients for new master var and add them to the separator master cuts */
1889 SCIP_VAR* newvar, /**< the new master variable to add */
1890 int prob, /**< number of the pricing problem the solution belongs to */
1891 SCIP_VAR** solvars, /**< array of variables with non-zero value in the solution of the pricing problem */
1892 SCIP_Real* solvals, /**< array of values in the solution of the pricing problem for variables in array solvars*/
1893 int nsolvars /**< number of variables in array solvars */
1894 )
1895{
1896 GCG_EXTENDEDMASTERCONSDATA** activecuts;
1897 SCIP_Real coeff;
1898 int nactivecuts;
1899 int j;
1900
1901 assert(scip_ != NULL);
1902 assert(newvar != NULL);
1903 assert(solvars != NULL || nsolvars == 0);
1904 assert(solvals != NULL || nsolvars == 0);
1905
1906 /* get master sepa cuts and separators */
1907 activecuts = GCGgetActiveMastersepacuts(gcg);
1908 nactivecuts = GCGgetNActiveMastersepacuts(gcg);
1909
1910 for( j = 0; j < nactivecuts; j++ )
1911 {
1912 SCIP_ROW* row;
1913
1914 row = GCGextendedmasterconsGetRow(activecuts[j]);
1915
1916 /* inactive cuts remain the same */
1917 if( !SCIProwIsInLP(row) )
1918 continue;
1919
1920 /* update the variable history of the cut */
1922
1923 /* compute the coefficient for the cut */
1924 coeff = 0.0;
1925 SCIP_CALL( GCGmastersepacutGetExtendedmasterconsCoeff(gcg, activecuts[j], solvars, solvals, nsolvars, prob, NULL, &coeff) );
1926
1927 /* add master variable to cut with computed coefficient */
1928 if( !SCIPisZero(scip_, coeff) )
1929 SCIP_CALL( SCIPaddVarToRow(scip_ , row, newvar, coeff) );
1930 }
1931
1932 return SCIP_OKAY;
1933}
1934
1935/** compute original separator cut coefficients of column in the master problem */
1937 GCG_COL* gcgcol /**< GCG column data structure */
1938 )
1939{
1940 int prob;
1941 int i;
1942
1943 SCIP_VAR** solvars = NULL;
1944 SCIP_Real* solvals = NULL;
1945 int nsolvars;
1946 int noldoriginalsepamastercuts;
1947 int nneworiginalsepamastercuts;
1948 SCIP_Real* neworiginalsepamastercuts = NULL;
1949
1950 assert(scip_ != NULL);
1951 assert(gcgcol != NULL);
1952
1953 prob = GCGcolGetProbNr(gcgcol);
1954 nsolvars = GCGcolGetNVars(gcgcol);
1955 solvars = GCGcolGetVars(gcgcol);
1956 solvals = GCGcolGetVals(gcgcol);
1957
1958 noldoriginalsepamastercuts = GCGcolGetNOriginalSepaMastercuts(gcgcol);
1959
1960 SCIP_ROW** originalsepamastercuts = NULL;
1961 int noriginalsepamastercuts;
1962 SCIP_ROW** originalsepaorigcuts = NULL;
1963
1964 SCIP_COL** cols = NULL;
1965 SCIP_Real conscoef;
1966 SCIP_VAR* var = NULL;
1967 SCIP_Real* consvals = NULL;
1968
1969 int j;
1970 int k;
1971
1972 assert(scip_ != NULL);
1973 assert(solvars != NULL);
1974 assert(solvals != NULL);
1975
1976 /* get the cuts of the master problem and the corresponding cuts in the original problem */
1977 originalsepamastercuts = GCGsepaGetOriginalSepaMastercuts(gcg);
1978 noriginalsepamastercuts = GCGsepaGetNOriginalSepaCuts(gcg);
1979 originalsepaorigcuts = GCGsepaGetOriginalSepaOrigcuts(gcg);
1980
1981 assert(originalsepamastercuts != NULL);
1982 assert(originalsepaorigcuts != NULL);
1983
1984 assert(noriginalsepamastercuts - noldoriginalsepamastercuts >= 0);
1985
1986 if( noriginalsepamastercuts - noldoriginalsepamastercuts == 0 )
1987 return SCIP_OKAY;
1988
1989 SCIP_CALL( SCIPallocBufferArray(origprob, &neworiginalsepamastercuts, noriginalsepamastercuts - noldoriginalsepamastercuts) );
1990
1991 nneworiginalsepamastercuts = 0;
1992
1993 /* compute coef of the variable in the cuts and add it to the cuts */
1994 for( i = noldoriginalsepamastercuts; i < noriginalsepamastercuts; i++ )
1995 {
1996 if( !SCIProwIsInLP(originalsepamastercuts[i]) )
1997 {
1998 neworiginalsepamastercuts[nneworiginalsepamastercuts] = 0.0;
1999 ++nneworiginalsepamastercuts;
2000 continue;
2001 }
2002
2003 /* get columns of the cut and their coefficients */
2004 cols = SCIProwGetCols(originalsepaorigcuts[i]);
2005 consvals = SCIProwGetVals(originalsepaorigcuts[i]);
2006
2007 conscoef = 0;
2008
2009 for( j = 0; j < SCIProwGetNNonz(originalsepaorigcuts[i]); j++ )
2010 {
2011 int blocknr;
2012 var = SCIPcolGetVar(cols[j]);
2013 blocknr = GCGvarGetBlock(var);
2015
2016 /* if the belongs to the same block and is no linking variable, update the coef */
2017 if( blocknr == prob )
2018 for( k = 0; k < nsolvars; k++ )
2019 if( solvars[k] == GCGoriginalVarGetPricingVar(var) )
2020 {
2021 conscoef += ( consvals[j] * solvals[k] );
2022 break;
2023 }
2024 }
2025
2026 neworiginalsepamastercuts[nneworiginalsepamastercuts] = conscoef;
2027 ++nneworiginalsepamastercuts;
2028 }
2029
2030 GCGcolUpdateOriginalSepaMastercuts(gcgcol, neworiginalsepamastercuts, nneworiginalsepamastercuts);
2031
2032 SCIPfreeBufferArray(origprob, &neworiginalsepamastercuts);
2033
2034 return SCIP_OKAY;
2035}
2036
2037/** compute separator master cut coefficients of column and store them in the column */
2039 GCG_COL* gcgcol /**< GCG column data structure */
2040 )
2041{
2042 GCG_EXTENDEDMASTERCONSDATA** activecuts;
2043 SCIP_Real* coeffs = NULL;
2044 int i;
2045 int nactivecuts;
2046
2047 assert(scip_ != NULL);
2048 assert(gcgcol != NULL);
2049
2050 activecuts = GCGgetActiveMastersepacuts(gcg);
2051 nactivecuts = GCGgetNActiveMastersepacuts(gcg);
2052
2053 /* ensure that the coefficients for the master constraints have been computed */
2054 if( !GCGcolGetInitializedCoefs(gcgcol) )
2056
2057 /* no new cuts since last computation */
2058 if( nactivecuts == 0 )
2059 return SCIP_OKAY;
2060
2061 /* compute coefficient for each (active) cut */
2062 SCIP_CALL( SCIPallocBufferArray(origprob, &coeffs, nactivecuts) );
2063 for( i = 0; i < nactivecuts; ++i )
2064 {
2065 coeffs[i] = 0.0;
2066
2069 GCGcolGetNVars(gcgcol), GCGcolGetProbNr(gcgcol), gcgcol, &coeffs[i]) );
2070 }
2071
2072 /* transfer the computed coefficients to the gcg column */
2073 SCIP_CALL( GCGcolUpdateActiveMastersepacuts(gcg, gcgcol, activecuts, nactivecuts, coeffs) );
2075
2076 return SCIP_OKAY;
2077}
2078
2079/** add variable to the extended master conss */
2080SCIP_RETCODE ObjPricerGcg::addVariableToExtendedmastercons(
2081 SCIP_VAR* newvar /**< The new variable to add */
2082 )
2083{
2084 int i;
2085
2086 GCG_BRANCHRULE** branchrules;
2087 GCG_BRANCHDATA** branchdata;
2088 GCG_EXTENDEDMASTERCONSDATA** branchextendedmasterconsdata;
2089 int nbranchextendedmasterconss;
2090
2091 SCIP_CALL( GCGrelaxBranchGetAllActiveExtendedMasterConss(gcg, &branchrules, &branchdata, &branchextendedmasterconsdata, &nbranchextendedmasterconss) );
2092 assert(nbranchextendedmasterconss == 0 || branchextendedmasterconsdata != NULL);
2093
2094 /* compute coef of the variable in the extended master conss */
2095 for( i = 0; i < nbranchextendedmasterconss; i++ )
2096 {
2097 SCIP_CALL( GCGrelaxBranchNewCol(gcg, branchrules[i], branchdata[i], newvar) );
2098 }
2099
2100 return SCIP_OKAY;
2101}
2102
2103/** adds new variable to the end of the priced variables array */
2104SCIP_RETCODE ObjPricerGcg::addVariableToPricedvars(
2105 SCIP_VAR* newvar /**< variable to add */
2106 )
2107{
2108 SCIP_CALL( ensureSizePricedvars(pricerdata->npricedvars + 1) );
2112
2114
2115 return SCIP_OKAY;
2116}
2117
2118#ifdef SCIP_STATISTIC
2119/** adds new bounds to the bound arrays as well as some additional information on dual variables and root lp solution */
2120SCIP_RETCODE ObjPricerGcg::addRootBounds(
2121 SCIP_Real primalbound, /**< new primal bound for the root master LP */
2122 SCIP_Real dualbound /**< new dual bound for the root master LP */
2123 )
2124{
2125 SCIP_VAR** probvars;
2126 int nprobvars;
2127 int i;
2128 int j;
2129
2130 SCIP_SOL* sol;
2131 SCIP_Real* solvals;
2132 SCIP_VAR** vars;
2133 int nvars;
2134 int idx;
2135
2138
2139 SCIP_CALL( ensureSizeRootBounds(pricerdata->nrootbounds + 1) );
2140 pricerdata->rootpbs[pricerdata->nrootbounds] = primalbound;
2141 pricerdata->rootdbs[pricerdata->nrootbounds] = dualbound;
2142 pricerdata->roottimes[pricerdata->nrootbounds] = SCIPgetSolvingTime(scip_) - pricerdata->rootfarkastime;
2143 pricerdata->rootdualdiffs[pricerdata->nrootbounds] = pricerdata->dualdiff;
2144
2145 SCIPdebugMessage("Add new bounds: \n pb = %f\n db = %f\n", primalbound, dualbound);
2146
2149
2150 for( i = 0; i < pricerdata->npricingprobs; i++ )
2151 {
2152 if( pricerdata->pricingprobs[i] == NULL )
2153 continue;
2154
2156 nprobvars = pricerdata->nrealdualvalues[i];
2157
2158 pricerdata->dualsolconvs[pricerdata->nrootbounds][i] = pricerdata->dualsolconv[i];
2159 SCIP_CALL( SCIPallocBlockMemoryArray(scip_, &(pricerdata->dualvalues[pricerdata->nrootbounds][i]), nprobvars) );
2160
2161 for( j = 0; j < nprobvars; j++ )
2162 {
2163 idx = SCIPvarGetIndex(probvars[j]);
2164 assert(idx >= 0 && idx < pricerdata->nrealdualvalues[i]);
2165 pricerdata->dualvalues[pricerdata->nrootbounds][i][idx] = pricerdata->realdualvalues[i][idx];
2166 }
2167 }
2168
2169 pricerdata->nrootbounds++;
2170
2172
2173 SCIP_CALL( SCIPgetSolVals(scip_, NULL, nvars, vars, solvals) );
2174
2175 SCIP_CALL( SCIPcreateSol(scip_, &sol, NULL) );
2176
2177 SCIP_CALL( SCIPsetSolVals(scip_, sol, nvars, vars, solvals) );
2178
2179 if( pricerdata->rootlpsol != NULL)
2180 SCIPfreeSol(scip_, &pricerdata->rootlpsol);
2181
2182 pricerdata->rootlpsol = sol;
2183
2184 SCIPfreeBufferArray(scip_, &solvals);
2185
2186 return SCIP_OKAY;
2187}
2188#endif
2189
2190SCIP_Real ObjPricerGcg::computeRedCost(
2191 PricingType* pricetype, /**< type of pricing */
2192 SCIP_SOL* sol, /**< solution to compute reduced cost for */
2193 SCIP_Bool solisray, /**< is the solution a ray? */
2194 int probnr, /**< number of the pricing problem the solution belongs to */
2195 SCIP_Real* objvalptr /**< pointer to store the computed objective value */
2196 ) const
2197{
2198 GCG_PRICINGPROB* pricingprob;
2199 SCIP* pricingscip;
2200 SCIP_CONS** branchconss; /* stack of genericbranching constraints */
2201 int nbranchconss; /* number of generic branching constraints */
2202 SCIP_Real* branchduals; /* dual values of branching constraints in the master (sigma) */
2203 int i;
2204
2205 SCIP_VAR** solvars;
2206 SCIP_Real* solvals = NULL;
2207 int nsolvars;
2208 SCIP_Real objvalue;
2209
2210 GCG_EXTENDEDMASTERCONSDATA* extendedmasterconsdata;
2211
2212 assert(pricerdata != NULL);
2213
2214 pricingprob = pricingcontroller->getPricingprob(probnr);
2215 assert(pricingprob != NULL);
2216
2217 objvalue = 0.0;
2218 pricingscip = pricerdata->pricingprobs[probnr];
2219 solvars = SCIPgetOrigVars(pricingscip);
2220 nsolvars = SCIPgetNOrigVars(pricingscip);
2221 SCIP_CALL_ABORT( SCIPallocBlockMemoryArray(scip_, &solvals, nsolvars) );
2222 SCIP_CALL_ABORT( SCIPgetSolVals(pricingscip, sol, nsolvars, solvars, solvals) );
2223
2224 /* compute the objective function value of the solution */
2225 for( i = 0; i < nsolvars; i++ )
2226 {
2227 assert(GCGvarIsPricing(solvars[i]) || GCGvarIsInferredPricing(solvars[i]));
2228 if( GCGvarIsPricing(solvars[i]) )
2229 {
2230 assert(SCIPvarGetIndex(solvars[i]) >= 0 && SCIPvarGetIndex(solvars[i]) < pricerdata->nrealdualvalues[probnr]);
2231 objvalue += solvals[i] * pricerdata->realdualvalues[probnr][SCIPvarGetIndex(solvars[i])];
2232 }
2233 else if( GCGvarIsInferredPricing(solvars[i]) && GCGinferredPricingVarIsCoefVar(solvars[i]) )
2234 {
2235 extendedmasterconsdata = GCGinferredPricingVarGetExtendedmasterconsdata(solvars[i]);
2236 objvalue -= solvals[i] * pricetype->extendedmasterconsGetDual(extendedmasterconsdata);
2237 }
2238 }
2239
2240 if( objvalptr != NULL )
2241 *objvalptr = objvalue;
2242
2243 /* get path to the last generic branching node */
2244 GCGpricingprobGetGenericBranchData(pricingprob, &branchconss, &branchduals, &nbranchconss);
2245
2246 for( i = nbranchconss - 1; i >= 0; --i )
2247 {
2248 SCIP_Bool feasible;
2249 SCIP_CALL_ABORT( checkBranchingBoundChanges(probnr, sol, branchconss[i], &feasible) );
2250 if( feasible )
2251 {
2252 objvalue -= branchduals[i];
2253 }
2254 }
2255 SCIPfreeBlockMemoryArray(scip_, &solvals, nsolvars);
2256
2257 /* compute reduced cost of variable (i.e. subtract dual solution of convexity constraint, if solution corresponds to a point) */
2258 return (solisray ? objvalue : objvalue - pricerdata->dualsolconv[probnr]);
2259}
2260
2262 PricingType* pricetype, /**< type of pricing */
2263 GCG_Col* gcgcol, /**< gcg column to compute reduced cost for */
2264 SCIP_Real* objvalptr /**< pointer to store the computed objective value */
2265 ) const
2266{
2267 GCG_PRICINGPROB* pricingprob;
2268 SCIP_CONS** branchconss; /* stack of genericbranching constraints */
2269 int nbranchconss; /* number of generic branching constraints */
2270 SCIP_Real* branchduals; /* dual values of branching constraints in the master (sigma) */
2271 int i;
2272 int probnr;
2273
2274 SCIP_Bool isray;
2275
2276 SCIP_Real redcost;
2277
2278 SCIP_VAR** solvars;
2279 SCIP_Real* solvals;
2280 int nsolvars;
2281 SCIP_Real objvalue;
2282
2284
2285 objvalue = 0.0;
2286 probnr = GCGcolGetProbNr(gcgcol);
2287
2288 solvars = GCGcolGetVars(gcgcol);
2289 nsolvars = GCGcolGetNVars(gcgcol);
2290 solvals = GCGcolGetVals(gcgcol);
2291 isray = GCGcolIsRay(gcgcol);
2292
2293 pricingprob = pricingcontroller->getPricingprob(probnr);
2294 assert(pricingprob != NULL);
2295
2296 /* compute the objective function value of the column */
2297 for( i = 0; i < nsolvars; i++ )
2298 {
2299 assert(GCGvarIsPricing(solvars[i]));
2300 if( GCGvarIsPricing(solvars[i]) )
2301 {
2302 assert(SCIPvarGetIndex(solvars[i]) >= 0 && SCIPvarGetIndex(solvars[i]) < pricerdata->nrealdualvalues[probnr]);
2303 objvalue += solvals[i] * pricerdata->realdualvalues[probnr][SCIPvarGetIndex(solvars[i])];
2304 }
2305 }
2306
2307 if( objvalptr != NULL )
2308 *objvalptr = objvalue;
2309
2310 /* get path to the last generic branching node */
2311 GCGpricingprobGetGenericBranchData(pricingprob, &branchconss, &branchduals, &nbranchconss);
2312
2313 for( i = nbranchconss -1; i >= 0; --i )
2314 {
2315 SCIP_Bool feasible;
2316 SCIP_CALL_ABORT( checkBranchingBoundChangesGcgCol(gcgcol, branchconss[i], &feasible) );
2317 if( feasible )
2318 {
2319 objvalue -= branchduals[i];
2320 }
2321 }
2322
2323 solvars = GCGcolGetInferredPricingVars(gcgcol);
2324 nsolvars = GCGcolGetNInferredPricingVars(gcgcol);
2325 solvals = GCGcolGetInferredPricingVals(gcgcol);
2326 for( i = 0; i < nsolvars; ++i )
2327 {
2329
2331 objvalue -= solvals[i] * pricetype->extendedmasterconsGetDual(extendedmasterconsdata);
2332 }
2333
2334 redcost = (isray ? objvalue : objvalue - pricerdata->dualsolconv[probnr]);
2335
2336 return redcost;
2337}
2338
2339/** for given columns, (re-)compute and update their reduced costs */
2340void ObjPricerGcg::updateRedcosts(
2341 PricingType* pricetype, /**< type of pricing */
2342 GCG_COL** cols, /**< columns to compute reduced costs for */
2343 int ncols /**< number of columns */
2344 ) const
2345{
2346 SCIPdebugMessage("Update reduced costs\n");
2347
2348 for( int i = 0; i < ncols; ++i )
2349 {
2350 SCIP_Real redcost = computeRedCostGcgCol(pricetype, cols[i], NULL);
2351 GCGcolUpdateRedcost(cols[i], redcost, FALSE);
2352
2353 SCIPdebugMessage(" -> column %d/%d <%p>, reduced cost = %g\n", i+1, ncols, (void*) cols[i], redcost);
2354 }
2355}
2356
2358 GCG_COL* col, /**< priced col */
2359 SCIP_Bool* added
2360 )
2361{
2362 SCIP_Bool addedcol;
2363 SCIP_Real redcost;
2364 assert(col != NULL);
2365 redcost = computeRedCostGcgCol(pricingtype, col, NULL);
2366 GCGcolUpdateRedcost(col, redcost, FALSE);
2367 GCGpricestoreAddCol(pricestore, col, FALSE, FALSE, &addedcol);
2368
2369 if( addedcol )
2370 {
2373#ifdef SCIP_DEBUG
2374 GCG_SET_LOCK(&pricerdata->locks->printlock);
2375 SCIPdebugMessage(" -> new column <%p>, reduced cost = %.8g\n", (void*) col, redcost);
2376 GCG_UNSET_LOCK(&pricerdata->locks->printlock);
2377#endif
2378 }
2379 if( added != NULL )
2380 *added = addedcol;
2381 return SCIP_OKAY;
2382}
2383
2384/** for each pricing problem, get the best found column from the pricing storage */
2386 GCG_COL** pricingprobcols /**< array to be filled with best column per pricing problem */
2387 )
2388{
2389 GCG_COL** cols;
2390 GCG_COL* col;
2391 int ncols;
2392 int i;
2393 int j;
2394
2395 assert(pricingprobcols != NULL);
2396
2397 SCIPdebugMessage("getBestCols():\n");
2398 for( i = 0; i < pricerdata->npricingprobs; ++i )
2399 {
2400 pricingprobcols[i] = NULL;
2401
2404
2405 for( j = 0; j < ncols; ++j )
2406 {
2407 col = cols[j];
2408 assert(i == GCGcolGetProbNr(col));
2409
2410 if( pricingprobcols[i] == NULL || SCIPisDualfeasLT(scip_, GCGcolGetRedcost(col), GCGcolGetRedcost(pricingprobcols[i])) )
2411 pricingprobcols[i] = col;
2412 }
2413#ifndef NDEBUG
2414 if( ncols > 0 )
2415 SCIPdebugMessage(" -> problem %d best col <%p>, redcost: %.8g\n", i, (void*)pricingprobcols[i], GCGcolGetRedcost(pricingprobcols[i]));
2416#endif
2417 }
2418}
2419
2420/** get the sum over the dual values of convexity constraints */
2422 GCG_COL** bestcols /**< best columns found per pricing problem */
2423 )
2424{
2425 SCIP_Real dualconvsum = 0.0;
2426
2427 assert(pricingtype != NULL);
2428
2429 for( int i = 0; i < pricerdata->npricingprobs; ++i )
2430 {
2431 if( GCGisPricingprobRelevant(gcg, i) && (bestcols[i] == NULL || !GCGcolIsRay(bestcols[i])) )
2432 dualconvsum += GCGgetNIdenticalBlocks(gcg, i) * pricingtype->consGetDual(GCGgetConvCons(gcg, i));
2433 }
2434
2435 return dualconvsum;
2436}
2437
2438/* computes the objective value of the current (stabilized) dual variables) in the dual program */
2440 PricingType* pricetype, /**< type of pricing */
2441 SCIP_Real* stabdualval, /**< pointer to store stabilized dual objective value */
2442 SCIP_Bool stabilize /**< stabilize? */
2443)
2444{
2445 SCIP_VAR** staticvars;
2446 int nstaticvars;
2447
2448 SCIP_CONS** origconss = NULL;
2449
2450 SCIP_ROW** originalsepaorigcuts = NULL;
2451 SCIP_COL** cols = NULL;
2452 SCIP_Real* consvals = NULL;
2453
2454 SCIP_VAR** consvars = NULL;
2455 int nconsvars;
2456 int j;
2457
2458 SCIP_Real dualsol;
2459 SCIP_Real boundval;
2460
2461 SCIP_CONS** masterconss = NULL;
2462 int nmasterconss;
2463
2464 int nlinkconss;
2465 SCIP_CONS** linkconss = NULL;
2466
2467 SCIP_ROW** originalsepamastercuts = NULL;
2468 int noriginalsepamastercuts;
2469 int i;
2470
2471 GCG_BRANCHRULE** activebranchrules = NULL;
2472 GCG_BRANCHDATA** activebranchdata = NULL;
2473 GCG_EXTENDEDMASTERCONSDATA** branchextendedmasterconsdata = NULL;
2474 int nbranchextendedmasterconsdata = 0;
2475 SCIP_CONS* extendedmasterconscons;
2476
2477 /* sepa mastercuts */
2478 GCG_EXTENDEDMASTERCONSDATA** activecuts = NULL;
2479 int nactivecuts;
2480
2481 SCIP_Real* stabredcosts = NULL;
2482
2483 assert(stabilization != NULL);
2484 assert(stabdualval != NULL);
2485
2486 *stabdualval = 0.0;
2487
2488 SCIPdebugMessage("getStabilizedDualObjectiveValue() calculation\n");
2489
2490#ifndef NDEBUG
2491 /* check linking constraints */
2492 nlinkconss = GCGgetNVarLinkingconss(gcg);
2493 linkconss = GCGgetVarLinkingconss(gcg);
2494
2495 /* compute lhs/rhs * dual for linking constraints and add it to dualobjval */
2496 for( i = 0; i < nlinkconss; ++i )
2497 {
2498 SCIP_CONS* linkcons = linkconss[i];
2499 SCIP_VAR** linkconsvars;
2500 int block = GCGgetVarLinkingconssBlock(gcg)[i];
2501
2502 linkconsvars = SCIPgetVarsLinear(scip_, linkcons);
2503
2504 SCIP_VAR* linkvar = linkconsvars[0];
2505
2509 }
2510#endif
2511
2512 /* compute lhs/rhs * dual for master constraints and add it to *stabdualval */
2513 /* get the constraints of the master problem and the corresponding constraints in the original problem */
2514 nmasterconss = GCGgetNMasterConss(gcg);
2515 masterconss = GCGgetMasterConss(gcg);
2516 origconss = GCGgetOrigMasterConss(gcg);
2517 for( i = 0; i < nmasterconss; i++ )
2518 {
2519 SCIP_Real lhs = GCGconsGetLhs(scip_, origconss[i]);
2520 SCIP_Real rhs = GCGconsGetRhs(scip_, origconss[i]);
2521
2522 if( stabilize )
2523 SCIP_CALL( stabilization->consGetDual(i, &dualsol) );
2524 else
2525 dualsol = pricetype->consGetDual(masterconss[i]);
2526
2527 if( !SCIPisZero(scip_, dualsol) || (!SCIPisInfinity(scip_, -lhs) && !SCIPisInfinity(scip_, rhs)) )
2528 // SCIPisZero(boundval * dualsol) could be FALSE although SCIPisZero(scip_, dualsol) holds
2529 boundval = dualsol > 0.0 ? lhs : rhs;
2530 else if( !SCIPisInfinity(scip_, -lhs) )
2531 boundval = lhs;
2532 else if( !SCIPisInfinity(scip_, rhs) )
2533 boundval = rhs;
2534 else
2535 continue;
2536
2537#ifdef PRINTDUALSOLS
2538 if( !SCIPisZero(scip_, boundval * dualsol) )
2539 {
2540 SCIPdebugMessage(" add %g (<%s>, dualsol: %g, bnds: [%g, %g])\n",
2541 boundval * dualsol, SCIPconsGetName(masterconss[i]), dualsol, lhs, rhs);
2542 }
2543#endif
2544 *stabdualval += boundval * dualsol;
2545 }
2546
2547 /* get the cuts of the master problem */
2548 originalsepamastercuts = GCGsepaGetOriginalSepaMastercuts(gcg);
2549 noriginalsepamastercuts = GCGsepaGetNOriginalSepaCuts(gcg);
2550 originalsepaorigcuts = GCGsepaGetOriginalSepaOrigcuts(gcg);
2551
2552 assert(originalsepamastercuts != NULL);
2553 assert(originalsepaorigcuts != NULL);
2554
2555 /* compute lhs/rhs * dual for master cuts and add it to dualobjval */
2556 for( i = 0; i < noriginalsepamastercuts; i++ )
2557 {
2558 SCIP_Real lhs = SCIProwGetLhs(originalsepamastercuts[i]);
2559 SCIP_Real rhs = SCIProwGetRhs(originalsepamastercuts[i]);
2560
2561 if( stabilize )
2562 SCIP_CALL( stabilization->rowGetDual(i, &dualsol) );
2563 else
2564 dualsol = pricetype->rowGetDual(originalsepamastercuts[i]);
2565
2566 if( !SCIPisZero(scip_, dualsol) || (!SCIPisInfinity(scip_, -lhs) && !SCIPisInfinity(scip_, rhs)) )
2567 boundval = dualsol > 0.0 ? lhs : rhs;
2568 else if( !SCIPisInfinity(scip_, -lhs) )
2569 boundval = lhs;
2570 else if( !SCIPisInfinity(scip_, rhs) )
2571 boundval = rhs;
2572 else
2573 continue;
2574
2575 boundval -= SCIProwGetConstant(originalsepamastercuts[i]);
2576
2577#ifdef PRINTDUALSOLS
2578 if( !SCIPisZero(scip_, boundval * dualsol) )
2579 {
2580 SCIPdebugMessage(" add %g (<%s>, dualsol: %g, bnds: [%g, %g] - %g)\n",
2581 boundval * dualsol, SCIProwGetName(originalsepamastercuts[i]), dualsol, lhs, rhs, SCIProwGetConstant(originalsepamastercuts[i]));
2582 }
2583#endif
2584 *stabdualval += boundval * dualsol;
2585 }
2586
2587 SCIP_CALL( GCGrelaxBranchGetAllActiveExtendedMasterConss(gcg, &activebranchrules, &activebranchdata, &branchextendedmasterconsdata, &nbranchextendedmasterconsdata) );
2588 assert(nbranchextendedmasterconsdata == 0 || (activebranchrules != NULL && activebranchdata != NULL && branchextendedmasterconsdata != NULL));
2589
2590 /* extended master conss: determine dual values and call update function */
2591 for( i = 0; i < nbranchextendedmasterconsdata; i++ )
2592 {
2593 SCIP_Real lhs = GCGextendedmasterconsGetLhs(gcg, branchextendedmasterconsdata[i]);
2594 SCIP_Real rhs = GCGextendedmasterconsGetRhs(gcg, branchextendedmasterconsdata[i]);
2595
2596 if( stabilize )
2597 {
2598 dualsol = stabilization->branchmasterconsGetDual(i);
2599 }
2600 else
2601 {
2602 dualsol = pricetype->extendedmasterconsGetDual(branchextendedmasterconsdata[i]);
2603 }
2604
2605 if( !SCIPisZero(scip_, dualsol) || (!SCIPisInfinity(scip_, -lhs) && !SCIPisInfinity(scip_, rhs)) )
2606 boundval = dualsol > 0.0 ? lhs : rhs;
2607 else if( !SCIPisInfinity(scip_, -lhs) )
2608 boundval = lhs;
2609 else if( !SCIPisInfinity(scip_, rhs) )
2610 boundval = rhs;
2611 else
2612 continue;
2613
2614 boundval -= GCGextendedmasterconsGetConstant(gcg, branchextendedmasterconsdata[i]);
2615
2616#ifdef PRINTDUALSOLS
2617 if( !SCIPisZero(scip_, boundval * dualsol) )
2618 {
2619 SCIPdebugMessage(" add %g (<%s>, dualsol: %g, bnds: [%g, %g] - %g)\n",
2620 boundval * dualsol, GCGextendedmasterconsGetName(branchextendedmasterconsdata[i]),
2621 dualsol, lhs, rhs, GCGextendedmasterconsGetConstant(gcg, branchextendedmasterconsdata[i]));
2622 }
2623#endif
2624 *stabdualval += boundval * dualsol;
2625 }
2626
2627 /* separator master cuts */
2628 nactivecuts = GCGgetNActiveMastersepacuts(gcg);
2629 activecuts = GCGgetActiveMastersepacuts(gcg);
2630
2631 for( j = 0; j < nactivecuts; j++ )
2632 {
2633 SCIP_ROW* mastercutrow;
2634
2635 mastercutrow = GCGextendedmasterconsGetRow(activecuts[j]);
2636 assert(mastercutrow != NULL);
2637
2638 SCIP_Real lhs = SCIProwGetLhs(mastercutrow);
2639 SCIP_Real rhs = SCIProwGetRhs(mastercutrow);
2640
2641 /* @todo stabilize */
2642 if( stabilize )
2643 {
2644 dualsol = pricetype->rowGetDual(mastercutrow);
2645 }
2646 else
2647 {
2648 dualsol = pricetype->rowGetDual(mastercutrow);
2649 }
2650
2651 if( !SCIPisZero(scip_, dualsol) || (!SCIPisInfinity(scip_, -lhs) && !SCIPisInfinity(scip_, rhs)) )
2652 boundval = dualsol > 0.0 ? lhs : rhs;
2653 else if( !SCIPisInfinity(scip_, -lhs) )
2654 boundval = lhs;
2655 else if( !SCIPisInfinity(scip_, rhs) )
2656 boundval = rhs;
2657 else
2658 continue;
2659
2660 boundval -= SCIProwGetConstant(mastercutrow);
2661
2662#ifdef PRINTDUALSOLS
2663 if( !SCIPisZero(scip_, boundval * dualsol) )
2664 {
2665 SCIPdebugMessage(" add %g (<%s>, dualsol: %g, bnds: [%g, %g] - %g)\n",
2666 boundval * dualsol, SCIProwGetName(mastercutrow), dualsol, lhs, rhs, SCIProwGetConstant(mastercutrow));
2667 }
2668#endif
2669 *stabdualval += boundval * dualsol;
2670 }
2671
2672
2673 /* get master variables that were directly transferred or that are linking */
2674 staticvars = SCIPgetOrigVars(scip_);
2675 nstaticvars = SCIPgetNOrigVars(scip_);
2676
2678
2679 /* no linking or directly transferred variables exist, exit */
2680 if( nstaticvars == 0 )
2681 return SCIP_OKAY;
2682
2683 /* allocate memory for array with (stabilized) reduced cost coefficients */
2684 SCIP_CALL( SCIPallocBufferArray(scip_, &stabredcosts, nstaticvars) );
2685
2686 /* initialize (stabilized) reduced cost with objective coefficients */
2687 for( i = 0; i < nstaticvars; i++ )
2688 {
2689 assert(GCGvarGetBlock(staticvars[i]) == -1);
2691
2692 stabredcosts[i] = SCIPvarGetObj(staticvars[i]);
2693#ifdef PRINTDUALSOLS
2694 if( !SCIPisZero(scip_, SCIPvarGetObj(staticvars[i])) )
2695 {
2696 SCIPdebugMessage(" stabredcost <%s> add %g\n", SCIPvarGetName(staticvars[i]), SCIPvarGetObj(staticvars[i]));
2697 }
2698#endif
2699 }
2700
2701 /*
2702 * compute (stabilized) reduced cost coefficients for static variables (direct copies and linking variables);
2703 * loop over variable linking constraints, master constraints and master cuts
2704 */
2705 nlinkconss = GCGgetNVarLinkingconss(gcg);
2706 linkconss = GCGgetVarLinkingconss(gcg);
2707 for( i = 0; i < nlinkconss; ++i )
2708 {
2709 SCIP_VAR** linkconsvars;
2710 SCIP_CONS* linkcons = linkconss[i];
2711 int varindex;
2712
2713 linkconsvars = SCIPgetVarsLinear(scip_, linkcons);
2714
2715 SCIP_VAR* linkvar = linkconsvars[0];
2716
2718 assert(varindex < nstaticvars);
2719 assert(staticvars[varindex] == GCGoriginalVarGetMastervars(GCGmasterVarGetOrigvars(linkvar)[0])[0]);
2720
2721 if( stabilize )
2722 {
2723 dualsol = stabilization->linkingconsGetDual(i);
2724 }
2725 else
2726 {
2727 dualsol = pricetype->consGetDual(linkcons);
2728 }
2729
2730 /* subtract dual solution value from the linking variable
2731 * (linking variables have coefficient 1 in linking constraints)
2732 */
2733 stabredcosts[varindex] -= dualsol;
2734#ifdef PRINTDUALSOLS
2735 if( !SCIPisZero(scip_, dualsol) )
2736 {
2737 SCIPdebugMessage(" stabredcost <%s> add %g (cons <%s>)\n", SCIPvarGetName(staticvars[varindex]), -dualsol, SCIPconsGetName(linkcons));
2738 }
2739#endif
2740 }
2741
2742 for( i = 0; i < nmasterconss; i++ )
2743 {
2744 if( stabilize )
2745 {
2746 SCIP_CALL( stabilization->
2747 consGetDual(i, &dualsol) );
2748 }
2749 else
2750 {
2751 dualsol = pricetype->consGetDual(masterconss[i]);
2752 }
2753
2754 /* search for static variables in the constraint, and update their red. cost coefficients */
2755 nconsvars = GCGconsGetNVars(origprob, origconss[i]);
2756 SCIP_CALL( SCIPallocBufferArray(scip_, &consvars, nconsvars) );
2757 SCIP_CALL( SCIPallocBufferArray(scip_, &consvals, nconsvars) );
2758 GCGconsGetVars(origprob, origconss[i], consvars, nconsvars);
2759 GCGconsGetVals(origprob, origconss[i], consvals, nconsvars);
2760 for( j = 0; j < nconsvars; j++ )
2761 {
2762 SCIP_VAR* mastervar;
2763 int blocknr;
2764
2765 assert(GCGvarIsOriginal(consvars[j]));
2766
2767 if( GCGoriginalVarGetNMastervars(consvars[j]) == 0 )
2768 continue;
2769 assert( GCGoriginalVarGetNMastervars(consvars[j]) > 0 );
2770
2771 mastervar = GCGoriginalVarGetMastervars(consvars[j])[0];
2772 blocknr = GCGvarGetBlock(mastervar);
2773
2774 if( blocknr < 0 )
2775 {
2776 int varindex;
2777 varindex = SCIPvarGetProbindex(GCGoriginalVarGetMastervars(GCGmasterVarGetOrigvars(mastervar)[0])[0]); // hack
2778 assert(varindex < nstaticvars);
2779 assert(staticvars[varindex] == GCGoriginalVarGetMastervars(GCGmasterVarGetOrigvars(mastervar)[0])[0]);
2780
2781 stabredcosts[varindex] -= dualsol * consvals[j];
2782#ifdef PRINTDUALSOLS
2783 if( !SCIPisZero(scip_, dualsol) )
2784 {
2785 SCIPdebugMessage(" stabredcost <%s> add %g * %g = %g (cons <%s>)\n", SCIPvarGetName(staticvars[varindex]), dualsol, consvals[j], -dualsol * consvals[j], SCIPconsGetName(origconss[i]));
2786 }
2787#endif
2788 }
2789 }
2790 SCIPfreeBufferArray(scip_, &consvals);
2791 SCIPfreeBufferArray(scip_, &consvars);
2792 }
2793
2794 /* compute reduced cost for master cuts and update (stabilized) reduced cost coefficients */
2795 for( i = 0; i < noriginalsepamastercuts; i++ )
2796 {
2797 if( stabilize )
2798 {
2799 SCIP_CALL( stabilization->rowGetDual(i, &dualsol) );
2800 }
2801 else
2802 {
2803 dualsol = pricetype->rowGetDual(originalsepamastercuts[i]);
2804 }
2805
2806 /* get columns and vals of the cut */
2807 nconsvars = SCIProwGetNNonz(originalsepaorigcuts[i]);
2808 cols = SCIProwGetCols(originalsepaorigcuts[i]);
2809 consvals = SCIProwGetVals(originalsepaorigcuts[i]);
2810
2811 /* get the variables corresponding to the columns in the cut */
2812 SCIP_CALL( SCIPallocBufferArray(scip_, &consvars, nconsvars) );
2813 for( j = 0; j < nconsvars; j++ )
2814 consvars[j] = SCIPcolGetVar(cols[j]);
2815
2816 /* search for static variables in the constraint, and update their red. cost coefficients */
2817 for( j = 0; j < nconsvars; j++ )
2818 {
2819 SCIP_VAR* mastervar;
2820 int blocknr;
2821
2822 assert(GCGvarIsOriginal(consvars[j]));
2823
2824 if( GCGoriginalVarGetNMastervars(consvars[j]) == 0 )
2825 continue;
2826 assert( GCGoriginalVarGetNMastervars(consvars[j]) > 0 );
2827
2828 mastervar = GCGoriginalVarGetMastervars(consvars[j])[0];
2829 blocknr = GCGvarGetBlock(mastervar);
2830
2831 if( blocknr < 0 )
2832 {
2833 int varindex;
2834 varindex = SCIPvarGetProbindex(GCGoriginalVarGetMastervars(GCGmasterVarGetOrigvars(mastervar)[0])[0]); // hack
2835 assert(varindex < nstaticvars);
2836 assert(staticvars[varindex] == GCGoriginalVarGetMastervars(GCGmasterVarGetOrigvars(mastervar)[0])[0]);
2837
2838 stabredcosts[varindex] -= dualsol * consvals[j];
2839#ifdef PRINTDUALSOLS
2840 if( !SCIPisZero(scip_, dualsol) )
2841 {
2842 SCIPdebugMessage(" stabredcost <%s> add %g * %g = %g (cut <%s>)\n",
2843 SCIPvarGetName(staticvars[varindex]), dualsol, consvals[j], -dualsol * consvals[j],
2844 SCIProwGetName(originalsepaorigcuts[i]));
2845 }
2846#endif
2847 }
2848 }
2849 SCIPfreeBufferArray(scip_, &consvars);
2850 }
2851
2852 /* compute reduced cost for extended master conss and update (stabilized) reduced cost coefficients */
2853 for( i = 0; i < nbranchextendedmasterconsdata; i++ )
2854 {
2855 if( stabilize )
2856 {
2857 dualsol = stabilization->branchmasterconsGetDual(i);
2858 }
2859 else
2860 {
2861 dualsol = pricetype->extendedmasterconsGetDual(branchextendedmasterconsdata[i]);
2862 }
2863
2864 extendedmasterconscons = GCGextendedmasterconsGetCons(branchextendedmasterconsdata[i]);
2865 assert(extendedmasterconscons != NULL);
2866 nconsvars = GCGconsGetNVars(origprob, extendedmasterconscons);
2867 SCIP_CALL( SCIPallocBufferArray(scip_, &consvars, nconsvars) );
2868 SCIP_CALL( SCIPallocBufferArray(scip_, &consvals, nconsvars) );
2869 GCGconsGetVars(origprob, extendedmasterconscons, consvars, nconsvars);
2870 GCGconsGetVals(origprob, extendedmasterconscons, consvals, nconsvars);
2871
2872 /* search for static variables in the constraint, and update their red. cost coefficients */
2873 for( j = 0; j < nconsvars; j++ )
2874 {
2875 SCIP_VAR* mastervar;
2876 int blocknr;
2877
2878 assert(GCGvarIsMaster(consvars[j]));
2879
2880 mastervar = consvars[j];
2881 blocknr = GCGvarGetBlock(mastervar);
2882
2883 if( blocknr < 0 )
2884 {
2885 int varindex;
2886 varindex = SCIPvarGetProbindex(GCGoriginalVarGetMastervars(GCGmasterVarGetOrigvars(mastervar)[0])[0]); // hack
2887 assert(varindex < nstaticvars);
2888 assert(staticvars[varindex] == GCGoriginalVarGetMastervars(GCGmasterVarGetOrigvars(mastervar)[0])[0]);
2889
2890 stabredcosts[varindex] -= dualsol * consvals[j];
2891#ifdef PRINTDUALSOLS
2892 if( !SCIPisZero(scip_, dualsol) )
2893 {
2894 SCIPdebugMessage(" stabredcost <%s> add %g * %g = %g (cut <%s>)\n",
2895 SCIPvarGetName(staticvars[varindex]), dualsol, consvals[j], -dualsol * consvals[j],
2896 GCGextendedmasterconsGetName(branchextendedmasterconsdata[i]));
2897 }
2898#endif
2899 }
2900 }
2901 switch( GCGextendedmasterconsGetType(branchextendedmasterconsdata[i]) )
2902 {
2904 SCIPfreeBufferArray(scip_, &consvals);
2905 SCIPfreeBufferArray(scip_, &consvars);
2906 break;
2908 SCIPfreeBufferArray(scip_, &consvars);
2909 break;
2910 default:
2912 return SCIP_ERROR;
2913 }
2914 }
2915
2916 /* master separator cuts */
2917 for( i = 0; i < nactivecuts; i++ )
2918 {
2919 SCIP_ROW* mastercutrow;
2920
2921 mastercutrow = GCGextendedmasterconsGetRow(activecuts[i]);
2922 assert(mastercutrow != NULL);
2923
2924 // get columns and vals of the cut
2925 nconsvars = SCIProwGetNNonz(mastercutrow);
2926 cols = SCIProwGetCols(mastercutrow);
2927 consvals = SCIProwGetVals(mastercutrow);
2928
2929 // get the variables corresponding to the columns in the cut
2930 consvars = NULL;
2931 SCIP_CALL( SCIPallocBufferArray(scip_, &consvars, nconsvars) );
2932 for( j = 0; j < nconsvars; j++ )
2933 consvars[j] = SCIPcolGetVar(cols[j]);
2934
2935 // @todo stabilize
2936 if( stabilize )
2937 {
2938 dualsol = pricetype->rowGetDual(mastercutrow);
2939 }
2940 else
2941 {
2942 dualsol = pricetype->rowGetDual(mastercutrow);
2943 }
2944
2945 for( j = 0; j < nconsvars; j++ )
2946 {
2947 int blocknr;
2948
2949 blocknr = GCGvarGetBlock(consvars[j]);
2950
2951 // master variable is static variable
2952 if( blocknr < 0 )
2953 {
2954 SCIP_VAR* origvar;
2955 int varindex;
2956
2957 assert(GCGmasterVarGetNOrigvars(consvars[j]) == 1);
2958 assert(GCGmasterVarGetOrigvals(consvars[j])[0] == 1);
2959 origvar = GCGmasterVarGetOrigvars(consvars[j])[0];
2960
2961 // coefficient of master variable in this cut corresponds to the coefficient of static var in hypothetical original cut???
2962 varindex = SCIPvarGetProbindex(GCGoriginalVarGetMastervars(origvar)[0]);
2963 assert( varindex < nstaticvars);
2964 assert(staticvars[varindex] == GCGoriginalVarGetMastervars(origvar)[0]);
2965 stabredcosts[varindex] -= dualsol * consvals[j];
2966 }
2967 }
2968 SCIPfreeBufferArray(scip_, &consvars);
2969 }
2970
2971 /* add (redcost coefficients * lb/ub) of static variables to *stabdualval */
2972 for( i = 0; i < nstaticvars; ++i )
2973 {
2974 SCIP_Real stabredcost = stabredcosts[i];
2975 SCIP_VAR* staticvar = staticvars[i];
2976 SCIP_Real lb = SCIPvarGetLbLocal(staticvar);
2977 SCIP_Real ub = SCIPvarGetUbLocal(staticvar);
2978
2979 if( !SCIPisZero(scip_, stabredcost) || (!SCIPisInfinity(scip_, -lb) && !SCIPisInfinity(scip_, ub)) )
2980 boundval = stabredcost > 0.0 ? lb : ub;
2981 else if( !SCIPisInfinity(scip_, -lb) )
2982 boundval = lb;
2983 else if( !SCIPisInfinity(scip_, ub) )
2984 boundval = ub;
2985 else
2986 continue;
2987
2988#ifdef PRINTDUALSOLS
2989 if( !SCIPisZero(scip_, boundval * stabredcost) )
2990 {
2991 SCIPdebugMessage(" add %g (<%s>, stabredcosts: %g, bnds: [%g, %g])\n",
2992 boundval * stabredcost, SCIPvarGetName(staticvar), stabredcost, lb, ub);
2993 }
2994#endif
2995 *stabdualval += boundval * stabredcost;
2996 }
2997
2998 SCIPfreeBufferArray(scip_, &stabredcosts);
2999
3000 return SCIP_OKAY;
3001}
3002
3003/** creates a new master variable corresponding to the given solution and problem */
3005 PricingType* pricetype, /**< type of pricing */
3006 SCIP_SOL* sol, /**< solution to compute reduced cost for */
3007 SCIP_VAR** solvars, /**< array of variables with non-zero value in the solution of the pricing problem */
3008 SCIP_Real* solvals, /**< array of values in the solution of the pricing problem for variables in array solvars*/
3009 int nsolvars, /**< number of variables in array solvars */
3010 SCIP_Bool solisray, /**< is the solution a ray? */
3011 int prob, /**< number of the pricing problem the solution belongs to */
3012 SCIP_Bool force, /**< should the given variable be added also if it has non-negative reduced cost? */
3013 SCIP_Bool* added, /**< pointer to store whether the variable was successfully added */
3014 SCIP_VAR** addedvar /**< pointer to store the created variable */
3015 )
3016{
3017 char varname[SCIP_MAXSTRLEN];
3018
3019 SCIP_Real objcoeff;
3020 SCIP_VAR* newvar;
3021
3022 SCIP_Real objvalue;
3023 SCIP_Real redcost;
3024 int i;
3025
3026 assert(scip_ != NULL);
3027 assert(solvars != NULL || nsolvars == 0);
3028 assert(solvals != NULL || nsolvars == 0);
3029 assert(nsolvars >= 0);
3031 assert((pricetype == NULL) == (force));
3032 assert((pricetype == NULL) == (sol == NULL));
3033 if( addedvar != NULL )
3034 *addedvar = NULL;
3035
3036 objvalue = 0.0;
3037 redcost = 0.0;
3038
3039 if( !force )
3040 {
3041 /* compute the objective function value of the solution */
3042 redcost = computeRedCost(pricetype, sol, solisray, prob, &objvalue);
3043
3044 if( !SCIPisDualfeasNegative(scip_, redcost) )
3045 {
3046 SCIPdebugMessage("var with redcost %g (objvalue=%g, dualsol=%g, ray=%u) was not added\n", redcost, objvalue, pricerdata->dualsolconv[prob], solisray);
3047 *added = FALSE;
3048
3049 return SCIP_OKAY;
3050 }
3051 SCIPdebugMessage("found var with redcost %g (objvalue=%g, dualsol=%g, ray=%u)\n", redcost, objvalue, pricerdata->dualsolconv[prob], solisray);
3052 }
3053 else
3054 {
3055 SCIPdebugMessage("force var (objvalue=%g, dualsol=%g, ray=%u)\n", objvalue, pricerdata->dualsolconv[prob], solisray);
3056 }
3057
3058 *added = TRUE;
3059
3060 /* compute objective coefficient of the variable */
3061 objcoeff = 0;
3062 for( i = 0; i < nsolvars; i++ )
3063 {
3064 SCIP_Real solval;
3065 solval = solvals[i];
3066
3067 if( !SCIPisZero(scip_, solval) )
3068 {
3069 SCIP_VAR* origvar;
3070
3071 if( GCGvarIsInferredPricing(solvars[i]) )
3072 continue;
3073
3074 assert(GCGvarIsPricing(solvars[i]));
3075
3076 origvar = GCGpricingVarGetOrigvars(solvars[i])[0];
3077
3078 if( SCIPisZero(scip_, SCIPvarGetObj(origvar)) )
3079 continue;
3080
3081 /* original variable is linking variable --> directly transferred master variable got the full obj,
3082 * priced-in variables get no objective value for this origvar */
3083 if( GCGoriginalVarIsLinking(origvar) )
3084 continue;
3085
3086 /* round solval if possible to avoid numerical troubles */
3089
3090 /* add quota of original variable's objcoef to the master variable's coef */
3091 objcoeff += solval * SCIPvarGetObj(origvar);
3092 }
3093 }
3094
3095 if( SCIPisInfinity(scip_, objcoeff) )
3096 {
3097 SCIPwarningMessage(scip_, "variable with infinite objective value found in pricing, change objective to SCIPinfinity()/2\n");
3098 objcoeff = SCIPinfinity(scip_) / 2;
3099 }
3100
3101 if( solisray )
3102 {
3103 (void) SCIPsnprintf(varname, SCIP_MAXSTRLEN, "r_%d_%d", prob, pricerdata->nraysprob[prob]);
3104 pricerdata->nraysprob[prob]++;
3105 }
3106 else
3107 {
3108 (void) SCIPsnprintf(varname, SCIP_MAXSTRLEN, "p_%d_%d", prob, pricerdata->npointsprob[prob]);
3109 pricerdata->npointsprob[prob]++;
3110 }
3111
3112 SCIP_CALL( GCGcreateMasterVar(gcg, pricerdata->pricingprobs[prob], &newvar, varname, objcoeff,
3113 pricerdata->vartype, solisray, prob, nsolvars, solvals, solvars, FALSE));
3114
3115 SCIPvarMarkDeletable(newvar);
3116
3119
3120
3121 /* add variable */
3122 if( !force )
3123 {
3124 SCIP_CALL( SCIPaddPricedVar(scip_, newvar, pricerdata->dualsolconv[prob] - objvalue) );
3125 }
3126 else
3127 {
3128 SCIP_CALL( SCIPaddVar(scip_, newvar) );
3129 }
3130
3131 SCIP_CALL( addVariableToPricedvars(newvar) );
3132 SCIP_CALL( addVariableToMasterconstraints(newvar, prob, solvars, solvals, nsolvars) );
3133 SCIP_CALL( addVariableToOriginalSepaCuts(newvar, prob, solvars, solvals, nsolvars) );
3134 SCIP_CALL( addVariableToMastersepacuts(newvar, prob, solvars, solvals, nsolvars) );
3135 SCIP_CALL( addVariableToExtendedmastercons(newvar) );
3136
3137 /* add variable to convexity constraint */
3138 if( !solisray )
3139 {
3140 SCIP_CALL( SCIPaddCoefLinear(scip_, GCGgetConvCons(gcg, prob), newvar, 1.0) );
3141 }
3142
3143 if( addedvar != NULL )
3144 {
3145 *addedvar = newvar;
3146 }
3147
3148 GCGupdateVarStatistics(gcg, newvar, redcost);
3149
3150#ifdef SCIP_STATISTIC
3151 if( SCIPgetCurrentNode(scip_) == SCIPgetRootNode(scip_) && pricetype != NULL && pricetype->getType() == GCG_PRICETYPE_REDCOST )
3152 GCGsetRootRedcostCall(newvar, pricerdata->nrootbounds );
3153#else
3154 GCGsetRootRedcostCall(newvar, -1LL);
3155#endif
3156
3157 SCIPdebugMessage("Added variable <%s>\n", varname);
3158
3159 return SCIP_OKAY;
3160}
3161
3162/** creates a new master variable corresponding to the given gcg column */
3164 PricingType* pricetype, /**< type of pricing */
3165 GCG_COL* gcgcol, /**< GCG column data structure */
3166 SCIP_Bool force, /**< should the given variable be added also if it has non-negative reduced cost? */
3167 SCIP_Bool* added, /**< pointer to store whether the variable was successfully added */
3168 SCIP_VAR** addedvar, /**< pointer to store the created variable */
3169 SCIP_Real score /**< score of column (or -1.0 if not specified) */
3170 )
3171{
3172 char varname[SCIP_MAXSTRLEN];
3173
3174 SCIP_Real objcoeff;
3175 SCIP_VAR* newvar;
3176
3177 SCIP_Real redcost;
3178 SCIP_Bool isray;
3179 int prob;
3180 int i;
3181
3182 SCIP_VAR** solvars;
3183 SCIP_Real* solvals;
3184 int nsolvars;
3185
3187 assert(gcgcol != NULL);
3188 assert((pricetype == NULL) == (force));
3189
3190 if( addedvar != NULL )
3191 *addedvar = NULL;
3192
3193 redcost = 0.0;
3194
3195 prob = GCGcolGetProbNr(gcgcol);
3196 isray = GCGcolIsRay(gcgcol);
3197 nsolvars = GCGcolGetNVars(gcgcol);
3198 solvars = GCGcolGetVars(gcgcol);
3199 solvals = GCGcolGetVals(gcgcol);
3200
3201 if( !force )
3202 {
3203 /* compute the objective function value of the solution */
3204 redcost = GCGcolGetRedcost(gcgcol);
3205
3206 if( !SCIPisDualfeasNegative(scip_, redcost) )
3207 {
3208 SCIPdebugMessage(" var with redcost %g (dualsol=%g, ray=%u) was not added\n", redcost, pricerdata->dualsolconv[prob], isray);
3209 *added = FALSE;
3210
3211 return SCIP_OKAY;
3212 }
3213 SCIPdebugMessage(" found var with redcost %g (dualsol=%g, ray=%u)\n", redcost, pricerdata->dualsolconv[prob], isray);
3214 }
3215 else
3216 {
3217 SCIPdebugMessage(" force var (dualsol=%g, ray=%u)\n", pricerdata->dualsolconv[prob], isray);
3218 }
3219
3220 *added = TRUE;
3221
3222 /* compute objective coefficient of the variable */
3223 objcoeff = 0.0;
3224 for( i = 0; i < nsolvars; i++ )
3225 {
3226 SCIP_Real solval;
3227 solval = solvals[i];
3228
3229 if( !SCIPisZero(scip_, solval) )
3230 {
3231 SCIP_VAR* origvar;
3232
3233 assert(GCGvarIsPricing(solvars[i]));
3234 origvar = GCGpricingVarGetOrigvars(solvars[i])[0];
3235
3236 if( SCIPisZero(scip_, SCIPvarGetObj(origvar)) )
3237 continue;
3238
3239 /* original variable is linking variable --> directly transferred master variable got the full obj,
3240 * priced-in variables get no objective value for this origvar */
3241 if( GCGoriginalVarIsLinking(origvar) )
3242 continue;
3243
3244 /* add quota of original variable's objcoef to the master variable's coef */
3245 objcoeff += solval * SCIPvarGetObj(origvar);
3246 }
3247 }
3248
3249 if( SCIPisInfinity(scip_, objcoeff) )
3250 {
3251 SCIPwarningMessage(scip_, "variable with infinite objective value found in pricing, change objective to SCIPinfinity()/2\n");
3252 objcoeff = SCIPinfinity(scip_) / 2;
3253 }
3254
3255 if( isray )
3256 {
3257 (void) SCIPsnprintf(varname, SCIP_MAXSTRLEN, "r_%d_%d", prob, pricerdata->nraysprob[prob]);
3258 pricerdata->nraysprob[prob]++;
3259 }
3260 else
3261 {
3262 (void) SCIPsnprintf(varname, SCIP_MAXSTRLEN, "p_%d_%d", prob, pricerdata->npointsprob[prob]);
3263 pricerdata->npointsprob[prob]++;
3264 }
3265
3266 SCIP_CALL( GCGcreateMasterVar(gcg, pricerdata->pricingprobs[prob], &newvar, varname, objcoeff,
3267 pricerdata->vartype, isray, prob, nsolvars, solvals, solvars, FALSE));
3268
3269 SCIPvarMarkDeletable(newvar);
3270
3273
3274 if( SCIPisNegative(scip_, score) )
3275 score = pricerdata->dualsolconv[prob] - objcoeff;
3276
3277 /* add variable */
3278 if( !force )
3279 {
3280 SCIP_CALL( SCIPaddPricedVar(scip_, newvar, score /* pricerdata->dualsolconv[prob] - objvalue */ ) );
3281 }
3282 else
3283 {
3284 SCIP_CALL( SCIPaddVar(scip_, newvar) );
3285 }
3286
3287 SCIP_CALL( addVariableToPricedvars(newvar) );
3288 SCIP_CALL( addVariableToMasterconstraintsFromGCGCol(newvar, gcgcol) );
3289 SCIP_CALL( addVariableToOriginalSepaCutsFromGCGCol(newvar, gcgcol) );
3291 SCIP_CALL( addVariableToExtendedmastercons(newvar) );
3292
3293 /* add variable to convexity constraint */
3294 if( !isray )
3295 {
3296 SCIP_CALL( SCIPaddCoefLinear(scip_, GCGgetConvCons(gcg, prob), newvar, 1.0) );
3297 }
3298
3299 if( addedvar != NULL )
3300 {
3301 *addedvar = newvar;
3302 }
3303
3304 GCGupdateVarStatistics(gcg, newvar, redcost);
3305
3306#ifdef SCIP_STATISTIC
3308 GCGsetRootRedcostCall(newvar, pricerdata->nrootbounds );
3309#else
3310 GCGsetRootRedcostCall(newvar, -1LL);
3311#endif
3312
3313 SCIPdebugMessage(" added variable <%s>\n", varname);
3314
3315 return SCIP_OKAY;
3316}
3317
3318/**
3319 * check whether pricing can be aborted:
3320 * if objective value is always integral and the current node's current
3321 * lowerbound rounded up equals the current lp objective value rounded
3322 * up we don't need to continue pricing since the best possible feasible
3323 * solution must have at least this value
3324 */
3325SCIP_Bool ObjPricerGcg::canPricingBeAborted() const
3326{
3327 SCIP_Bool canabort = FALSE;
3328
3330
3333 {
3334 GCGpricerPrintInfo(scip_, pricerdata, "pricing aborted due to integral objective: node LB = %g, LP obj = %g\n",
3336
3337 canabort = TRUE;
3338 }
3339
3340 if( !canabort && pricerdata->abortpricinggap > 0.0 )
3341 {
3342 SCIP_Real gap;
3344 gap = ABS(gap);
3345
3346 if( gap < pricerdata->abortpricinggap )
3347 {
3348 GCGpricerPrintInfo(scip_, pricerdata, "pricing aborted due to small gap: node LB = %g, LP obj = %g, gap = %g\n",
3350
3351 canabort = TRUE;
3352 }
3353 }
3354
3355 return canabort;
3356}
3357
3358
3359/** free pricing problems */
3360SCIP_RETCODE ObjPricerGcg::freePricingProblems()
3361{
3362 int j;
3363 assert(pricerdata != NULL);
3364 assert(pricerdata->pricingprobs != NULL);
3365
3366 for( j = 0; j < pricerdata->npricingprobs; j++ )
3367 if( pricerdata->pricingprobs[j] != NULL
3368 && SCIPgetStage(pricerdata->pricingprobs[j]) > SCIP_STAGE_PROBLEM)
3369 {
3373 }
3374
3375 return SCIP_OKAY;
3376}
3377
3378/** add bounds change from constraint from the pricing problem at this node
3379 * @note This method has to be threadsafe!
3380 */
3381SCIP_RETCODE ObjPricerGcg::addBranchingBoundChangesToPricing(
3382 int prob, /**< index of pricing problem */
3383 SCIP_CONS* branchcons /**< branching constraints from which bound should applied */
3384) const
3385{
3386 GCG_BRANCHDATA* branchdata = GCGconsMasterbranchGetBranchdata(branchcons);
3387 GCG_COMPSEQUENCE* components = GCGbranchGenericBranchdataGetConsS(branchdata);
3388 int ncomponents = GCGbranchGenericBranchdataGetConsSsize(branchdata);
3389 int i;
3390
3391 assert(pricerdata != NULL);
3392
3393 for( i = 0; i < ncomponents; ++i)
3394 {
3395 SCIP_Real bound = components[i].bound;
3396 SCIP_VAR* var = GCGoriginalVarGetPricingVar(components[i].component);
3397 SCIP_Bool infeasible = FALSE;
3398 SCIP_Bool tightened = TRUE;
3399
3400 if( components[i].sense == GCG_COMPSENSE_GE )
3401 {
3402 SCIP_CALL( SCIPtightenVarLb(pricerdata->pricingprobs[prob], var, bound, TRUE, &infeasible, &tightened));
3403 SCIPdebugMessage("Added <%s> >= %.2f\n", SCIPvarGetName(var), bound);
3404 assert(infeasible || tightened || SCIPisGE(pricerdata->pricingprobs[prob], SCIPvarGetLbGlobal(var), bound));
3405 }
3406 else
3407 {
3408 SCIP_CALL( SCIPtightenVarUb(pricerdata->pricingprobs[prob], var, bound-1, TRUE, &infeasible, &tightened));
3409 SCIPdebugMessage("Added <%s> <= %.2f\n", SCIPvarGetName(var), bound-1);
3410 assert(infeasible || tightened || SCIPisLE(pricerdata->pricingprobs[prob], SCIPvarGetUbGlobal(var), bound-1));
3411 }
3412 }
3413
3414 return SCIP_OKAY;
3415}
3416
3417/** check bounds change from constraint from the pricing problem at this node
3418 * @note This method has to be threadsafe!
3419 */
3420SCIP_RETCODE ObjPricerGcg::checkBranchingBoundChanges(
3421 int prob, /**< index of pricing problem */
3422 SCIP_SOL* sol, /**< solution to check */
3423 SCIP_CONS* branchcons, /**< branching constraints from which bound should applied */
3424 SCIP_Bool* feasible /**< check whether the solution is feasible */
3425) const
3426{
3427 GCG_BRANCHDATA* branchdata = GCGconsMasterbranchGetBranchdata(branchcons);
3428 GCG_COMPSEQUENCE* components = GCGbranchGenericBranchdataGetConsS(branchdata);
3429 int ncomponents = GCGbranchGenericBranchdataGetConsSsize(branchdata);
3430 int i;
3431
3432 assert(pricerdata != NULL);
3433
3434 for( i = 0; i < ncomponents; ++i)
3435 {
3436 SCIP_VAR* pricingvar = GCGoriginalVarGetPricingVar(components[i].component);
3437 SCIP_Real val = SCIPgetSolVal(pricerdata->pricingprobs[prob], sol, pricingvar);
3438
3439 if( components[i].sense == GCG_COMPSENSE_GE )
3440 {
3441 *feasible = SCIPisFeasGE(pricerdata->pricingprobs[prob], val, components[i].bound);
3442 SCIPdebugMessage("<%s> %.4f >= %.4f\n", SCIPvarGetName(pricingvar), val, components[i].bound);
3443 }
3444 else
3445 {
3446 *feasible = SCIPisFeasLT(pricerdata->pricingprobs[prob], val, components[i].bound);
3447 SCIPdebugMessage("<%s> %.4f < %.4f\n", SCIPvarGetName(pricingvar), val, components[i].bound);
3448 }
3449 if( !*feasible )
3450 break;
3451 }
3452
3453 return SCIP_OKAY;
3454}
3455
3456
3457/** check bounds change from constraint from the pricing problem at this node
3458 * @note This method has to be threadsafe!
3459 */
3460SCIP_RETCODE ObjPricerGcg::checkBranchingBoundChangesGcgCol(
3461 GCG_COL* gcgcol, /**< gcg column to check */
3462 SCIP_CONS* branchcons, /**< branching constraints from which bound should applied */
3463 SCIP_Bool* feasible /**< check whether the solution is feasible */
3464) const
3465{
3466 int prob = GCGcolGetProbNr(gcgcol);
3467 GCG_BRANCHDATA* branchdata = GCGconsMasterbranchGetBranchdata(branchcons);
3468 GCG_COMPSEQUENCE* components = GCGbranchGenericBranchdataGetConsS(branchdata);
3469 int ncomponents = GCGbranchGenericBranchdataGetConsSsize(branchdata);
3470 int i;
3471
3472 assert(pricerdata != NULL);
3473
3474 for( i = 0; i < ncomponents; ++i)
3475 {
3476 SCIP_VAR* pricingvar = GCGoriginalVarGetPricingVar(components[i].component);
3477
3478 SCIP_Real val = GCGcolGetSolVal(gcgcol, pricingvar);
3479
3480 if( components[i].sense == GCG_COMPSENSE_GE )
3481 {
3482 *feasible = SCIPisFeasGE(pricerdata->pricingprobs[prob], val, components[i].bound);
3483/* SCIPdebugMessage("<%s> %.4f >= %.4f\n", SCIPvarGetName(pricingvar), val, components[i].bound); */
3484 }
3485 else
3486 {
3487 *feasible = SCIPisFeasLT(pricerdata->pricingprobs[prob], val, components[i].bound);
3488/* SCIPdebugMessage("<%s> %.4f < %.4f\n", SCIPvarGetName(pricingvar), val, components[i].bound); */
3489 }
3490 if( !*feasible )
3491 break;
3492 }
3493
3494 return SCIP_OKAY;
3495}
3496
3497
3498/** perform a pricing job, i.e. apply the corresponding solver to the pricing problem
3499 * @note This method has to be threadsafe!
3500 */
3501SCIP_RETCODE ObjPricerGcg::performPricingjob(
3502 GCG_PRICINGJOB* pricingjob, /**< pricing job */
3503 PricingType* pricetype, /**< type of pricing: reduced cost or Farkas */
3504 GCG_PRICINGSTATUS* status, /**< pointer to store pricing status */
3505 SCIP_Real* lowerbound /**< pointer to store the obtained lower bound */
3506 )
3507{
3508 GCG_PRICINGPROB* pricingprob;
3509 SCIP* pricingscip;
3510 int probnr;
3511 GCG_SOLVER* solver;
3512 SCIP_Bool heuristic;
3513 SCIP_Bool solved;
3514 SCIP_Bool solverchanged;
3515 SCIP_Bool varbndschanged;
3516 SCIP_Bool branchconsschanged = FALSE;
3517
3518 pricingprob = GCGpricingjobGetPricingprob(pricingjob);
3519 assert(pricingprob != NULL);
3520
3521 probnr = GCGpricingprobGetProbnr(pricingprob);
3522
3523 pricingscip = GCGpricingprobGetPricingscip(pricingprob);
3524 assert(pricingscip != NULL);
3525
3526 solver = GCGpricingjobGetSolver(pricingjob);
3527 assert(solver != NULL);
3528
3529 heuristic = GCGpricingjobIsHeuristic(pricingjob);
3530
3531 // @todo: this should be done by the pricing solvers
3532 // @todo: has to consider #threads
3533 SCIP_CALL( setPricingProblemMemorylimit(pricingscip) );
3534
3535 solverchanged = GCGpricingjobSolverChanged(pricingjob);
3536
3537 /* add the next generic branching constraint if necessary */
3538 if( !GCGpricingprobBranchconsIsAdded(pricingprob) )
3539 {
3540 SCIP_CONS** branchconss;
3541 int nbranchconss;
3542 int branchconsidx;
3543
3544 GCGpricingprobGetGenericBranchData(pricingprob, &branchconss, NULL, &nbranchconss);
3545 branchconsidx = GCGpricingprobGetBranchconsIdx(pricingprob);
3546 assert(branchconsidx >= 0);
3547 assert(branchconsidx < nbranchconss);
3548
3549 if( SCIPgetStage(pricingscip) >= SCIP_STAGE_TRANSFORMED )
3550 SCIP_CALL( SCIPfreeTransform(pricingscip) );
3551
3552 SCIPdebugMessage("*** Apply generic branching bound change of depth %d\n", -branchconsidx);
3553 SCIP_CALL( SCIPtransformProb(pricingscip) );
3554 SCIP_CALL( addBranchingBoundChangesToPricing(probnr, branchconss[branchconsidx]) );
3555
3557 varbndschanged = TRUE;
3558 }
3559 else
3560 {
3561 varbndschanged = solverchanged &&
3564 }
3565
3566 branchconsschanged = solverchanged && pricerdata->npricingloopiters <= 1;
3567
3568 /* call update method of pricing solvers */
3569 SCIP_CALL( GCGsolverUpdate(gcg, pricingscip, solver, probnr, solverchanged, varbndschanged, branchconsschanged) );
3570
3571 SCIP_CALL( GCGsolverSolve(gcg, pricingscip, solver, pricetype->getType() == GCG_PRICETYPE_REDCOST,
3572 heuristic, probnr, pricerdata->dualsolconv[probnr], lowerbound, status, &solved) );
3573
3574 GCGpricingjobSolverCalled(pricingjob);
3575
3576 if( solved == FALSE )
3577 return SCIP_OKAY;
3578
3579 if( heuristic == FALSE )
3580 {
3581 #pragma omp atomic update
3583 }
3584 else
3585 {
3586 #pragma omp atomic update
3588 }
3589
3590#ifdef SCIP_STATISTIC
3591 GCGpricerCollectStatistic(pricerdata, pricetype->getType(), probnr, SCIPgetSolvingTime(pricingscip));
3592#endif
3593 /* @todo: This should actually be a MIP solver specific statistic */
3594 if( SCIPgetStage(pricingscip) > SCIP_STAGE_SOLVING )
3595 {
3596 #pragma omp atomic update
3598 }
3599
3600 return SCIP_OKAY;
3601}
3602
3603
3604/* Compute difference of two dual solutions */
3606 SCIP_Real** dualvals1, /**< array of dual values for each pricing problem */
3607 SCIP_Real* dualconv1, /**< array of dual solutions for the convexity constraints */
3608 SCIP_Real** dualvals2, /**< array of dual values for each pricing problem */
3609 SCIP_Real* dualconv2, /**< array of dual solutions for the convexity constraints */
3610 SCIP_Real* dualdiff /**< pointer to store difference of duals solutions */
3611 )
3612{
3613 int i;
3614 int j;
3615 int nprobvars;
3616
3617 *dualdiff = 0.0;
3618 for( i = 0; i < pricerdata->npricingprobs; i++ )
3619 {
3620 if( pricerdata->pricingprobs[i] == NULL )
3621 continue;
3622
3623 nprobvars = SCIPgetNVars(pricerdata->pricingprobs[i]);
3624
3625 for( j = 0; j < nprobvars; j++ )
3626 {
3627 *dualdiff += SQR(dualvals1[i][j] - dualvals2[i][j]);
3628 }
3629
3630 *dualdiff += SQR(dualconv1[i] - dualconv2[i]);
3631
3632 }
3633 *dualdiff = sqrt(ABS(*dualdiff));
3634
3635 return SCIP_OKAY;
3636}
3637
3638/** the pricing loop: solve the pricing problems */
3640 PricingType* pricetype, /**< type of pricing */
3641 SCIP_RESULT* result, /**< result pointer */
3642 int* pnfoundvars, /**< pointer to store number of found variables */
3643 SCIP_Real* lowerbound, /**< pointer to store lowerbound obtained due to lagrange bound */
3644 SCIP_Bool* bestredcostvalid /**< pointer to store if bestredcost are valid (pp solvedoptimal) */
3645 )
3646{
3647 GCG_COL** bestcols = NULL;
3648 SCIP_LPI* lpi = NULL;
3649 SCIP_Real* bestobjvals = NULL;
3650 SCIP_Real bestredcost;
3651 SCIP_Real beststabobj;
3653 SCIP_Bool infeasible;
3654 SCIP_Bool nextchunk = TRUE;
3655 SCIP_Bool stabilized;
3656 SCIP_Bool colpoolupdated;
3657 SCIP_Bool enableppcuts;
3658 SCIP_Bool enablestab;
3659 int nsuccessfulprobs;
3660 int i;
3661 int j;
3662 int nfoundvars;
3663 SCIP_Bool optimal;
3664 bool probingnode;
3665 int nthreads;
3666 GCG_BRANCHRULE** branchrules;
3667 GCG_BRANCHDATA** branchdata;
3668 GCG_EXTENDEDMASTERCONSDATA** branchextendedmasterconsdata;
3669 int nbranchextendedmasterconss;
3670
3671 /* master separator cuts */
3672 GCG_EXTENDEDMASTERCONSDATA** activecuts;
3673 int nactivecuts;
3674
3675#ifdef SCIP_STATISTIC
3676 SCIP_Real** olddualvalues;
3677 SCIP_Real* olddualconv;
3678
3679 SCIP_VAR** probvars;
3680 int nprobvars;
3681 int nstabrounds;
3682#endif
3683
3685 assert(stabilization != NULL);
3686 assert(farkaspricing != NULL);
3687 assert(reducedcostpricing != NULL);
3688
3689 assert(result != NULL);
3690 assert(pnfoundvars != NULL);
3691
3692 /* initializations */
3694 *pnfoundvars = 0;
3695 nfoundvars = 0;
3696 infeasible = FALSE;
3697 stabilized = FALSE;
3698 optimal = FALSE;
3699 if( lowerbound != NULL )
3700 *lowerbound = -SCIPinfinity(scip_);
3701
3702 SCIP_CALL( GCGrelaxBranchGetAllActiveExtendedMasterConss(gcg, &branchrules, &branchdata, &branchextendedmasterconsdata, &nbranchextendedmasterconss) );
3703 assert(nbranchextendedmasterconss == 0 || (branchrules != NULL && branchdata != NULL && branchextendedmasterconsdata != NULL));
3704
3705 activecuts = GCGgetActiveMastersepacuts(gcg);
3706 nactivecuts = GCGgetNActiveMastersepacuts(gcg);
3707
3708 // disable colpool while probing mode is active (can be removed after a feasibility check (#586) is implemented)
3710
3711 SCIP_CALL( SCIPgetLPI(scip_, &lpi) );
3712
3713 /* check preliminary conditions for stabilization */
3714 enablestab = pricerdata->stabilization
3716 && (pricerdata->stabilization && pricetype->getType() == GCG_PRICETYPE_REDCOST)
3718
3719 /* allocate memory */
3722
3723 enableppcuts = FALSE;
3724 SCIP_CALL( SCIPgetBoolParam(origprob, "sepa/basis/enableppcuts", &enableppcuts) );
3725 /* set parameters for adding pool cuts to separation basis */
3726 if( enableppcuts && SCIPgetCurrentNode(scip_) != SCIPgetRootNode(scip_) )
3727 {
3728 for( i = 0; i < pricerdata->npricingprobs; i++ )
3729 {
3731 {
3732 SCIP_CALL( SCIPsetIntParam(pricerdata->pricingprobs[i], "branching/pscost/priority", 2000) );
3733 SCIP_CALL( SCIPsetIntParam(pricerdata->pricingprobs[i], "propagating/maxroundsroot", 1000) );
3735 }
3736 }
3737 }
3738
3739 /* todo: We avoid checking for feasibility of the columns using this hack */
3740 if( pricerdata->usecolpool && !probingnode )
3742
3743 colpoolupdated = FALSE;
3744
3745#ifdef SCIP_STATISTIC
3746 if( pricerdata->nroundsredcost > 0 && pricetype->getType() == GCG_PRICETYPE_REDCOST )
3747 {
3748 int idx;
3751
3752 for( i = 0; i < pricerdata->npricingprobs; i++ )
3753 {
3754 if( pricerdata->pricingprobs[i] == NULL )
3755 continue;
3756
3757 probvars = SCIPgetVars(pricerdata->pricingprobs[i]);
3758 nprobvars = SCIPgetNVars(pricerdata->pricingprobs[i]);
3759
3760 olddualconv[i] = pricerdata->dualsolconv[i];
3761 SCIP_CALL( SCIPallocBufferArray(scip_, &(olddualvalues[i]), nprobvars) );
3762
3763 for( j = 0; j < nprobvars; j++ )
3764 {
3765 idx = SCIPvarGetIndex(probvars[j]);
3766 olddualvalues[i][idx] = pricerdata->realdualvalues[i][idx];
3767 }
3768 }
3769 }
3770
3773 nstabrounds = 0;
3774#endif
3775
3776 SCIPdebugMessage("***** New pricing round at node %" SCIP_LONGINT_FORMAT " (depth = %d)\n",
3778
3779#ifdef _OPENMP
3780 if( pricerdata->maxnthreads > 0 )
3781 nthreads = MIN(pricerdata->maxnthreads, GCGgetNRelPricingprobs(gcg));
3782 else
3783 nthreads = MIN(omp_get_max_threads(), GCGgetNRelPricingprobs(gcg));
3784#else
3785 nthreads = 1;
3786#endif
3787
3788 /* apply the inferred pricing modifications from the extended master cons */
3789 for( i = 0; i < nbranchextendedmasterconss; ++i )
3790 {
3791 SCIP_Bool apply = !SCIPisZero(scip_, pricingtype->extendedmasterconsGetDual(branchextendedmasterconsdata[i]))
3792 && (!enablestab || !stabilization->hasStabilityCenter() || !SCIPisZero(scip_, stabilization->branchmasterconsGetStabCenter(i)));
3793 assert(GCGextendedmasterconsIsActive(branchextendedmasterconsdata[i]));
3794 SCIP_CALL( activatePricingModifications(branchextendedmasterconsdata[i], apply) );
3795 }
3796
3797 /* master separator cuts: modify pricing problems for active master cuts */
3798 for( i = 0; i < nactivecuts; i++ )
3799 {
3800 SCIP_Bool apply = !SCIPisZero(scip_, pricingtype->extendedmasterconsGetDual(activecuts[i])); // && (!enablestab || !SCIPisZero(scip_, @todo));
3801 SCIPdebugMessage("cut dual %.10g\n", pricingtype->extendedmasterconsGetDual(activecuts[i]));
3803 SCIP_CALL( activatePricingModifications(activecuts[i], apply) );
3804 }
3805
3807
3808 /* stabilization loop */
3809 do
3810 {
3811 optimal = FALSE;
3812#ifndef NDEBUG
3813 if( nextchunk )
3814 {
3815 SCIPdebugMessage("*** get next chunk of pricing problems\n");
3816 }
3817#endif
3818
3819 nsuccessfulprobs = 0;
3821 nextchunk = FALSE;
3823
3824 if( stabilized )
3825 {
3826 SCIPdebugMessage("****************************** Mispricing iteration ******************************\n");
3827#ifdef SCIP_STATISTIC
3828 ++nstabrounds;
3829 SCIPstatisticMessage("Sr %d\n", nstabrounds);
3830#endif
3831 }
3832
3833 /* initialize stabilization parameters if we are at a new node */
3834 if( enablestab )
3835 {
3836 stabilization->updateNode();
3837 SCIP_CALL( stabilization->updateHybrid() );
3838 }
3839
3840 stabilized = enablestab && stabilization->isStabilized();
3841
3842 SCIP_CALL( freePricingProblems() );
3843
3844 /* set the objective function */
3845 SCIP_CALL( setPricingObjs(pricetype, stabilized) );
3846
3847 /* todo: do this inside the updateRedcostColumnPool */
3848 if( !colpoolupdated && pricerdata->usecolpool && !probingnode )
3849 {
3850 /* update reduced cost of cols in colpool */
3852
3853 colpoolupdated = TRUE;
3854 }
3855
3856 /* check if colpool already contains columns with negative reduced cost */
3857 if( pricerdata->usecolpool && !probingnode )
3858 {
3859 int nfoundvarscolpool;
3860
3861 SCIP_CALL( GCGcolpoolPrice(colpool, NULL, &nfoundvarscolpool) );
3862 SCIPstatisticMessage("cp: %d impr c\n", nfoundvarscolpool);
3863
3864 if( nfoundvarscolpool > 0 )
3865 {
3866 SCIPdebugMessage("*** Found column(s) with negative reduced cost in column pool\n");
3868 break;
3869 }
3870 }
3871
3872 pricingcontroller->setupPriorityQueue(pricerdata->dualsolconv);
3873
3874 assert(!infeasible);
3875 /* actual pricing loop: perform the pricing jobs until none are left or an abortion criterion is met */
3876 #pragma omp parallel default(none) shared(nthreads, retcode, pricetype, nfoundvars, nsuccessfulprobs, stabilized) num_threads(nthreads)
3877 #pragma omp single
3878 for( int t = 0; t < nthreads; ++t)
3879 {
3880 #pragma omp task default(none) shared(retcode, pricetype, nfoundvars, nsuccessfulprobs, stabilized)
3881 while( TRUE )
3882 {
3883 GCG_PRICINGJOB* pricingjob;
3884 GCG_PRICINGPROB* pricingprob;
3885 GCG_PRICINGSTATUS status;
3886 SCIP_Real problowerbound;
3887 SCIP_RETCODE private_retcode;
3888 int pricingprobnr;
3889 int impcols;
3890 int oldimpcols;
3891 int _nfoundvars;
3892 int _nsuccessfulprobs;
3893#ifdef SCIP_STATISTIC
3894 SCIP_Real pricingtime;
3895#endif
3896
3897 #pragma omp atomic read
3898 private_retcode = retcode;
3899
3900 if( private_retcode != SCIP_OKAY )
3901 break;
3902
3903 #pragma omp atomic read
3904 _nfoundvars = nfoundvars;
3905 #pragma omp atomic read
3906 _nsuccessfulprobs = nsuccessfulprobs;
3907 if( pricingcontroller->canPricingloopBeAborted(pricetype, _nfoundvars, _nsuccessfulprobs) && !stabilized )
3908 {
3909#ifdef SCIP_DEBUG
3910 GCG_SET_LOCK(&pricerdata->locks->printlock);
3911 SCIPdebugMessage("*** Abort pricing loop, stabilized = %u\n", stabilized);
3912 GCG_UNSET_LOCK(&pricerdata->locks->printlock);
3913#endif
3914 break;
3915 }
3916
3917 /* retrieve the next pricing job from the queue */
3918 GCG_SET_LOCK(&pricerdata->locks->pricinglock);
3919 pricingjob = pricingcontroller->getNextPricingjob();
3920 GCG_UNSET_LOCK(&pricerdata->locks->pricinglock);
3921
3922 if( pricingjob == NULL )
3923 break;
3924
3925 /* initializations */
3926 pricingprob = GCGpricingjobGetPricingprob(pricingjob);
3927 pricingprobnr = GCGpricingprobGetProbnr(pricingprob);
3928 oldimpcols = pricerdata->nefficaciouscols[pricingprobnr];
3930 problowerbound = -SCIPinfinity(scip_);
3931
3932#ifdef SCIP_DEBUG
3933 GCG_SET_LOCK(&pricerdata->locks->printlock);
3934 SCIPdebugMessage("*** Solve solving pricing problem %d, solver <%s>, stabilized = %u, %s\n",
3935 pricingprobnr, GCGsolverGetName(GCGpricingjobGetSolver(pricingjob)), stabilized,
3936 GCGpricingjobIsHeuristic(pricingjob) ? "heuristic" : "exact");
3937 GCG_UNSET_LOCK(&pricerdata->locks->printlock);
3938#endif
3939
3940 /* @todo: this should be done by the pricing solvers */
3941 GCG_SET_LOCK(&pricerdata->locks->pricinglimitslock);
3942 SCIP_CALL_ABORT( pricingcontroller->setPricingjobTimelimit(pricingjob) );
3943 GCG_UNSET_LOCK(&pricerdata->locks->pricinglimitslock);
3944
3945#ifdef SCIP_STATISTIC
3946 /* @todo: this can interfere with parallelization */
3947 pricingtime = pricetype->getClockTime();
3948#endif
3949
3950 /* solve the pricing problem */
3951 private_retcode = performPricingjob(pricingjob, pricetype, &status, &problowerbound);
3952
3953#ifdef SCIP_STATISTIC
3954 pricingtime = pricetype->getClockTime() - pricingtime;
3955#endif
3956
3957 impcols = pricerdata->nefficaciouscols[pricingprobnr] - oldimpcols;
3958
3959#ifdef SCIP_DEBUG
3960 GCG_SET_LOCK(&pricerdata->locks->printlock);
3961 SCIPdebugMessage("*** Finished solving pricing problem %d, solver <%s>, stabilized = %u, %s\n",
3962 pricingprobnr, GCGsolverGetName(GCGpricingjobGetSolver(pricingjob)), stabilized,
3963 GCGpricingjobIsHeuristic(pricingjob) ? "heuristic" : "exact");
3964 SCIPdebugMessage(" -> status: %d\n", status);
3965 SCIPdebugMessage(" -> problowerbound: %.8g\n", problowerbound);
3966 SCIPdebugMessage(" -> #impcols: %d\n", impcols);
3967 GCG_UNSET_LOCK(&pricerdata->locks->printlock);
3968#endif
3969
3970 /* update pricing problem results */
3971 pricingcontroller->updatePricingprob(pricingprob, status, problowerbound, impcols);
3972
3973 /* update solving statistics, needed for checking the abortion criterion */
3974 if( private_retcode != SCIP_OKAY )
3975 {
3976 #pragma omp atomic write
3977 retcode = private_retcode; // @todo: handle return code correctly
3978 }
3979
3980 #pragma omp atomic update
3981 nfoundvars += impcols;
3982
3983 if( oldimpcols == 0 && impcols > 0 )
3984 {
3985 #pragma omp atomic update
3986 ++nsuccessfulprobs;
3987 }
3988
3989#ifdef SCIP_STATISTIC
3990 if( status != GCG_PRICINGSTATUS_NOTAPPLICABLE )
3991 {
3992 GCG_SET_LOCK(&pricerdata->locks->printlock);
3993 SCIPstatisticMessage("P p %d : %d in %g\n",
3994 pricingprobnr, impcols, pricingtime);
3995 GCG_UNSET_LOCK(&pricerdata->locks->printlock);
3996 }
3997 #endif
3998
3999 pricingcontroller->evaluatePricingjob(pricingjob, status);
4000 }
4001 }
4002
4003 SCIP_CALL( retcode );
4004
4005 /* collect results from all performed pricing jobs */
4006 getBestCols(bestcols);
4007 pricingcontroller->collectResults(bestcols, pricerdata->dualsolconv, stabilized, &infeasible, &optimal, bestobjvals, &beststabobj, &bestredcost, bestredcostvalid);
4008
4009 if( infeasible )
4010 break;
4011
4012 SCIPdebugMessage("optimal = %u, bestredcostvalid = %u, stabilized = %u\n", optimal, *bestredcostvalid, stabilized);
4013
4014 /* update stabilization information and lower bound */
4015 if( pricetype->getType() == GCG_PRICETYPE_REDCOST )
4016 {
4017 SCIP_Real lowerboundcandidate;
4018 SCIP_Real stabdualval = 0.0;
4019
4020 assert(lowerbound != NULL);
4021
4022 SCIP_CALL( getStabilizedDualObjectiveValue(pricetype, &stabdualval, stabilized) );
4023
4024 SCIPdebugMessage("lpobjval = %.10g, bestredcost = %.10g, stabdualval = %.10g, beststabobj = %.10g\n",
4025 SCIPgetSolOrigObj(scip_, NULL), bestredcost, stabdualval, beststabobj);
4026
4027#ifndef NDEBUG
4028 if( optimal && *bestredcostvalid && !stabilized &&
4030 !SCIPisSumEQ(scip_, SCIPgetSolOrigObj(scip_, NULL) + bestredcost, stabdualval + beststabobj) )
4031 {
4032 SCIP_ROW** rows = SCIPgetLPRows(scip_);
4033 int nrows = SCIPgetNLPRows(scip_);
4034 SCIP_Real dualobj = 0.0;
4035 SCIP_Real dualconvoffset = 0.0;
4036
4037 SCIPdebugMessage("Check result of getStabilizedDualObjectiveValue() ...\n");
4038 for( int r = 0; r < nrows; ++r )
4039 {
4040 SCIP_ROW* row = rows[r];
4041 if( !SCIProwIsInLP(row) )
4042 continue;
4043 SCIP_Real dualsol = SCIProwGetDualsol(row);
4044 SCIP_Real tmp = 0.0;
4045 if( !SCIPisZero(scip_, dualsol) || (!SCIPisInfinity(scip_, -SCIProwGetLhs(row)) && !SCIPisInfinity(scip_, SCIProwGetRhs(row))) )
4046 tmp = dualsol * (dualsol > 0 ? SCIProwGetLhs(row) : SCIProwGetRhs(row));
4047 else if( !SCIPisInfinity(scip_, -SCIProwGetLhs(row)) )
4048 tmp = dualsol * SCIProwGetLhs(row);
4049 else if( !SCIPisInfinity(scip_, SCIProwGetRhs(row)) )
4050 tmp = dualsol * SCIProwGetRhs(row);
4051 if( !SCIPisZero(scip_, tmp) )
4052 {
4053 SCIPdebugMessage(" <%s>, dualsol %.8g, bnds [%.8g, %.8g] -> %.10g\n", SCIProwGetName(row), dualsol, SCIProwGetLhs(row), SCIProwGetRhs(row), tmp);
4054 dualobj += tmp;
4055 }
4056 }
4057
4058 SCIP_COL** cols = SCIPgetLPCols(scip_);
4059 int ncols = SCIPgetNLPCols(scip_);
4060 for( int c = 0; c < ncols; ++c )
4061 {
4062 SCIP_COL* col = cols[c];
4063 if( !SCIPcolIsInLP(col) )
4064 continue;
4065 SCIP_Real redcost = SCIPgetColRedcost(scip_, col);
4066 SCIP_Real tmp = 0.0;
4067 if( !SCIPisZero(scip_, redcost) || (!SCIPisInfinity(scip_, -SCIPcolGetLb(col)) && !SCIPisInfinity(scip_, SCIPcolGetUb(col))) )
4068 tmp = redcost * (redcost >= 0 ? SCIPcolGetLb(col) : SCIPcolGetUb(col));
4069 else if( !SCIPisInfinity(scip_, -SCIPcolGetLb(col)) )
4070 tmp = redcost * SCIPcolGetLb(col);
4071 else if( !SCIPisInfinity(scip_, SCIPcolGetUb(col)) )
4072 tmp = redcost * SCIPcolGetUb(col);
4073 if( !SCIPisZero(scip_, tmp) )
4074 {
4075 SCIPdebugMessage(" <%s>, redcost %.8g, bnds [%.8g, %.8g] -> %.10g\n", SCIPvarGetName(SCIPcolGetVar(col)), redcost, SCIPcolGetLb(col), SCIPcolGetUb(col), tmp);
4076 dualobj += tmp;
4077 }
4078 }
4079 SCIPdebugMessage(" -> dualobj %.10g\n", dualobj);
4080
4081 /* getStabilizedDualObjectiveValue() does not include the dual solutions associated with the convexity constraints.
4082 * This works since they are also not included in 'beststabobj' and we are only interested in the sum 'stabdualval + beststabobj'
4083 */
4084 for( int p = 0; p < pricerdata->npricingprobs; p++ )
4085 {
4086 SCIP_CONS* convcons = GCGgetConvCons(gcg, p);
4087
4088 if( convcons != NULL )
4089 dualconvoffset += GCGconsGetRhs(scip_, convcons) * pricetype->consGetDual(convcons);
4090 }
4091 SCIPdebugMessage(" offset caused by convexity constraints: %.10g\n", dualconvoffset);
4092
4093 assert(SCIPisDualfeasEQ(scip_, SCIPretransformObj(scip_, dualobj), stabdualval + dualconvoffset));
4094 }
4095#endif
4096
4097 assert(!optimal || !*bestredcostvalid || stabilized ||
4099 SCIPisSumEQ(scip_, SCIPgetSolOrigObj(scip_, NULL) + bestredcost, stabdualval + beststabobj));
4100
4101 if( stabilized || !optimal || !*bestredcostvalid )
4102 lowerboundcandidate = SCIPtransformObj(scip_, stabdualval + beststabobj);
4103 else
4104 lowerboundcandidate = SCIPgetLPObjval(scip_) + bestredcost;
4105
4106 SCIPdebugMessage("lowerboundcandidate = %.8g\n", lowerboundcandidate);
4107
4108 if( enablestab )
4109 {
4110 SCIP_Real beststabredcost = beststabobj - getDualconvsum(bestcols);
4111
4112 SCIPdebugMessage("beststabredcost = %.8g\n", beststabredcost);
4113
4114 /* If all pricing problems have been solved to optimality, update subgradient product and stability center */
4115 if( optimal )
4116 {
4117 SCIPdebugMessage("update subgradient product and stability center\n");
4118
4119 /* update subgradient product before a potential change of the stability center */
4120 SCIP_CALL( stabilization->updateSubgradientProduct(bestcols) );
4121 SCIP_CALL( stabilization->updateStabilityCenter(lowerboundcandidate, bestobjvals, bestcols) );
4122 }
4123
4124 /* activate or deactivate mispricing schedule, depending on whether improving columns have been found */
4125 if( nfoundvars == 0 )
4126 {
4127 if( stabilized )
4128 {
4129 SCIPdebugMessage("enabling mispricing schedule\n");
4130 stabilization->activateMispricingSchedule();
4131 stabilization->updateAlphaMisprice();
4132 }
4133 else
4134 stabilization->disablingMispricingSchedule();
4135 }
4136 else if( *bestredcostvalid && SCIPisDualfeasNegative(scip_, beststabredcost) )
4137 {
4138 if( stabilization->isInMispricingSchedule() )
4139 stabilization->disablingMispricingSchedule();
4140 stabilization->updateAlpha();
4141 }
4142 }
4143
4144 if( *bestredcostvalid )
4145 {
4146 SCIP_Bool enableppobjcg;
4147
4148 *lowerbound = MAX(*lowerbound, lowerboundcandidate);
4149
4150 /* add cuts based on the latest pricing problem objective to the original problem */
4151 SCIP_CALL( SCIPgetBoolParam(origprob, "sepa/basis/enableppobjcg", &enableppobjcg) );
4152 if( enableppobjcg && SCIPgetCurrentNode(scip_) == SCIPgetRootNode(scip_) )
4153 {
4154 for( i = 0; i < pricerdata->npricingprobs; ++i )
4155 {
4157 continue;
4158
4159 SCIP_CALL( SCIPsepaBasisAddPPObjConss(gcg, i, bestobjvals[i], TRUE) );
4160 }
4161 }
4162 }
4163 }
4164
4165 /* if no column has negative reduced cost, consider the next chunk of pricing problems */
4166 if( nfoundvars == 0 && !stabilized )
4167 nextchunk = pricingcontroller->checkNextChunk();
4168
4169 /** @todo perhaps solve remaining pricing problems, if only few left? */
4170 /** @todo solve all pricing problems all k iterations? */
4171 }
4172 while( !SCIPisStopped(scip_) && (nextchunk || (stabilized && nfoundvars == 0)) );
4173
4174 SCIPdebugMessage("*** Pricing loop finished, found %d improving columns.\n", nfoundvars);
4175
4176 /* Add new columns as variables to the master problem or move them to the column pool */
4177 SCIP_CALL( GCGpricestoreApplyCols(pricestore, colpool, (pricerdata->usecolpool && !probingnode), &nfoundvars) );
4178 for( j = 0; j < pricerdata->npricingprobs; j++ )
4179 {
4181 }
4182
4183 SCIPdebugMessage("Added %d new variables.\n", nfoundvars);
4184
4187
4188 enableppcuts = FALSE;
4189 SCIP_CALL( SCIPgetBoolParam(origprob, "sepa/basis/enableppcuts", &enableppcuts) );
4190
4191 /* add pool cuts to sepa basis */
4192 if( enableppcuts && SCIPgetCurrentNode(scip_) == SCIPgetRootNode(scip_) )
4193 {
4194 for( j = 0; j < pricerdata->npricingprobs; j++ )
4195 {
4196 if( pricerdata->pricingprobs[j] != NULL
4198 {
4199 SCIP_CUT** cuts;
4200 int ncuts;
4201
4204
4205 for( i = 0; i < ncuts; ++i )
4206 {
4207 SCIP_ROW* row;
4208 row = SCIPcutGetRow(cuts[i]);
4209
4210 if( !SCIProwIsLocal(row) && SCIProwGetRank(row) >= 1 && nfoundvars == 0 )
4212 }
4213 }
4214 }
4215 }
4216
4217#ifdef SCIP_STATISTIC
4219#endif
4220
4221 /* free the pricingproblems if they exist and need to be freed */
4222 // @todo: actually, only the transformed problems are freed
4223 SCIP_CALL( freePricingProblems() );
4224 *pnfoundvars = nfoundvars;
4225
4226 if( infeasible )
4228 else if( *pnfoundvars > 0 || optimal )
4230 else
4232
4233#ifdef SCIP_STATISTIC
4234 if( pricerdata->nroundsredcost > 0 && pricetype->getType() == GCG_PRICETYPE_REDCOST )
4235 {
4236 if( pricerdata->nrootbounds != pricerdata->dualdiffround )
4237 {
4238 SCIP_Real dualdiff;
4239 SCIP_CALL( computeDualDiff(olddualvalues, olddualconv, pricerdata->realdualvalues, pricerdata->dualsolconv, &dualdiff) );
4240 pricerdata->dualdiffround = pricerdata->nrootbounds;
4241 pricerdata->dualdiff = dualdiff;
4242 }
4243
4244 for( i = pricerdata->npricingprobs - 1; i >= 0; i-- )
4245 {
4246 if( pricerdata->pricingprobs[i] == NULL )
4247 continue;
4248 SCIPfreeBufferArray(scip_, &(olddualvalues[i]));
4249 }
4250 SCIPfreeBufferArray(scip_, &olddualconv);
4251 SCIPfreeBufferArray(scip_, &olddualvalues);
4252
4253 }
4254 else if( pricerdata->nrootbounds != pricerdata->dualdiffround )
4255 {
4256 pricerdata->dualdiff = 0.0;
4257 }
4258#endif
4259
4260 /* undo the inferred pricing modifications from the extended master cons */
4261 for( i = 0; i < nbranchextendedmasterconss; ++i )
4262 {
4263 assert(GCGextendedmasterconsIsActive(branchextendedmasterconsdata[i]));
4264 SCIP_CALL( GCGextendedmasterconsUndoPricingModifications(gcg, branchextendedmasterconsdata[i]) );
4265 }
4266
4267 /* as generation of new columns is finished, the modifications to the pricing problems stemming from the active mastercuts are undone */
4268 for( j = 0; j < nactivecuts; j++ )
4269 {
4271 /* update the var history of all the cuts still in the LP */
4274 }
4275
4276 for( j = 0; j < pricerdata->npricingprobs; j++ )
4277 {
4279 }
4280
4281 return SCIP_OKAY;
4282}
4283
4284/** apply all pricing modifications */
4285SCIP_RETCODE ObjPricerGcg::activatePricingModifications(
4286 GCG_EXTENDEDMASTERCONSDATA* extendedmasterconsdata, /**< extended master cons data */
4287 SCIP_Bool apply /**< should the modifications actually be activated */
4288 )
4289{
4291 int i;
4292 SCIP* pricingprob;
4293
4294 assert(extendedmasterconsdata != NULL);
4295
4296 pmods = GCGextendedmasterconsGetPricingModifications(extendedmasterconsdata);
4297 for( i = 0; i < GCGextendedmasterconsGetNPricingModifications(extendedmasterconsdata); i++ )
4298 {
4299 GCG_PRICINGMODIFICATION* mod = pmods[i];
4300 int probnr = GCGpricingmodificationGetBlock(mod);
4301 if( apply )
4302 {
4303 pricingprob = pricerdata->pricingprobs[probnr];
4304 assert(pricingprob != NULL);
4305 SCIP_CALL( GCGpricingmodificationApply(pricingprob, mod) );
4307 }
4308 pricerdata->nactivepricingmods[probnr]++;
4309 SCIPdebugMessage("activated pricing modification <%p> with coefvar <%s> for prob %d, apply: %d\n",
4310 (void*) mod, SCIPvarGetName(GCGpricingmodificationGetCoefVar(mod)), probnr, apply);
4311 }
4312
4313 return SCIP_OKAY;
4314}
4315
4316/** set pricing objectives */
4317extern "C"
4319 GCG* gcg, /**< GCG data structure */
4320 SCIP_Real* dualsolconv /**< array of dual solutions corresponding to convexity constraints */
4321)
4322{
4323 ObjPricerGcg* pricer;
4324 SCIP_Bool stabilizationtmp;
4325 int i;
4326
4327 pricer = GCGgetObjPricer(gcg);
4328 assert(pricer != NULL);
4329
4330 stabilizationtmp = pricer->pricerdata->stabilization;
4331
4332 pricer->pricerdata->stabilization = FALSE;
4333
4335
4336 if( dualsolconv != NULL )
4337 {
4338 for(i = 0; i < pricer->pricerdata->npricingprobs; ++i)
4339 {
4340 dualsolconv[i] = pricer->pricerdata->dualsolconv[i];
4341 }
4342 }
4343 pricer->pricerdata->stabilization = stabilizationtmp;
4344
4345 return SCIP_OKAY;
4346}
4347
4348/** sets the dual weight for the pricing objective */
4349extern "C"
4351 GCG* gcg, /**< GCG data structure */
4352 SCIP_Real dualweight /**< the weighting applied to the dual variables */
4353 )
4354{
4355 ObjPricerGcg* pricer;
4356
4357 assert(gcg != NULL);
4358
4359 pricer = GCGgetObjPricer(gcg);
4360 assert(pricer != NULL);
4361
4362 pricer->pricerdata->dualweight = dualweight;
4363}
4364
4365/** sets the Lagrangian relaxation weight for the pricing objective */
4366extern "C"
4368 GCG* gcg, /**< GCG data structure */
4369 SCIP_Real* weights, /**< the Lagrangian relaxation weight applied to the master constraints */
4370 int* weightids, /**< the constraint ids for the relaxation weights */
4371 int nweights /**< the number of weights */
4372 )
4373{
4374 ObjPricerGcg* pricer;
4375 int nmasterconss;
4376 SCIP_Bool relaxobjective;
4377 int i;
4378
4379 assert(gcg != NULL);
4380
4381 pricer = GCGgetObjPricer(gcg);
4382 assert(pricer != NULL);
4383
4384 /* setting the relaxation weights to zero */
4385 nmasterconss = GCGgetNMasterConss(gcg);
4386 BMSclearMemoryArray(pricer->pricerdata->relaxweight, nmasterconss);
4387 relaxobjective = FALSE;
4388
4389 for( i = 0; i < nweights; i++ )
4390 {
4391 assert(weightids[i] >= 0 && weightids[i] < nmasterconss);
4392
4393 pricer->pricerdata->relaxweight[weightids[i]] += weights[i];
4394
4395 if( !SCIPisZero(GCGgetMasterprob(gcg), weights[i]) )
4396 relaxobjective = TRUE;
4397 }
4398
4399 pricer->pricerdata->relaxobjective = relaxobjective;
4400}
4401
4402/** creates a new master variable corresponding to the given gcg column */
4403extern "C"
4405 GCG* gcg, /**< GCG data structure */
4406 SCIP_Bool infarkas, /**< in Farkas pricing? */
4407 GCG_COL* gcgcol, /**< GCG column data structure */
4408 SCIP_Bool force, /**< should the given variable be added also if it has non-negative reduced cost? */
4409 SCIP_Bool* added, /**< pointer to store whether the variable was successfully added */
4410 SCIP_VAR** addedvar, /**< pointer to store the created variable */
4411 SCIP_Real score /**< score of column (or -1.0 if not specified) */
4412 )
4413{
4414 ObjPricerGcg* pricer;
4415 PricingType* pricetype;
4416
4417 pricer = GCGgetObjPricer(gcg);
4418 assert(pricer != NULL);
4419
4420 if( infarkas )
4421 pricetype = pricer->getFarkasPricingNonConst();
4422 else
4423 pricetype = pricer->getReducedCostPricingNonConst();
4424
4425
4426 SCIP_CALL( pricer->createNewMasterVarFromGcgCol(pricetype, gcgcol, force, added, addedvar, score) );
4427
4428 return SCIP_OKAY;
4429}
4430
4431/** compute master and cut coefficients of column */
4432extern "C"
4434 GCG* gcg, /**< GCG data structure */
4435 GCG_COL* gcgcol /**< GCG column data structure */
4436 )
4437{
4438 ObjPricerGcg* pricer;
4439
4440 pricer = GCGgetObjPricer(gcg);
4441 assert(pricer != NULL);
4442
4443 pricer->computeColMastercoefs(gcgcol);
4444 pricer->computeColOriginalSepaCuts(gcgcol);
4445 pricer->computeColMastersepacutCoeffs(gcgcol);
4446
4447 return SCIP_OKAY;
4448
4449}
4450/** computes the reduced cost of a column */
4451extern "C"
4453 GCG* gcg, /**< GCG data structure */
4454 SCIP_Bool infarkas, /**< in Farkas pricing? */
4455 GCG_COL* gcgcol, /**< gcg column to compute reduced cost for */
4456 SCIP_Real* objvalptr /**< pointer to store the computed objective value */
4457 )
4458{
4459 ObjPricerGcg* pricer;
4460 PricingType* pricetype;
4461 SCIP_Real redcost;
4462
4463 pricer = GCGgetObjPricer(gcg);
4464 assert(pricer != NULL);
4465
4466 if( infarkas )
4467 pricetype = pricer->getFarkasPricingNonConst();
4468 else
4469 pricetype = pricer->getReducedCostPricingNonConst();
4470
4471 redcost = pricer->computeRedCostGcgCol(pricetype, gcgcol, objvalptr);
4472
4473 return redcost;
4474}
4475
4476/** includes a pricing callback plugin into the pricer data */
4477extern "C"
4479 GCG* gcg, /**< GCG data structure */
4480 const char* name, /**< name of pricing callback plugin */
4481 const char* desc, /**< description of pricing callback plugin */
4482 int priority, /**< priority of pricing callback plugin */
4483 GCG_DECL_PRICINGCBFREE((*pricingcbfree)), /**< destructor of the pricing callback */
4484 GCG_DECL_PRICINGCBINIT((*pricingcbinit)), /**< initialize the pricing callback */
4485 GCG_DECL_PRICINGCBEXIT((*pricingcbexit)), /**< deinitialize the pricing callback */
4486 GCG_DECL_PRICINGCBINITSOL((*pricingcbinitsol)),/**< solving process initialization method of the pricing callback */
4487 GCG_DECL_PRICINGCBEXITSOL((*pricingcbexitsol)),/**< solving process deinitialization method of the pricing callback */
4488 GCG_DECL_PRICINGCBPREPRICING((*pricingcbprepricing)),/**< pre-pricing method of the pricing callback */
4489 GCG_DECL_PRICINGCBPOSTPRICING((*pricingcbpostpricing)),/**< post-pricing method of the pricing callback */
4490 GCG_PRICINGCBDATA* pricingcbdata /**< pricing callback data */
4491 )
4492{
4493 GCG_PRICINGCB* pricingcb;
4494 ObjPricerGcg* pricer;
4495 SCIP_PRICERDATA* pricerdata;
4496
4497 assert(gcg != NULL);
4498
4499 pricer = GCGgetObjPricer(gcg);
4500 assert(pricer != NULL);
4501
4502 pricerdata = pricer->getPricerdata();
4503 assert(pricerdata != NULL);
4504
4505 /* create pricing callback plugin */
4506 pricingcb = NULL;
4507 SCIP_CALL( GCGpricingcbCreate(gcg, &pricingcb, name, desc, priority, pricingcbfree, pricingcbinit,
4508 pricingcbexit, pricingcbinitsol, pricingcbexitsol, pricingcbprepricing, pricingcbpostpricing, pricingcbdata) );
4509 assert(pricingcb != NULL);
4510
4511 /* add solver to pricer data */
4512 if( pricerdata->npricingcbs == 0 )
4513 {
4514 SCIP_CALL( SCIPallocMemoryArray(scip, &(pricerdata->pricingcbs), 1) ); /*lint !e506*/
4515 }
4516 else
4517 {
4518 SCIP_CALL( SCIPreallocMemoryArray(scip, &(pricerdata->pricingcbs), (size_t)pricerdata->npricingcbs+1) );
4519 }
4520 pricerdata->pricingcbs[pricerdata->npricingcbs] = pricingcb;
4521 ++pricerdata->npricingcbs;
4522
4523 return SCIP_OKAY;
4524}
4525
4526/** returns the available pricing callback plugins */
4527extern "C"
4529 GCG* gcg /**< GCG data structure */
4530 )
4531{
4532 ObjPricerGcg* pricer;
4533 SCIP_PRICERDATA* pricerdata;
4534
4535 assert(gcg != NULL);
4536
4537 pricer = GCGgetObjPricer(gcg);
4538 assert(pricer != NULL);
4539
4540 pricerdata = pricer->getPricerdata();
4541 assert(pricerdata != NULL);
4542
4543 return pricerdata->pricingcbs;
4544}
4545
4546/** returns the number of available pricing callback plugins */
4547extern "C"
4549 GCG* gcg /**< GCG data structure */
4550 )
4551{
4552 ObjPricerGcg* pricer;
4553 SCIP_PRICERDATA* pricerdata;
4554
4555 assert(gcg != NULL);
4556
4557 pricer = GCGgetObjPricer(gcg);
4558 assert(pricer != NULL);
4559
4560 pricerdata = pricer->getPricerdata();
4561 assert(pricerdata != NULL);
4562
4563 return pricerdata->npricingcbs;
4564}
4565
4566/** returns the pricing callback plugin of the given name, or NULL if it doesn't exist */
4567extern "C"
4569 GCG* gcg, /**< GCG data structure */
4570 const char* name /**< the name of the pricing callback plugin */
4571 )
4572{
4573 ObjPricerGcg* pricer;
4574 SCIP_PRICERDATA* pricerdata;
4575 int i;
4576
4577 assert(gcg != NULL);
4578
4579 pricer = GCGgetObjPricer(gcg);
4580 assert(pricer != NULL);
4581
4582 pricerdata = pricer->getPricerdata();
4583 assert(pricerdata != NULL);
4584
4585 for( i = 0; i < pricerdata->npricingcbs; i++ )
4586 {
4587 if( strcmp(GCGpricingcbGetName(pricerdata->pricingcbs[i]), name) == 0 )
4588 return pricerdata->pricingcbs[i];
4589 }
4590
4591 return NULL;
4592}
4593
4594/** performs the pricing routine, gets the type of pricing that should be done: farkas or redcost pricing */
4596 PricingType* pricetype, /**< type of the pricing */
4597 SCIP_RESULT* result, /**< result pointer */
4598 SCIP_Real* lowerbound /**< lowerbound pointer */
4599 )
4600{
4601 int nfoundvars;
4602 SCIP_Bool bestredcostvalid;
4603
4604 assert(result != NULL);
4605 assert(lowerbound != NULL || pricetype->getType() == GCG_PRICETYPE_FARKAS);
4607
4608 if( lowerbound != NULL )
4609 *lowerbound = -SCIPinfinity(scip_);
4610
4611 GCGpricerPrintInfo(scip_, pricerdata, "nvars = %d, current LP objval = %g, time = %f, node = %lld\n",
4613
4614 if( pricetype->getType() == GCG_PRICETYPE_REDCOST )
4615 {
4616 assert(result != NULL);
4617
4618 /* terminate early, if applicable */
4619 if( canPricingBeAborted() )
4620 {
4622 return SCIP_OKAY;
4623 }
4624 }
4625
4627
4628 pricingtype = pricetype;
4629 pricetype->incCalls();
4630
4631 pricerdata->calls++;
4632 nfoundvars = 0;
4633
4634 bestredcostvalid = TRUE;
4635
4636 pricingcontroller->initPricing(pricetype);
4637
4638 SCIP_CALL( pricingLoop(pricetype, result, &nfoundvars, lowerbound, &bestredcostvalid) );
4639
4640 if( pricetype->getType() == GCG_PRICETYPE_REDCOST && bestredcostvalid )
4641 {
4642 assert(lowerbound != NULL);
4643 GCGpricerPrintInfo(scip_, pricerdata, "lower bound = %g\n", *lowerbound);
4644
4645 pricingcontroller->resetEagerage();
4646 }
4647
4648
4649 SCIPdebugMessage("%s pricing: found %d new vars\n", (pricetype->getType() == GCG_PRICETYPE_REDCOST ? "Redcost" : "Farkas"), nfoundvars);
4650
4651 if( GCGisRootNode(gcg) && pricetype->getType() == GCG_PRICETYPE_REDCOST && pricetype->getCalls() > 0 )
4652 {
4653 double degeneracy = 0.0;
4654
4655 /* only compute degeneracy if current solution is basic */
4656 if( SCIPisLPSolBasic(scip_) )
4657 SCIP_CALL( computeCurrentDegeneracy(&degeneracy) );
4658
4659 pricerdata->rootnodedegeneracy = degeneracy;
4660
4661 /* Complicated calculation for numerical stability:
4662 * E[\sum_{i=1}^n x_i] = (E[\sum_{i=1}^{n-1} x_i]*(n-1) + x_n)/n
4663 * E[\sum_{i=1}^n x_i] = E[\sum_{i=1}^{n-1} x_i]*(n-1)/n + x_n/n
4664 * <=> E[\sum_{i=1}^n x_i] = E[\sum_{i=1}^{n-1} x_i]-E[\sum_{i=1}^{n-1} x_i]/n + x_n/n
4665 * <=> E_n = E_{n-1} - E_{n-1}/n + x_n/n
4666 * <=> E -= E/n - x_n/n
4667 */
4670 }
4671
4672 pricingcontroller->exitPricing();
4673
4674 pricingtype = NULL;
4675
4676 return SCIP_OKAY;
4677}
4678
4679/*
4680 * Callback methods of variable pricer
4681 */
4682
4684 GCG* gcgstruct, /**< GCG data structure */
4685 const char* name, /**< name of variable pricer */
4686 const char* desc, /**< description of variable pricer */
4687 int priority, /**< priority of the variable pricer */
4688 SCIP_Bool delay,
4689 SCIP_PRICERDATA* p_pricerdata
4690 ) : ObjPricer(GCGgetMasterprob(gcgstruct), name, desc, priority, delay), gcg(gcgstruct), colpool(NULL), pricestore(NULL), reducedcostpricing(NULL), farkaspricing(NULL), pricingtype(NULL), pricingcontroller(NULL), stabilization(NULL)
4691 {
4692
4693 assert(gcgstruct!= NULL);
4694 pricerdata = p_pricerdata;
4695 origprob = GCGgetOrigprob(gcgstruct);
4696 }
4697
4698/** destructor of variable pricer to free user data (called when SCIP is exiting) */
4699SCIP_DECL_PRICERFREE(ObjPricerGcg::scip_free)
4700{
4701 assert(scip == scip_);
4702 SCIP_CALL( solversFree() );
4703
4704 if( pricerdata->pricingcbs != NULL )
4705 {
4706 SCIP_CALL( pricingcbsFree() );
4707
4708 SCIPfreeMemoryArray(scip, &pricerdata->pricingcbs);
4709 }
4710
4711 SCIPfreeMemoryArray(scip, &pricerdata->solvers);
4712
4713 gcg->pricer = NULL;
4714
4715 /* free memory for pricerdata*/
4716 if( pricerdata != NULL )
4717 {
4718 SCIPfreeMemory(scip, &pricerdata);
4719 }
4720
4721 delete pricingcontroller;
4722
4723 if( reducedcostpricing != NULL )
4724 delete reducedcostpricing;
4725
4726 if( farkaspricing != NULL )
4727 delete farkaspricing;
4728
4729 SCIPpricerSetData(pricer, NULL);
4730 return SCIP_OKAY;
4731}
4732
4733
4734/** initialization method of variable pricer (called after problem was transformed) */
4735SCIP_DECL_PRICERINIT(ObjPricerGcg::scip_init)
4736{ /*lint --e{715}*/
4737 assert(scip == scip_);
4738 assert(reducedcostpricing != NULL);
4739 assert(farkaspricing != NULL);
4740
4741 pricerdata->artificialused = FALSE;
4742 pricerdata->artificialvars = NULL;
4743 pricerdata->nartificialvars = 0;
4744 pricerdata->maxartificialvars = 0;
4745
4746 SCIP_CALL( solversInit() );
4747 SCIP_CALL( pricingcbsInit() );
4748
4749 SCIP_CALL( reducedcostpricing->resetCalls() );
4750 SCIP_CALL( farkaspricing->resetCalls() );
4751
4752 return SCIP_OKAY;
4753}
4754
4755
4756/** deinitialization method of variable pricer (called before transformed problem is freed) */
4757SCIP_DECL_PRICEREXIT(ObjPricerGcg::scip_exit)
4758{ /*lint --e{715}*/
4759 assert(scip == scip_);
4760 SCIP_CALL( solversExit() );
4761 SCIP_CALL( pricingcbsExit() );
4762
4763 return SCIP_OKAY;
4764}
4765
4766
4767/** solving process initialization method of variable pricer (called when branch and bound process is about to begin) */
4768SCIP_DECL_PRICERINITSOL(ObjPricerGcg::scip_initsol)
4769{
4770 int i;
4771 int norigvars;
4772 SCIP_Bool discretization;
4773 SCIP_CONS** masterconss;
4774 int nmasterconss;
4775 int origverblevel;
4776 int npricingvars;
4777
4778 assert(scip == scip_);
4779 assert(pricer != NULL);
4780 assert(pricerdata != NULL);
4781
4782 /* at the beginning, the output of the master problem gets the same verbosity level
4783 * as the output of the original problem */
4784 SCIP_CALL( SCIPgetIntParam(origprob, "display/verblevel", &origverblevel) );
4785 SCIP_CALL( SCIPsetIntParam(scip, "display/verblevel", origverblevel) );
4786
4787 pricerdata->currnodenr = -1;
4788 pricerdata->artificialused = FALSE;
4789 pricerdata->npricingloopiters = 0;
4790
4791 nmasterconss = GCGgetNMasterConss(gcg);
4792 masterconss = GCGgetMasterConss(gcg);
4793
4794 pricerdata->relaxobjective = FALSE;
4795 pricerdata->dualweight = 1.0;
4796 SCIP_CALL( SCIPallocClearBlockMemoryArray(scip, &(pricerdata->relaxweight), nmasterconss) );
4797
4798 /* init array containing all pricing problems */
4799 pricerdata->npricingprobs = GCGgetNPricingprobs(gcg);
4800 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(pricerdata->pricingprobs), pricerdata->npricingprobs) );
4801 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(pricerdata->npointsprob), pricerdata->npricingprobs) );
4802 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(pricerdata->nraysprob), pricerdata->npricingprobs) );
4803
4804 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(pricerdata->farkascallsdist), pricerdata->npricingprobs) );
4805 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(pricerdata->farkasfoundvars), pricerdata->npricingprobs) );
4807
4811
4812 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(pricerdata->realdualvalues), pricerdata->npricingprobs) );
4813 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(pricerdata->nrealdualvalues), pricerdata->npricingprobs) );
4814
4817
4818 pricerdata->oldvars = 0;
4819
4820 pricerdata->npricingprobsnotnull = 0;
4821
4822 /* alloc memory for arrays of reduced cost */
4823 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(pricerdata->dualsolconv), pricerdata->npricingprobs) );
4824
4826
4827 for( i = 0; i < pricerdata->npricingprobs; i++ )
4828 {
4829
4830 pricerdata->farkascallsdist[i] = 0;
4831 pricerdata->farkasfoundvars[i] = 0;
4832 pricerdata->farkasnodetimedist[i] = 0;
4833 pricerdata->redcostcallsdist[i] = 0;
4834 pricerdata->redcostfoundvars[i] = 0;
4835 pricerdata->redcostnodetimedist[i]= 0;
4836 pricerdata->dualsolconv[i] = -SCIPinfinity(scip_);
4837 pricerdata->nefficaciouscols[i] = 0;
4838
4840 {
4841 pricerdata->pricingprobs[i] = GCGgetPricingprob(gcg, i);
4842 pricerdata->npricingprobsnotnull++;
4843 npricingvars = SCIPgetNOrigVars(pricerdata->pricingprobs[i]);
4844 assert(GCGcountInferredCoefPricingVars(SCIPgetOrigVars(pricerdata->pricingprobs[i]), npricingvars) == 0);
4845 pricerdata->nrealdualvalues[i] = npricingvars;
4846 SCIP_CALL( SCIPallocClearBlockMemoryArray(scip, &(pricerdata->realdualvalues[i]), pricerdata->nrealdualvalues[i]) ); /*lint !e666 !e866*/
4847 }
4848 else
4849 {
4850 pricerdata->realdualvalues[i] = NULL;
4851 pricerdata->nrealdualvalues[i] = 0;
4852 pricerdata->pricingprobs[i] = NULL;
4853 }
4854 pricerdata->npointsprob[i] = 0;
4855 pricerdata->nraysprob[i] = 0;
4856 }
4857
4858 /* alloc memory for solution values of variables in pricing problems */
4859 norigvars = SCIPgetNOrigVars(origprob);
4860 pricerdata->maxsolvals = SCIPcalcMemGrowSize(scip, norigvars);
4861 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(pricerdata->solvals), pricerdata->maxsolvals) );
4862
4863 SCIP_CALL( SCIPcreateCPUClock(scip, &(pricerdata->freeclock)) );
4864 SCIP_CALL( SCIPcreateCPUClock(scip, &(pricerdata->transformclock)) );
4866
4867 pricerdata->nduplicatecols = 0;
4868 pricerdata->solvedsubmipsoptimal = 0;
4869 pricerdata->solvedsubmipsheur = 0;
4870 pricerdata->calls = 0;
4871 pricerdata->pricingiters = 0;
4872
4873 /* set variable type for master variables */
4874 SCIP_CALL( SCIPgetBoolParam(origprob, "relaxing/gcg/discretization", &discretization) );
4875 if( discretization && SCIPgetNContVars(origprob) == 0 )
4876 {
4877 pricerdata->vartype = SCIP_VARTYPE_INTEGER;
4878 }
4879 else
4880 {
4881 pricerdata->vartype = SCIP_VARTYPE_CONTINUOUS;
4882 }
4883
4884 SCIP_CALL( SCIPhashmapCreate(&(pricerdata->mapcons2idx), SCIPblkmem(scip), 10 * nmasterconss +1) );
4885 for( i = 0; i < nmasterconss; i++ )
4886 {
4887 SCIP_CALL( SCIPhashmapInsert(pricerdata->mapcons2idx, masterconss[i], (void*)(size_t)i) );
4888 assert((int)(size_t)SCIPhashmapGetImage(pricerdata->mapcons2idx, masterconss[i]) == i); /*lint !e507*/
4889 }
4890
4891 pricerdata->npricedvars = 0;
4892 pricerdata->maxpricedvars = SCIPcalcMemGrowSize(scip, 50);
4893 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &pricerdata->pricedvars, pricerdata->maxpricedvars) );
4894
4895 pricerdata->varhistory = NULL;
4896 SCIP_CALL( GCGvarhistoryCreate(scip, &(pricerdata->varhistory)) );
4897
4898 pricerdata->nroundsredcost = 0;
4899#ifdef SCIP_STATISTIC
4900 pricerdata->rootlpsol = NULL;
4901 pricerdata->rootfarkastime = 0.0;
4902 pricerdata->dualdiff = 0.0;
4903 pricerdata->dualdiffround = -1;
4904 pricerdata->nrootbounds = 0;
4905 pricerdata->maxrootbounds = 50;
4906 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &pricerdata->rootpbs, pricerdata->maxrootbounds) );
4907 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &pricerdata->rootdbs, pricerdata->maxrootbounds) );
4908 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &pricerdata->roottimes, pricerdata->maxrootbounds) );
4909 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &pricerdata->rootdualdiffs, pricerdata->maxrootbounds) );
4910 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &pricerdata->dualvalues, pricerdata->maxrootbounds) );
4911 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &pricerdata->dualsolconvs, pricerdata->maxrootbounds) );
4912 SCIP_CALL( SCIPallocMemoryArray(scip, &(pricerdata->nodetimehist), PRICER_STAT_ARRAYLEN_TIME) ); /*lint !e506*/
4913 SCIP_CALL( SCIPallocMemoryArray(scip, &(pricerdata->foundvarshist), PRICER_STAT_ARRAYLEN_VARS) ); /*lint !e506*/
4914
4915 BMSclearMemoryArray(pricerdata->nodetimehist, PRICER_STAT_ARRAYLEN_TIME);
4916 BMSclearMemoryArray(pricerdata->foundvarshist, PRICER_STAT_ARRAYLEN_VARS);
4917#endif
4918
4919 pricerdata->rootnodedegeneracy = 0.0;
4920 pricerdata->avgrootnodedegeneracy = 0.0;
4921 pricerdata->ndegeneracycalcs = 0;
4922
4923 /* sort solvers by priority */
4924 SCIPsortPtr((void**)pricerdata->solvers, GCGsolverComp, pricerdata->nsolvers);
4925
4926 /* sort pricing callback plugins by priority */
4927 SCIPsortPtr((void**)pricerdata->pricingcbs, GCGpricingcbComp, pricerdata->npricingcbs);
4928
4929 SCIP_CALL( pricingcontroller->initSol() );
4930
4931 SCIP_CALL( solversInitsol() );
4932 SCIP_CALL( pricingcbsInitsol() );
4933
4934 /* if maxobj should be used, compute it */
4935 if( pricerdata->usemaxobj )
4936 {
4937 SCIP_Bool reliable;
4938 pricerdata->maxobj = 0.0;
4939 reliable = TRUE;
4940 for( i = 0; i < SCIPgetNVars(origprob); ++i )
4941 {
4942 SCIP_VAR* var;
4943 SCIP_Real obj;
4944 SCIP_Real ub;
4945 SCIP_Real lb;
4946
4949 ub = SCIPvarGetUbGlobal(var);
4950 lb = SCIPvarGetLbGlobal(var);
4951
4952 /* check if influence of variable on objective is bounded */
4955 {
4956 /* if it is not bounded, maxobj is not reliable; use large, heuristic value */
4957 pricerdata->maxobj += pricerdata->factorunreliable* ABS(obj);
4958 reliable = FALSE;
4959 }
4960 else
4961 /* if it is bounded, add maximum difference to maxobj */
4962 pricerdata->maxobj += MAX(ub * obj, lb * obj) - MIN(ub * obj, lb * obj);
4963 }
4964 if( !reliable && pricerdata->onlyreliablebigm )
4965 {
4966 if( pricerdata->useartificialvars )
4967 {
4968 pricerdata->useartificialvars = FALSE;
4969 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "Big M to be used for artificial variables not reliable; use regular Farkas pricing instead.\n");
4970 }
4971 pricerdata->maxobj = SCIPinfinity(origprob);
4972 }
4973 else if( pricerdata->useartificialvars && !reliable && !pricerdata->onlyreliablebigm )
4974 SCIPwarningMessage(scip, "Big M used for artificial variables not reliable. This might lead to wrong solutions.\n");
4975 }
4976 else
4977 pricerdata->maxobj = SCIPinfinity(origprob);
4978
4979 createStabilization();
4980 SCIP_CALL( stabilization->setNLinkingconsvals(GCGgetNVarLinkingconss(gcg)) );
4981 SCIP_CALL( stabilization->setNConvconsvals(GCGgetNPricingprobs(gcg)) );
4982
4983 if( pricerdata->usecolpool )
4984 SCIP_CALL( createColpool() );
4985
4986 SCIP_CALL( createPricestore() );
4987
4989
4990 return SCIP_OKAY;
4991}
4992
4993
4994/** solving process deinitialization method of variable pricer (called before branch and bound process data is freed) */
4995SCIP_DECL_PRICEREXITSOL(ObjPricerGcg::scip_exitsol)
4996{
4997 int nmasterconss;
4998 int i;
4999#ifdef SCIP_STATISTIC
5000 int j;
5001#endif
5002
5003 assert(scip == scip_);
5004 assert(pricer != NULL);
5005 assert(pricerdata != NULL);
5006
5007 nmasterconss = GCGgetNMasterConss(gcg);
5008
5009 SCIP_CALL( solversExitsol() );
5010 SCIP_CALL( pricingcbsExitsol() );
5011
5012 SCIP_CALL( pricingcontroller->exitSol() );
5013
5014 if( stabilization != NULL )
5015 delete stabilization;
5016
5017 stabilization = NULL;
5018
5019 if( pricerdata->usecolpool )
5020 SCIP_CALL( GCGcolpoolFree(&colpool) );
5021
5022 SCIP_CALL( GCGpricestoreFree(&pricestore) );
5023
5024 SCIPhashmapFree(&(pricerdata->mapcons2idx));
5025
5026#ifdef SCIP_STATISTIC
5027 for( i = 0; i < pricerdata->nrootbounds; ++i )
5028 {
5029 for( j = 0; j < pricerdata->npricingprobs; ++j )
5030 {
5031 if( pricerdata->dualvalues[i][j] != NULL )
5032 {
5033 SCIPfreeBlockMemoryArray(scip, &pricerdata->dualvalues[i][j], pricerdata->nrealdualvalues[i]);
5034 }
5035 }
5036 SCIPfreeBlockMemoryArray(scip, &pricerdata->dualvalues[i], pricerdata->npricingprobs);
5037 SCIPfreeBlockMemoryArray(scip, &pricerdata->dualsolconvs[i], pricerdata->npricingprobs);
5038 }
5039 SCIPfreeBlockMemoryArray(scip, &pricerdata->rootpbs, pricerdata->maxrootbounds);
5040 SCIPfreeBlockMemoryArray(scip, &pricerdata->rootdbs, pricerdata->maxrootbounds);
5041 SCIPfreeBlockMemoryArray(scip, &pricerdata->roottimes, pricerdata->maxrootbounds);
5042 SCIPfreeBlockMemoryArray(scip, &pricerdata->rootdualdiffs, pricerdata->maxrootbounds);
5043 SCIPfreeBlockMemoryArray(scip, &pricerdata->dualvalues, pricerdata->maxrootbounds);
5044 SCIPfreeBlockMemoryArray(scip, &pricerdata->dualsolconvs, pricerdata->maxrootbounds);
5045 SCIPfreeSol(scip, &pricerdata->rootlpsol);
5046 pricerdata->rootlpsol = NULL;
5047 pricerdata->maxrootbounds = 0;
5048 pricerdata->nrootbounds = 0;
5049 pricerdata->rootfarkastime = 0.0;
5050 pricerdata->dualdiff = 0.0;
5051 SCIPfreeMemoryArrayNull(scip, &(pricerdata->nodetimehist));
5052 SCIPfreeMemoryArrayNull(scip, &(pricerdata->foundvarshist));
5053
5054 pricerdata->nodetimehist = NULL;
5055 pricerdata->foundvarshist = NULL;
5056#endif
5057
5058 SCIPfreeBlockMemoryArray(scip, &(pricerdata->pricingprobs), pricerdata->npricingprobs);
5059 SCIPfreeBlockMemoryArray(scip, &(pricerdata->npointsprob), pricerdata->npricingprobs);
5060 SCIPfreeBlockMemoryArray(scip, &(pricerdata->nraysprob), pricerdata->npricingprobs);
5061
5062 SCIPfreeBlockMemoryArray(scip, &(pricerdata->farkascallsdist), pricerdata->npricingprobs);
5063 SCIPfreeBlockMemoryArray(scip, &(pricerdata->farkasfoundvars), pricerdata->npricingprobs);
5064 SCIPfreeBlockMemoryArray(scip, &(pricerdata->farkasnodetimedist), pricerdata->npricingprobs);
5065
5066 SCIPfreeBlockMemoryArray(scip, &(pricerdata->redcostcallsdist), pricerdata->npricingprobs);
5067 SCIPfreeBlockMemoryArray(scip, &(pricerdata->redcostfoundvars), pricerdata->npricingprobs);
5068 SCIPfreeBlockMemoryArray(scip, &(pricerdata->redcostnodetimedist), pricerdata->npricingprobs);
5069
5070
5071 SCIPfreeBlockMemoryArray(scip, &(pricerdata->dualsolconv), pricerdata->npricingprobs);
5072
5073 SCIPfreeBlockMemoryArray(scip, &(pricerdata->solvals), pricerdata->maxsolvals);
5074
5075 for( i = 0; i < pricerdata->nartificialvars; i++ )
5076 {
5077// SCIP_CALL( SCIPdropVarEvent(scip, pricerdata->artificialvars[i], SCIP_EVENTTYPE_VARDELETED,
5078// pricerdata->eventhdlr, NULL, -1) );
5079
5080 SCIP_CALL( SCIPreleaseVar(scip, &pricerdata->artificialvars[i]) );
5081 }
5083 pricerdata->maxartificialvars = 0;
5084 pricerdata->nartificialvars = 0;
5085
5086 for( i = 0; i < pricerdata->npricedvars; i++ )
5087 {
5089 pricerdata->eventhdlr, NULL, -1) );
5090
5091 SCIP_CALL( SCIPreleaseVar(scip, &pricerdata->pricedvars[i]) );
5092 }
5093 SCIPfreeBlockMemoryArray(scip, &pricerdata->pricedvars, pricerdata->maxpricedvars);
5094 pricerdata->maxpricedvars = 0;
5095 pricerdata->npricedvars = 0;
5096
5097 assert(pricerdata->varhistory != NULL);
5099
5100 SCIP_CALL( SCIPfreeClock(scip, &(pricerdata->freeclock)) );
5101 SCIP_CALL( SCIPfreeClock(scip, &(pricerdata->transformclock)) );
5102 SCIP_CALL( SCIPfreeClock(scip, &(pricerdata->duplicatecolclock)) );
5103
5104 for( i = 0; i < pricerdata->npricingprobs; ++i )
5105 {
5106 assert(0 <= pricerdata->nrealdualvalues[i]);
5107 SCIPfreeBlockMemoryArrayNull(scip, &(pricerdata->realdualvalues[i]), pricerdata->nrealdualvalues[i]);
5108 }
5109 SCIPfreeBlockMemoryArray(scip, &(pricerdata->realdualvalues), pricerdata->npricingprobs);
5110 SCIPfreeBlockMemoryArray(scip, &(pricerdata->nrealdualvalues), pricerdata->npricingprobs);
5111
5112 SCIPfreeBlockMemoryArray(scip, &(pricerdata->nefficaciouscols), pricerdata->npricingprobs);
5113
5114 SCIPfreeBlockMemoryArray(scip, &(pricerdata->nactivepricingmods), pricerdata->npricingprobs);
5115 SCIPfreeBlockMemoryArray(scip, &(pricerdata->nappliedpricingmods), pricerdata->npricingprobs);
5116
5117 SCIPfreeBlockMemoryArray(scip, &(pricerdata->relaxweight), nmasterconss);
5118 pricerdata->dualweight = 1.0;
5119 pricerdata->relaxobjective = FALSE;
5120
5121 return SCIP_OKAY;
5122}
5123
5124
5125/** reduced cost pricing method of variable pricer for feasible LPs */
5126SCIP_DECL_PRICERREDCOST(ObjPricerGcg::scip_redcost)
5127{ /*lint -esym(715, stopearly)*/
5128 SCIP_Bool abort = FALSE;
5130
5131 assert(scip == scip_);
5132 assert(pricer != NULL);
5133 assert(pricerdata != NULL);
5134 assert(reducedcostpricing != NULL);
5135 assert(farkaspricing != NULL);
5136
5138
5139 if( reducedcostpricing->getCalls() == 0 )
5140 {
5141 /** @todo This is just a workaround around SCIP stages! */
5142 if( farkaspricing->getCalls() == 0 )
5143 {
5145 }
5146 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "Starting reduced cost pricing...\n");
5147 }
5148
5149 if( SCIPisStopped(scip_) )
5150 {
5151 return SCIP_OKAY;
5152 }
5153
5154 if( SCIPgetCurrentNode(scip) == SCIPgetRootNode(scip) && GCGsepaGetNOriginalSepaCuts(gcg) == 0 && reducedcostpricing->getCalls() > 0
5155 && GCGmasterIsCurrentSolValid(gcg) && pricerdata->artificialused )
5156 {
5157 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "Starting reduced cost pricing without artificial variables...\n");
5158 }
5159
5161 pricerdata->artificialused = TRUE;
5162 else
5163 pricerdata->artificialused = FALSE;
5164
5165
5166 /* update number of reduced cost pricing rounds at the current node */
5167 if( SCIPgetNNodes(scip) == pricerdata->currnodenr )
5168 {
5169 pricerdata->nroundsredcost++;
5170 }
5171 else
5172 {
5173 pricerdata->currnodenr = SCIPgetNNodes(scip);
5174 pricerdata->nroundsredcost = 0;
5175 }
5176
5177 /* if the number of reduced cost pricing rounds at the current node exceeds the limit (and we are not at the root), stop pricing;
5178 * we always stop pricing, if the maximum number of reduced cost rounds is set to 0
5179 */
5180 if( reducedcostpricing->getMaxrounds() == 0 || (pricerdata->nroundsredcost >= reducedcostpricing->getMaxrounds() && pricerdata->currnodenr != 1) )
5181 {
5182 SCIPdebugMessage("pricing aborted at node %lld\n", pricerdata->currnodenr);
5183 return SCIP_OKAY;
5184 }
5185
5187
5188 /* perform pricing */
5189
5190 pricingcontroller->increaseEagerage();
5191
5192 GCGpricestoreEndFarkas(pricestore);
5193 if( pricerdata->usecolpool )
5194 GCGcolpoolEndFarkas(colpool);
5195
5196 /* executing the pre-pricing method of the pricing callback plugins. */
5197 SCIP_CALL( pricingcbsPrepricing(pricer, GCG_PRICETYPE_REDCOST, &abort) );
5198
5199 /*If one of the pre-pricing methods of the pricing callback plugins indicates that the pricing must be aborted,
5200 * then no columns are generated
5201 */
5202 if( abort )
5203 return SCIP_OKAY;
5204
5205 SCIP_CALL( reducedcostpricing->startClock() );
5206 retcode = priceNewVariables(reducedcostpricing, result, lowerbound);
5207 SCIP_CALL( reducedcostpricing->stopClock() );
5208
5209 /* executing the post-pricing method of the pricing callback plugins. */
5210 SCIP_CALL( pricingcbsPostpricing(pricer, GCG_PRICETYPE_REDCOST) );
5211
5212#ifdef SCIP_STATISTIC
5214 {
5215 SCIP_CALL( addRootBounds(SCIPgetLPObjval(scip_), *lowerbound) );
5216 SCIPdebugMessage("Add bounds, %f\n", *lowerbound);
5217 }
5218#endif
5219 return retcode;
5220}
5221
5222SCIP_RETCODE ObjPricerGcg::ensureSizeArtificialvars(
5223 int size /**< needed size */
5224 )
5225{
5226 assert(pricerdata != NULL);
5227
5228 if( pricerdata->maxartificialvars < size )
5229 {
5230 int oldsize = pricerdata->maxartificialvars;
5233 }
5235
5236 return SCIP_OKAY;
5237}
5238
5239/** add artificial vars */
5241 )
5242{
5243 SCIP_CONS** masterconss;
5244 int nmasterconss;
5245 int nconvconss;
5246 char varname[SCIP_MAXSTRLEN];
5247 int i;
5248 SCIP_Real bigm;
5249
5252
5253 masterconss = GCGgetMasterConss(gcg);
5254 nmasterconss = GCGgetNMasterConss(gcg);
5255
5256 nconvconss = GCGgetNPricingprobs(gcg);
5257
5258 /* if bigmartificial is negative, use maxobj */
5259 if( pricerdata->usemaxobj )
5260 bigm = pricerdata->maxobj;
5261 else
5262 bigm = pricerdata->bigmartificial;
5263
5264 for( i = 0; i < nmasterconss; ++i )
5265 {
5266 if( !SCIPisInfinity(scip_, -1.0*GCGconsGetLhs(scip_, masterconss[i]) ))
5267 {
5268 (void) SCIPsnprintf(varname, SCIP_MAXSTRLEN, "art_lhs_%s", SCIPconsGetName(masterconss[i]));
5269 ensureSizeArtificialvars(pricerdata->nartificialvars + 1);
5274 }
5275
5276 if( !SCIPisInfinity(scip_, GCGconsGetRhs(scip_, masterconss[i]) ))
5277 {
5278 (void) SCIPsnprintf(varname, SCIP_MAXSTRLEN, "art_rhs_%s", SCIPconsGetName(masterconss[i]));
5279 ensureSizeArtificialvars(pricerdata->nartificialvars + 1);
5284 }
5285 }
5286
5287 for( i = 0; i < nconvconss; ++i )
5288 {
5289 SCIP_CONS* convcons;
5290
5292 continue;
5293
5294 convcons = GCGgetConvCons(gcg, i);
5295
5296 if( !SCIPisInfinity(scip_, -1.0*GCGconsGetLhs(scip_, convcons) ))
5297 {
5298 (void) SCIPsnprintf(varname, SCIP_MAXSTRLEN, "art_lhs_%s", SCIPconsGetName(convcons));
5299 ensureSizeArtificialvars(pricerdata->nartificialvars + 1);
5304 }
5305
5306 if( !SCIPisInfinity(scip_, GCGconsGetRhs(scip_, convcons) ))
5307 {
5308 (void) SCIPsnprintf(varname, SCIP_MAXSTRLEN, "art_rhs_%s", SCIPconsGetName(convcons));
5309 ensureSizeArtificialvars(pricerdata->nartificialvars + 1);
5314 }
5315
5316 }
5317
5319
5320 return SCIP_OKAY;
5321}
5322
5323/** farcas pricing method of variable pricer for infeasible LPs */
5324SCIP_DECL_PRICERFARKAS(ObjPricerGcg::scip_farkas)
5325{
5327 SCIP_SOL** origsols;
5328 int norigsols;
5329 int nstoredsols;
5330 SCIP_Bool abort = FALSE;
5331
5332 assert(scip == scip_);
5333 assert(pricer != NULL);
5334 assert(pricerdata != NULL);
5335 assert(reducedcostpricing != NULL);
5336 assert(farkaspricing != NULL);
5337
5339
5340 /** @todo This is just a workaround around SCIP stages! */
5341 if( reducedcostpricing->getCalls() == 0 && farkaspricing->getCalls() == 0 )
5342 {
5344 }
5345
5346 /* get solutions from the original problem */
5347 origsols = SCIPgetSols(origprob);
5348 norigsols = SCIPgetNSols(origprob);
5349 assert(norigsols >= 0);
5350
5351 /* update current node */
5352 if( SCIPgetNNodes(scip) != pricerdata->currnodenr )
5353 {
5354 pricerdata->currnodenr = SCIPgetNNodes(scip);
5355 }
5356
5358
5359 /* Add already known solutions for the original problem to the master variable space */
5360 /** @todo This is just a workaround around SCIP stages! */
5361 nstoredsols = 0;
5362 if( farkaspricing->getCalls() == 0 )
5363 {
5364 int i;
5365
5366 for( i = 0; i < norigsols; ++i )
5367 {
5368 SCIP_Bool stored;
5369 assert(origsols[i] != NULL);
5370 SCIPdebugMessage("Transferring original feasible solution found by <%s> to master problem\n",
5371 SCIPsolGetHeur(origsols[i]) == NULL ? "relaxation" : SCIPheurGetName(SCIPsolGetHeur(origsols[i])));
5372 SCIP_CALL( GCGmasterTransOrigSolToMasterVars(gcg, origsols[i], &stored) );
5373 if( stored )
5374 {
5375 ++nstoredsols;
5376 }
5377 }
5378 SCIPdebugMessage("GCGmasterTransOrigSolToMasterVars() transferred %d original feasible solutions\n",
5379 nstoredsols);
5380 /* return if we transferred solutions as the master should be feasible */
5381 if( nstoredsols > 0 )
5382 {
5383 farkaspricing->incCalls();
5384#ifdef SCIP_STATISTIC
5385 pricerdata->rootfarkastime = SCIPgetSolvingTime(scip_);
5386#endif
5387 return SCIP_OKAY;
5388 }
5389 }
5390
5391 if( pricerdata->useartificialvars && farkaspricing->getCalls() == 0 )
5392 {
5393 SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "Add artificial variables ensuring the restricted master problem is feasible.\n");
5394 SCIP_CALL( addArtificialVars() );
5395 farkaspricing->incCalls();
5396 return SCIP_OKAY;
5397 }
5398
5399 GCGpricestoreStartFarkas(pricestore);
5400 if( pricerdata->usecolpool )
5401 GCGcolpoolStartFarkas(colpool);
5402
5403 /* executing the pre-pricing method of the pricing callback plugins. */
5404 SCIP_CALL( pricingcbsPrepricing(pricer, GCG_PRICETYPE_FARKAS, &abort) );
5405
5406 /*If one of the pre-pricing methods of the pricing callback plugins indicates that the pricing must be aborted,
5407 * then no columns are generated
5408 */
5409 if( abort )
5410 return SCIP_OKAY;
5411
5412 SCIP_CALL( farkaspricing->startClock() );
5413 retcode = priceNewVariables(farkaspricing, result, NULL);
5414 SCIP_CALL( farkaspricing->stopClock() );
5415
5416 /* executing the post-pricing method of the pricing callback plugins. */
5417 SCIP_CALL( pricingcbsPostpricing(pricer, GCG_PRICETYPE_FARKAS) );
5418
5419#ifdef SCIP_STATISTIC
5420 pricerdata->rootfarkastime = SCIPgetSolvingTime(scip_);
5421#endif
5422
5423 return retcode;
5424}
5425
5426/** create the pointers for the pricing types */
5428{
5429 farkaspricing = new FarkasPricing(gcg);
5430 SCIP_CALL( farkaspricing->addParameters() );
5431
5432 reducedcostpricing = new ReducedCostPricing(gcg);
5433 SCIP_CALL( reducedcostpricing->addParameters() );
5434
5435 pricingtype = NULL;
5436
5437 return SCIP_OKAY;
5438}
5439
5440/** create the pricing controller */
5442{
5443 pricingcontroller = new Pricingcontroller(gcg);
5444 SCIP_CALL( pricingcontroller->addParameters() );
5445
5446 return SCIP_OKAY;
5447}
5448
5449/** create the pointers for the stabilization */
5451{
5452 SCIP_Bool usehybridascent;
5453
5454 usehybridascent = pricerdata->hybridascent ||
5456
5457
5458 stabilization = new Stabilization(gcg, reducedcostpricing, usehybridascent);
5459}
5460
5462{
5463 assert(farkaspricing != NULL);
5464 assert(reducedcostpricing != NULL);
5466
5468
5469 return SCIP_OKAY;
5470}
5471
5473{
5477 1.1 * MAX(reducedcostpricing->getMaxcolsround(), GCGgetNRelPricingprobs(gcg) * reducedcostpricing->getMaxcolsprob())) );
5478
5479 return SCIP_OKAY;
5480}
5481/*
5482 * variable pricer specific interface methods
5483 */
5484
5485/** creates the GCG variable pricer and includes it in SCIP */
5486extern "C"
5488 GCG* gcg /**< GCG data structure */
5489 )
5490{ /*lint -esym(429,pricer) */
5491 SCIP* origprob;
5493 ObjPricerGcg* pricer;
5494 SCIP_PRICERDATA* pricerdata = NULL;
5495 SCIP_EventhdlrData* eventhdlrdata = NULL;
5496
5499
5500 SCIP_CALL( SCIPallocMemory(masterprob, &pricerdata) );
5501
5502 /* initialize solvers array */
5503 pricerdata->solvers = NULL;
5504 pricerdata->nsolvers = 0;
5505 pricerdata->realdualvalues = NULL;
5506 pricerdata->artificialvars = NULL;
5507 pricerdata->nartificialvars = 0;
5508 pricerdata->maxartificialvars = 0;
5509
5510 /* initialize pricing callback array */
5511 pricerdata->pricingcbs = NULL;
5512 pricerdata->npricingcbs = 0;
5513
5514#ifdef SCIP_STATISTIC
5515 pricerdata->nodetimehist = NULL;
5516 pricerdata->foundvarshist = NULL;
5517#endif
5518
5519#ifdef _OPENMP
5520 pricerdata->locks = GCGgetLocks(gcg);
5521#endif
5522
5524 /* include variable pricer */
5526
5527 SCIP_CALL( pricer->createPricingTypes() );
5529
5530 gcg->pricer = reinterpret_cast<GCG_PRICER*>(pricer);
5531
5532 /* include event handler into master SCIP */
5533 SCIP_CALL( SCIPallocBlockMemory(masterprob, &eventhdlrdata) );
5534 eventhdlrdata->gcg = gcg;
5536 NULL, eventFreeVardeleted, eventInitVardeleted, eventExitVardeleted,
5538 eventhdlrdata) );
5539
5541
5542 SCIP_CALL( SCIPaddBoolParam(origprob, "pricing/masterpricer/abortpricingint",
5543 "should pricing be aborted due to integral objective function?",
5545
5546 SCIP_CALL( SCIPaddRealParam(origprob, "pricing/masterpricer/abortpricinggap",
5547 "gap between dual bound and RMP objective at which pricing is aborted",
5548 &pricerdata->abortpricinggap, TRUE, DEFAULT_ABORTPRICINGGAP, 0.0, 1.0, NULL, NULL) );
5549
5550 SCIP_CALL( SCIPaddBoolParam(origprob, "pricing/masterpricer/dispinfos",
5551 "should additional informations concerning the pricing process be displayed?",
5552 &pricerdata->dispinfos, FALSE, DEFAULT_DISPINFOS, NULL, NULL) );
5553
5554#ifdef _OPENMP
5555 SCIP_CALL( SCIPaddIntParam(origprob, "pricing/masterpricer/nthreads",
5556 "maximum number of threads used to parallelize pricing (0: automatic)",
5557 (int*)&pricerdata->maxnthreads, FALSE, DEFAULT_NTHREADS, 0, omp_get_max_threads(), NULL, NULL) );
5558#ifdef SCIP_STATISTIC
5559 /* statistics are not threadsafe */
5560 SCIP_CALL( SCIPsetIntParam(origprob, "pricing/masterpricer/nthreads", 1) );
5561 SCIP_CALL( SCIPfixParam(origprob, "pricing/masterpricer/nthreads") );
5562#endif
5563#endif
5564
5565 SCIP_CALL( SCIPaddBoolParam(origprob, "pricing/masterpricer/stabilization",
5566 "should stabilization be performed?",
5568
5569 SCIP_CALL( SCIPaddBoolParam(origprob, "pricing/masterpricer/stabilizationtree",
5570 "should stabilization be performed in the tree (in nodes other than the root node)?",
5572
5573 SCIP_CALL( SCIPaddBoolParam(origprob, "pricing/masterpricer/usecolpool",
5574 "should the colpool be checked for negative redcost cols before solving the pricing problems?",
5575 &pricerdata->usecolpool, FALSE, DEFAULT_USECOLPOOL, NULL, NULL) );
5576
5577 SCIP_CALL( SCIPaddBoolParam(origprob, "pricing/masterpricer/preventduplicatecols",
5578 "should an existing master variable be reused when an original solution is transferred to the master problem, instead of creating a duplicate column?",
5580
5581 SCIP_CALL( SCIPaddBoolParam(origprob, "pricing/masterpricer/stabilization/hybridascent",
5582 "should hybridization of smoothing with an ascent method be enabled?",
5583 &pricerdata->hybridascent, FALSE, DEFAULT_HYBRIDASCENT, NULL, NULL) );
5584
5585 SCIP_CALL( SCIPaddBoolParam(origprob, "pricing/masterpricer/stabilization/hybridascentnoagg",
5586 "should hybridization of smoothing with an ascent method be enabled if pricing problems cannot be aggregation?",
5588
5589 SCIP_CALL( SCIPaddBoolParam(origprob, "pricing/masterpricer/useartificialvars",
5590 "should artificial variables be used to make the RMP feasible (instead of applying Farkas pricing)?",
5592
5593 SCIP_CALL( SCIPaddBoolParam(origprob, "pricing/masterpricer/usemaxobj",
5594 "use maxobj for big M objective of artificial variables",
5595 &pricerdata->usemaxobj, FALSE, DEFAULT_USEMAXOBJ, NULL, NULL) );
5596
5597 SCIP_CALL( SCIPaddBoolParam(origprob, "pricing/masterpricer/onlyreliablebigm",
5598 "only use maxobj for big M objective of artificial variables if it is reliable",
5600
5601 SCIP_CALL( SCIPaddRealParam(origprob, "pricing/masterpricer/factorunreliable",
5602 "factor to use for objective of unbounded variables",
5604
5605 SCIP_CALL( SCIPaddRealParam(origprob, "pricing/masterpricer/bigmartificial",
5606 "value for for big M objective of artificial variables (negative if max obj should be used)",
5608
5610
5611 SCIP_CALL( SCIPaddIntParam(origprob, "pricing/masterpricer/disablecutoff",
5612 "should the cutoffbound be applied in master LP solving (0: on, 1:off, 2:auto)?",
5613 &pricerdata->disablecutoff, FALSE, DEFAULT_DISABLECUTOFF, 0, 2, paramChgdDisablecutoff, NULL) );
5614
5615 SCIP_CALL( SCIPaddIntParam(origprob, "pricing/masterpricer/colpool/agelimit",
5616 "age limit for columns in column pool? (-1 for no limit)",
5617 &pricerdata->colpoolagelimit, FALSE, DEFAULT_COLPOOL_AGELIMIT, -1, INT_MAX, NULL, NULL) );
5618
5619 SCIP_CALL( SCIPaddRealParam(origprob, "pricing/masterpricer/pricestore/redcostfac",
5620 "factor of -redcost/norm in score function",
5621 &pricerdata->redcostfac, FALSE, DEFAULT_PRICE_REDCOSTFAC, 0.0, 10.0, NULL, NULL) );
5622
5623 SCIP_CALL( SCIPaddRealParam(origprob, "pricing/masterpricer/pricestore/objparalfac",
5624 "factor of objective parallelism in score function",
5625 &pricerdata->objparalfac, FALSE, DEFAULT_PRICE_OBJPARALFAC, 0.0, 10.0, NULL, NULL) );
5626
5627 SCIP_CALL( SCIPaddRealParam(origprob, "pricing/masterpricer/pricestore/orthofac",
5628 "factor of orthogonalities in score function",
5629 &pricerdata->orthofac, FALSE, DEFAULT_PRICE_ORTHOFAC, 0.0, 10.0, NULL, NULL) );
5630
5631 SCIP_CALL( SCIPaddRealParam(origprob, "pricing/masterpricer/pricestore/mincolorth",
5632 "minimal orthogonality of columns to add",
5633 &pricerdata->mincolorth, FALSE, DEFAULT_PRICE_MINCOLORTH, 0.0, 1.0, NULL, NULL) );
5634
5635 SCIP_CALL( SCIPaddIntParam(origprob, "pricing/masterpricer/pricestore/efficiacychoice",
5636 "choice to base efficiacy on",
5637 (int*)&pricerdata->efficiacychoice, FALSE, DEFAULT_PRICE_EFFICIACYCHOICE, 0, 2, NULL, NULL) );
5638
5639 return SCIP_OKAY;
5640}
5641
5642/** returns the array of variables that were priced in during the solving process */
5643extern "C"
5645 GCG* gcg /**< GCG data structure */
5646 )
5647{
5648 ObjPricerGcg* pricer;
5649 SCIP_PRICERDATA* pricerdata;
5650
5651 pricer = GCGgetObjPricer(gcg);
5652 assert(pricer != NULL);
5653
5654 pricerdata = pricer->getPricerdata();
5655 assert(pricerdata != NULL);
5656
5657 return pricerdata->pricedvars;
5658}
5659
5660/** returns the number of variables that were priced in during the solving process */
5661extern "C"
5663 GCG* gcg /**< GCG data structure */
5664 )
5665{
5666 ObjPricerGcg* pricer;
5667 SCIP_PRICERDATA* pricerdata;
5668
5669 pricer = GCGgetObjPricer(gcg);
5670 assert(pricer != NULL);
5671
5672 pricerdata = pricer->getPricerdata();
5673 assert(pricerdata != NULL);
5674
5675 return pricerdata->npricedvars;
5676}
5677
5678
5679/** adds the given constraint and the given position to the hashmap of the pricer */
5680extern "C"
5682 GCG* gcg, /**< GCG data structure */
5683 SCIP_CONS* cons, /**< the constraint that should be added */
5684 int pos /**< the position of the constraint in the relaxator's masterconss array */
5685 )
5686{
5687 ObjPricerGcg* pricer;
5688 SCIP_PRICERDATA* pricerdata;
5689
5690 assert(cons != NULL);
5691 assert(pos >= 0);
5692
5693 pricer = GCGgetObjPricer(gcg);
5694 assert(pricer != NULL);
5695
5696 pricerdata = pricer->getPricerdata();
5697 assert(pricerdata != NULL);
5698
5699 SCIP_CALL( SCIPhashmapInsert(pricerdata->mapcons2idx, cons, (void*)(size_t)pos) );
5700 assert((int)(size_t)SCIPhashmapGetImage(pricerdata->mapcons2idx, cons) == pos); /*lint !e507*/
5701
5702 SCIPdebugMessage("Added cons %s (%p) to hashmap with index %d\n", SCIPconsGetName(cons), (void*) cons, pos);
5703
5704 return SCIP_OKAY;
5705}
5706
5707#ifdef SCIP_STATISTIC
5708/** sets the optimal LP solution in the pricerdata */
5709extern "C"
5711 GCG* gcg, /**< GCG data structure */
5712 SCIP_SOL** sol /**< pointer to optimal solution to root LP */
5713 )
5714{
5715 ObjPricerGcg* pricer;
5716 SCIP_PRICERDATA* pricerdata;
5717
5718 pricer = GCGgetObjPricer(gcg);
5719 assert(pricer != NULL);
5720
5721 pricerdata = pricer->getPricerdata();
5722 assert(pricerdata != NULL);
5723
5724 pricerdata->rootlpsol = *sol;
5725
5726 return SCIP_OKAY;
5727}
5728
5729/** gets the optimal LP solution in the pricerdata */
5730extern "C"
5731SCIP_SOL* GCGmasterGetRootLPSol(
5732 GCG* gcg /**< GCG data structure */
5733 )
5734{
5735 ObjPricerGcg* pricer;
5736 SCIP_PRICERDATA* pricerdata;
5737
5738 pricer = GCGgetObjPricer(gcg);
5739 assert(pricer != NULL);
5740
5741 pricerdata = pricer->getPricerdata();
5742 assert(pricerdata != NULL);
5743
5744 return pricerdata->rootlpsol;
5745}
5746#endif
5747
5748/** includes a solver into the pricer data */
5749extern "C"
5751 GCG* gcg, /**< GCG data structure */
5752 const char* name, /**< name of solver */
5753 const char* desc, /**< description of solver */
5754 int priority, /**< priority of solver */
5755 SCIP_Bool heurenabled, /**< flag to indicate whether heuristic solving method of the solver is enabled */
5756 SCIP_Bool exactenabled, /**< flag to indicate whether exact solving method of the solver is enabled */
5757 GCG_DECL_SOLVERUPDATE((*solverupdate)), /**< update method for solver */
5758 GCG_DECL_SOLVERSOLVE ((*solversolve)), /**< solving method for solver */
5759 GCG_DECL_SOLVERSOLVEHEUR((*solversolveheur)), /**< heuristic solving method for solver */
5760 GCG_DECL_SOLVERFREE ((*solverfree)), /**< free method of solver */
5761 GCG_DECL_SOLVERINIT ((*solverinit)), /**< init method of solver */
5762 GCG_DECL_SOLVEREXIT ((*solverexit)), /**< exit method of solver */
5763 GCG_DECL_SOLVERINITSOL((*solverinitsol)), /**< initsol method of solver */
5764 GCG_DECL_SOLVEREXITSOL((*solverexitsol)), /**< exitsol method of solver */
5765 GCG_SOLVERDATA* solverdata /**< pricing solver data */
5766 )
5767{
5768 GCG_SOLVER* solver;
5769 ObjPricerGcg* pricer;
5770 SCIP_PRICERDATA* pricerdata;
5771
5772 pricer = GCGgetObjPricer(gcg);
5773 assert(pricer != NULL);
5774
5775 pricerdata = pricer->getPricerdata();
5776 assert(pricerdata != NULL);
5777
5778 /* create pricing solver */
5779 solver = NULL;
5780 SCIP_CALL( GCGsolverCreate(gcg, &solver, name, desc, priority, heurenabled, exactenabled,
5781 solverupdate, solversolve, solversolveheur, solverfree, solverinit, solverexit, solverinitsol, solverexitsol,
5782 solverdata) );
5783 assert(solver != NULL);
5784
5785 /* add solver to pricer data */
5786 if( pricerdata->nsolvers == 0 )
5787 {
5788 SCIP_CALL( SCIPallocMemoryArray(scip_, &(pricerdata->solvers), 1) ); /*lint !e506*/
5789 }
5790 else
5791 {
5792 SCIP_CALL( SCIPreallocMemoryArray(scip_, &(pricerdata->solvers), (size_t)pricerdata->nsolvers+1) );
5793 }
5794 pricerdata->solvers[pricerdata->nsolvers] = solver;
5795 ++pricerdata->nsolvers;
5796
5797 return SCIP_OKAY;
5798}
5799
5800/** returns the available pricing solvers */
5801extern "C"
5803 GCG* gcg /**< GCG data structure */
5804 )
5805{
5806 ObjPricerGcg* pricer;
5807 SCIP_PRICERDATA* pricerdata;
5808
5809 pricer = GCGgetObjPricer(gcg);
5810 assert(pricer != NULL);
5811
5812 pricerdata = pricer->getPricerdata();
5813 assert(pricerdata != NULL);
5814
5815 return pricerdata->solvers;
5816}
5817
5818/** returns the number of available pricing solvers */
5819extern "C"
5821 GCG* gcg /**< GCG data structure */
5822 )
5823{
5824 ObjPricerGcg* pricer;
5825 SCIP_PRICERDATA* pricerdata;
5826
5827 pricer = GCGgetObjPricer(gcg);
5828 assert(pricer != NULL);
5829
5830 pricerdata = pricer->getPricerdata();
5831 assert(pricerdata != NULL);
5832
5833 return pricerdata->nsolvers;
5834}
5835
5836/** writes out a list of all pricing problem solvers */
5837extern "C"
5839 GCG* gcg /**< GCG data structure */
5840 )
5841{
5842 ObjPricerGcg* pricer;
5843 SCIP_PRICERDATA* pricerdata;
5844 int nsolvers;
5845 int i;
5847
5849
5850 pricer = GCGgetObjPricer(gcg);
5851 assert(pricer != NULL);
5852
5853 pricerdata = pricer->getPricerdata();
5854 assert(pricerdata != NULL);
5855
5856 assert((pricerdata->solvers == NULL) == (pricerdata->nsolvers == 0));
5857
5858 nsolvers = pricerdata->nsolvers;
5859
5860 SCIPdialogMessage(masterprob, NULL, " solver priority heur exact description\n");
5861 SCIPdialogMessage(masterprob, NULL, " -------------- -------- ----- ----- -----------\n");
5862
5863 for( i = 0; i < nsolvers; ++i )
5864 {
5865 SCIPdialogMessage(masterprob, NULL, " %-20s", GCGsolverGetName(pricerdata->solvers[i]));
5867 SCIPdialogMessage(masterprob, NULL, " %5s", GCGsolverIsHeurEnabled(pricerdata->solvers[i]) ? "TRUE" : "FALSE");
5868 SCIPdialogMessage(masterprob, NULL, " %5s", GCGsolverIsExactEnabled(pricerdata->solvers[i]) ? "TRUE" : "FALSE");
5869 SCIPdialogMessage(masterprob, NULL, " %s\n", GCGsolverGetDesc(pricerdata->solvers[i]));
5870 }
5871}
5872
5873/** prints pricing solver statistics */
5874extern "C"
5876 GCG* gcg, /**< GCG data structure */
5877 FILE* file /**< output file */
5878)
5879{
5880 ObjPricerGcg* pricer;
5881 SCIP_PRICERDATA* pricerdata;
5883
5885
5886 pricer = GCGgetObjPricer(gcg);
5887 assert(pricer != NULL);
5888
5889 pricerdata = pricer->getPricerdata();
5890 assert(pricerdata != NULL);
5891
5892 /**@todo add constraint statistics: how many constraints (instead of cuts) have been added? */
5894 "Pricing Solver : #HeurFarkas #OptFarkas #HeurRedcost #OptRedcost Time: HeurFarkas OptFarkas HeurRedcost OptRedcost\n");
5895 for( int i = 0; i < pricerdata->nsolvers; ++i )
5896 {
5897 GCG_SOLVER* solver;
5898 solver = pricerdata->solvers[i];
5899 assert(solver != NULL);
5900
5902 GCGsolverGetName(solver));
5904 " %11d %11d %11d %11d %10.2f %10.2f %10.2f %10.2f \n",
5911 }
5912}
5913
5914/** prints pricer statistics */
5915extern "C"
5917 GCG* gcg, /**< GCG data structure */
5918 FILE* file /**< output file */
5919 )
5920{
5921 ObjPricerGcg* pricer;
5922 SCIP_PRICERDATA* pricerdata;
5923 const PricingType* farkas;
5924 const PricingType* redcost;
5925 int i;
5926#ifdef SCIP_STATISTIC
5927 double start;
5928 double end;
5929#endif
5931
5933
5934 pricer = GCGgetObjPricer(gcg);
5935 assert(pricer != NULL);
5936
5937 pricerdata = pricer->getPricerdata();
5938 assert(pricerdata != NULL);
5939
5940 /**@todo add constraint statistics: how many constraints (instead of cuts) have been added? */
5941
5942 /* print of Pricing Statistics */
5943
5944 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(masterprob), file, "Farkas pricing Statistic:\nno.\t#Calls\t\t#Vars\t\ttime(s)\n");
5945
5946 for( i = 0; i < pricerdata->npricingprobs; i++ )
5947 {
5948 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(masterprob), file, "%d \t %d \t\t %d \t\t %.2f \n", i, pricerdata->farkascallsdist[i],
5949 pricerdata->farkasfoundvars[i], pricerdata->farkasnodetimedist[i]);
5950
5951 }
5952
5953 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(masterprob), file, "Reduced Cost pricing Statistic:\nno.\t#Calls\t\t#Vars\t\ttime(s)\n");
5954
5955 for( i = 0; i < pricerdata->npricingprobs; i++ )
5956 {
5957 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(masterprob), file, "%d \t %d \t\t %d \t\t %.2f \n", i, pricerdata->redcostcallsdist[i],
5958 pricerdata->redcostfoundvars[i], pricerdata->redcostnodetimedist[i]);
5959
5960 }
5961
5962#ifdef SCIP_STATISTIC
5963 /* print of Histogram Buckets !=0 */
5964
5965 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(masterprob), file, "Histogram Time\n");
5966 for( i = 0; i < PRICER_STAT_ARRAYLEN_TIME; i++ )
5967 {
5968 start = (1.0 * i * PRICER_STAT_BUCKETSIZE_TIME)/1000.0;
5969 end = start + PRICER_STAT_BUCKETSIZE_TIME/1000.0;
5970
5971 if( pricerdata->nodetimehist[i] != 0 )
5972 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(masterprob), file, "From\t%.4f\t-\t%.4f\ts:\t\t%d \n", start, end, pricerdata->nodetimehist[i]);
5973 }
5974
5975 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(masterprob), file, "Histogram Found Vars\n");
5976
5977 for( i = 0; i < PRICER_STAT_ARRAYLEN_VARS; i++ )
5978 {
5980 end = start + PRICER_STAT_BUCKETSIZE_VARS;
5981
5982 if( pricerdata->foundvarshist[i] != 0 )
5983 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(masterprob), file, "From\t%.0f\t-\t%.0f\tvars:\t\t%d \n", start, end, pricerdata->foundvarshist[i]);
5984 }
5985
5986 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(masterprob), file, "Root bounds \n");
5987 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(masterprob), file, " iter pb db time dualdiff dualoptdiff\n");
5988
5989 for( i = 0; i < pricerdata->nrootbounds; i++ )
5990 {
5991 SCIP_Real pb;
5992 SCIP_Real db;
5993 SCIP_Real time;
5994 SCIP_Real dualdiff;
5995 SCIP_Real dualoptdiff;
5996
5997 pb = pricerdata->rootpbs[i];
5998 db = pricerdata->rootdbs[i];
5999 time = pricerdata->roottimes[i];
6000 dualdiff = pricerdata->rootdualdiffs[i];
6001 pricer->computeDualDiff(pricerdata->dualvalues[i], pricerdata->dualsolconvs[i], pricerdata->dualvalues[pricerdata->nrootbounds - 1], pricerdata->dualsolconvs[pricerdata->nrootbounds - 1], &dualoptdiff);
6002
6003 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(masterprob), file, "%5d %13.6e %13.6e %15.5f %15.5f %15.5f\n", i, pb, db, time, dualdiff, dualoptdiff);
6004 }
6005#endif
6006
6007 redcost = pricer->getReducedCostPricing();
6008 assert( redcost != NULL );
6009 farkas = pricer->getFarkasPricing();
6010 assert( farkas != NULL );
6011
6012 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(masterprob), file, "Pricing Summary:\n");
6013 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(masterprob), file, "Calls : %d\n", pricerdata->calls);
6014 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(masterprob), file, "Farkas Pricing Calls : %d\n", farkas->getCalls());
6015 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(masterprob), file, "Farkas Pricing Time : %f\n", farkas->getClockTime());
6016 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(masterprob), file, "Reduced Cost Pricing Calls : %d\n", redcost->getCalls());
6017 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(masterprob), file, "Reduced Cost Pricing Time : %f\n", redcost->getClockTime());
6018 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(masterprob), file, "Solved subMIPs Heuristic Pricing : %d\n", pricerdata->solvedsubmipsheur);
6019 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(masterprob), file, "Solved subMIPs Optimal Pricing : %d\n", pricerdata->solvedsubmipsoptimal);
6020 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(masterprob), file, "Time for transformation : %f\n", SCIPgetClockTime(masterprob, pricerdata->transformclock));
6021 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(masterprob), file, "Time for freeing subMIPs : %f\n", SCIPgetClockTime(masterprob, pricerdata->freeclock));
6022 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(masterprob), file, "Duplicate Columns Avoided : %d\n", pricerdata->nduplicatecols);
6023 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(masterprob), file, "Time for duplicate column check : %f\n", SCIPgetClockTime(masterprob, pricerdata->duplicatecolclock));
6024
6025}
6026
6027/** method to get existence of rays */
6028extern "C"
6030 GCG* gcg, /**< GCG data structure */
6031 SCIP_Bool* exist /**< pointer to store if there exists any ray */
6032 )
6033{
6034 int prob;
6035
6036 ObjPricerGcg* pricer;
6037 SCIP_PRICERDATA* pricerdata;
6038
6039 pricer = GCGgetObjPricer(gcg);
6040 assert(pricer != NULL);
6041
6042 pricerdata = pricer->getPricerdata();
6043 assert(pricerdata != NULL);
6044
6045 *exist = FALSE;
6046
6047 for( prob = 0; prob < pricerdata->npricingprobs; ++prob )
6048 {
6049 if( pricerdata->nraysprob[prob] > 0 )
6050 {
6051 *exist = TRUE;
6052 break;
6053 }
6054 }
6055
6056 return SCIP_OKAY;
6057}
6058
6059/** get the number of extreme points that a pricing problem has generated so far */
6060extern "C"
6062 GCG* gcg, /**< GCG data structure */
6063 int probnr /**< index of pricing problem */
6064 )
6065{
6066 ObjPricerGcg* pricer;
6067 SCIP_PRICERDATA* pricerdata;
6068
6069 pricer = GCGgetObjPricer(gcg);
6070 assert(pricer != NULL);
6071
6072 pricerdata = pricer->getPricerdata();
6073 assert(pricerdata != NULL);
6074
6075 if( !GCGisPricingprobRelevant(gcg, probnr) )
6076 return 0;
6077 else
6078 return pricerdata->npointsprob[probnr];
6079}
6080
6081/** get the number of extreme rays that a pricing problem has generated so far */
6082extern "C"
6084 GCG* gcg, /**< GCG data structure */
6085 int probnr /**< index of pricing problem */
6086 )
6087{
6088 ObjPricerGcg* pricer;
6089 SCIP_PRICERDATA* pricerdata;
6090
6091 pricer = GCGgetObjPricer(gcg);
6092 assert(pricer != NULL);
6093
6094 pricerdata = pricer->getPricerdata();
6095 assert(pricerdata != NULL);
6096
6097 if( !GCGisPricingprobRelevant(gcg, probnr) )
6098 return 0;
6099 else
6100 return pricerdata->nraysprob[probnr];
6101}
6102
6103/** get the number of columns to be added to the master LP in the current pricing round */
6104extern "C"
6106 GCG* gcg /**< GCG data structure */
6107 )
6108{
6109 ObjPricerGcg* pricer;
6110
6111 pricer = GCGgetObjPricer(gcg);
6112 assert(pricer != NULL);
6113
6114 return pricer->getMaxColsRound();
6115}
6116
6117/** get the number of columns per pricing problem to be added to the master LP in the current pricing round */
6118extern "C"
6120 GCG* gcg /**< GCG data structure */
6121 )
6122{
6123 ObjPricerGcg* pricer;
6124
6125 pricer = GCGgetObjPricer(gcg);
6126 assert(pricer != NULL);
6127
6128 return pricer->getMaxColsProb();
6129}
6130
6131/** add a new column to the pricing storage */
6132extern "C"
6134 GCG* gcg, /**< GCG data structure */
6135 GCG_COL* col /**< priced col */
6136 )
6137{
6138 ObjPricerGcg* pricer;
6139
6140 pricer = GCGgetObjPricer(gcg);
6141 assert(pricer != NULL);
6142
6143 SCIP_CALL( pricer->addColToPricestore(col, NULL) );
6144
6145 return SCIP_OKAY;
6146}
6147
6148/** add a new column to the pricing storage */
6149extern "C"
6151 GCG* gcg, /**< GCG data structure */
6152 GCG_COL* col, /**< priced col */
6153 SCIP_Bool* added
6154 )
6155{
6156 ObjPricerGcg* pricer;
6157
6158 pricer = GCGgetObjPricer(gcg);
6159 assert(pricer != NULL);
6160
6161 SCIP_CALL( pricer->addColToPricestore(col, added) );
6162
6163 return SCIP_OKAY;
6164}
6165
6166/** transfers a primal solution of the original problem into the master variable space,
6167 * i.e. creates one master variable for each block and adds the solution to the master problem */
6168extern "C"
6170 GCG* gcg, /**< GCG data structure */
6171 SCIP_SOL* origsol, /**< the solution that should be transferred */
6172 SCIP_Bool* stored /**< pointer to store if transferred solution is feasible (or NULL) */
6173 )
6174{
6175 ObjPricerGcg* pricer = NULL;
6176 SCIP_PRICERDATA* pricerdata = NULL;
6177 SCIP_SOL* mastersol = NULL;
6178 SCIP_VAR* newvar = NULL;
6179 SCIP* origprob = NULL;
6180 SCIP_Bool added;
6181 int prob;
6182 int i;
6183 int j;
6184
6185 SCIP_VAR** origvars = NULL;
6186 SCIP_Real* origsolvals = NULL;
6187 int norigvars;
6188
6189 SCIP_VAR*** pricingvars = NULL;
6190 SCIP_Real** pricingvals = NULL;
6191 int* npricingvars = NULL;
6193
6195
6197 assert(origprob != NULL);
6198
6199 /*
6200 * Due to global domain changes, it might happen that the solution is not feasible for the
6201 * transformed original problem anymore; in that case, do not tranfer it to the master
6202 */
6203 SCIP_CALL( SCIPcheckSol(origprob, origsol, FALSE, FALSE, TRUE, TRUE, TRUE, &added) );
6204 if( !added )
6205 {
6206 if( stored != NULL)
6207 *stored = FALSE;
6208 return SCIP_OKAY;
6209 }
6210
6211 pricerdata = NULL; /* the pricerdata is set to NULL when the Benders' decomposition mode is used. */
6213 {
6214 pricer = GCGgetObjPricer(gcg);
6215 assert(pricer != NULL);
6216
6217 pricerdata = pricer->getPricerdata();
6218 assert(pricerdata != NULL);
6219 }
6220
6221 /* now compute coefficients of the master variables in the master constraint */
6222 origvars = SCIPgetVars(origprob);
6223 norigvars = SCIPgetNVars(origprob);
6224
6225 /* allocate memory for storing variables and solution values from the solution */
6226 SCIP_CALL( SCIPallocBufferArray(masterprob, &origsolvals, norigvars) ); /*lint !e530*/
6227
6228 if( pricerdata != NULL )
6229 {
6230 SCIP_CALL( SCIPallocBufferArray(masterprob, &pricingvars, pricerdata->npricingprobs) ); /*lint !e530*/
6231 SCIP_CALL( SCIPallocBufferArray(masterprob, &pricingvals, pricerdata->npricingprobs) ); /*lint !e530*/
6232 SCIP_CALL( SCIPallocBufferArray(masterprob, &npricingvars, pricerdata->npricingprobs) ); /*lint !e530*/
6233
6234 for( i = 0; i < pricerdata->npricingprobs; i++ )
6235 {
6236 int representative;
6237 representative = GCGgetBlockRepresentative(gcg, i);
6238 npricingvars[i] = 0;
6239
6240 SCIP_CALL( SCIPallocBufferArray(masterprob, &(pricingvars[i]), SCIPgetNVars(pricerdata->pricingprobs[representative])) ); /*lint !e866*/
6241 SCIP_CALL( SCIPallocBufferArray(masterprob, &(pricingvals[i]), SCIPgetNVars(pricerdata->pricingprobs[representative])) ); /*lint !e866*/
6242 }
6243 }
6244
6245 /* get solution values */
6246 SCIP_CALL( SCIPgetSolVals(masterprob, origsol, norigvars, origvars, origsolvals) );
6247 SCIP_CALL( SCIPcreateSol(masterprob, &mastersol, NULL) );
6248
6249 /* store variables and solutions into arrays */
6250 for( i = 0; i < norigvars; i++ )
6251 {
6252 int blocknr;
6253 assert(GCGvarIsOriginal(origvars[i]));
6254 blocknr = GCGvarGetBlock(origvars[i]);
6255 assert(blocknr < 0 || GCGoriginalVarGetPricingVar(origvars[i]) != NULL);
6256
6257 if( blocknr >= 0 )
6258 {
6259 if( pricerdata != NULL && !SCIPisZero(masterprob, origsolvals[i]) )
6260 {
6261 pricingvars[blocknr][npricingvars[blocknr]] = GCGoriginalVarGetPricingVar(origvars[i]);
6262 pricingvals[blocknr][npricingvars[blocknr]] = origsolvals[i];
6263 npricingvars[blocknr]++;
6264 }
6265 }
6266 else
6267 {
6269
6270 assert((GCGoriginalVarGetNMastervars(origvars[i]) == 1) || (GCGoriginalVarIsLinking(origvars[i])));
6271 assert(GCGoriginalVarGetMastervars(origvars[i])[0] != NULL);
6272
6273 mastervar = GCGoriginalVarGetMastervars(origvars[i])[0];
6274
6276 {
6278 }
6279 else
6280 {
6281 SCIP_CALL( SCIPsetSolVal(masterprob, mastersol, mastervar, origsolvals[i]) );
6282 }
6283
6284 if( GCGoriginalVarIsLinking(origvars[i]) )
6285 {
6286 if( pricerdata != NULL )
6287 {
6288 if( !SCIPisZero(masterprob, origsolvals[i]) )
6289 {
6290 int* blocks = NULL;
6291 int nblocks = GCGlinkingVarGetNBlocks(origvars[i]);
6292 SCIP_CALL( SCIPallocBufferArray(masterprob, &blocks, nblocks) ); /*lint !e530*/
6293 SCIP_CALL( GCGlinkingVarGetBlocks(origvars[i], nblocks, blocks) );
6294 for ( j = 0; j < nblocks; ++j)
6295 {
6296 prob = blocks[j];
6297
6298 pricingvars[prob][npricingvars[prob]] = GCGlinkingVarGetPricingVars(origvars[i])[prob];
6299 pricingvals[prob][npricingvars[prob]] = origsolvals[i];
6300 npricingvars[prob]++;
6301 }
6303
6304 }
6305 }
6306 else
6307 {
6309 {
6311 }
6312 else
6313 {
6314 SCIP_CALL( SCIPsetSolVal(masterprob, mastersol, mastervar, origsolvals[i]) );
6315 }
6316 }
6317 }
6318 }
6319 }
6320
6321 /* create variables in the master problem and filter duplicates optionally */
6322 if( pricerdata != NULL )
6323 {
6324 SCIP_HASHTABLE* mastervarhash = NULL;
6325 GCG_MASTERVARKEY* mvkeys = NULL;
6326 SCIP_VAR** candvars = NULL;
6327 SCIP_Real* candvals = NULL;
6328 int nmvkeys = 0;
6329 int ncandvars = 0;
6330
6331 if( pricerdata->preventduplicatecols )
6332 {
6333 SCIP_VAR** pricedvars;
6334 int npricedvars;
6335
6337
6338 pricedvars = GCGmasterGetPricedvars(gcg);
6339 npricedvars = GCGmasterGetNPricedvars(gcg);
6340
6341 /* the candidate columns are described in terms of original variables, just as the master variables are */
6342 for( prob = 0; prob < pricerdata->npricingprobs; prob++ )
6343 ncandvars += npricingvars[prob];
6344
6345 SCIP_CALL( SCIPallocBufferArray(masterprob, &mvkeys, npricedvars + pricerdata->npricingprobs) );
6346 SCIP_CALL( SCIPallocBufferArray(masterprob, &candvars, MAX(ncandvars, 1)) );
6347 SCIP_CALL( SCIPallocBufferArray(masterprob, &candvals, MAX(ncandvars, 1)) );
6348
6350 npricedvars + pricerdata->npricingprobs, hashGetKeyMastervarkey, hashKeyEqMastervarkey,
6351 hashKeyValMastervarkey, (void*) masterprob) );
6352
6353 /* register the columns that already exist */
6354 for( i = 0; i < npricedvars; i++ )
6355 {
6356 if( getMastervarKey(masterprob, pricedvars[i], &mvkeys[nmvkeys]) )
6357 {
6358 if( SCIPhashtableRetrieve(mastervarhash, (void*) &mvkeys[nmvkeys]) == NULL )
6359 {
6360 SCIP_CALL( SCIPhashtableInsert(mastervarhash, (void*) &mvkeys[nmvkeys]) );
6361 ++nmvkeys;
6362 }
6363 }
6364 }
6365
6366 ncandvars = 0;
6367
6369 }
6370
6371 for( prob = 0; prob < pricerdata->npricingprobs; prob++ )
6372 {
6373 GCG_MASTERVARKEY* dupkey = NULL;
6374 int representative;
6375
6376 representative = GCGgetBlockRepresentative(gcg, prob);
6377
6378 if( mastervarhash != NULL )
6379 {
6380 GCG_MASTERVARKEY candkey;
6381
6383
6384 /* build the key of the column this block would create; mirrors what GCGcreateMasterVar stores, including
6385 * the rounding of integral values, so that identical columns also hash identically */
6386 candkey.mastervar = NULL;
6387 candkey.block = representative;
6388 candkey.nvars = npricingvars[prob];
6389 candkey.vars = &candvars[ncandvars];
6390 candkey.vals = &candvals[ncandvars];
6391
6392 for( j = 0; j < npricingvars[prob]; j++ )
6393 {
6394 SCIP_Real solval = pricingvals[prob][j];
6395
6396 if( SCIPvarIsIntegral(pricingvars[prob][j]) && SCIPisIntegral(masterprob, solval) )
6398
6399 candvars[ncandvars] = GCGpricingVarGetOrigvars(pricingvars[prob][j])[0];
6400 candvals[ncandvars] = solval;
6401 ++ncandvars;
6402 }
6403
6404 dupkey = (GCG_MASTERVARKEY*) SCIPhashtableRetrieve(mastervarhash, (void*) &candkey);
6405
6407 }
6408
6409 if( dupkey != NULL )
6410 {
6411 /* an identical column exists, reuse it instead of creating a copy */
6412 newvar = dupkey->mastervar;
6413 ++pricerdata->nduplicatecols;
6414
6416 {
6417 SCIPdebugMessage("transferred solution will be rejected: master variable <%s> reused for block %d "
6418 "is fixed to zero\n", SCIPvarGetName(newvar), prob);
6419 }
6420 }
6421 else
6422 {
6423 SCIP_CALL( pricer->createNewMasterVar(NULL, NULL, pricingvars[prob], pricingvals[prob], npricingvars[prob], FALSE, representative, TRUE, &added, &newvar) );
6424 assert(added);
6425
6426 if( mastervarhash != NULL )
6427 {
6429
6430 /* register the new column so that later blocks of this solution do not duplicate it either */
6431 if( getMastervarKey(masterprob, newvar, &mvkeys[nmvkeys]) )
6432 {
6433 SCIP_CALL( SCIPhashtableInsert(mastervarhash, (void*) &mvkeys[nmvkeys]) );
6434 ++nmvkeys;
6435 }
6436
6438 }
6439 }
6440
6441 SCIP_CALL( SCIPincSolVal(masterprob, mastersol, newvar, 1.0) );
6442 }
6443
6444 if( mastervarhash != NULL )
6445 {
6446 SCIPhashtableFree(&mastervarhash);
6447 SCIPfreeBufferArray(masterprob, &candvals);
6448 SCIPfreeBufferArray(masterprob, &candvars);
6450 }
6451 }
6452
6453#ifdef SCIP_DEBUG
6454 SCIP_CALL( SCIPtrySolFree(masterprob, &mastersol, TRUE, TRUE, TRUE, TRUE, TRUE, &added) );
6455#else
6456 SCIP_CALL( SCIPtrySolFree(masterprob, &mastersol, FALSE, FALSE, TRUE, TRUE, TRUE, &added) );
6457#endif
6458
6459 /* set external pointer if it is not NULL */
6460 if( stored != NULL )
6461 *stored = added;
6462
6463 /* free memory for storing variables and solution values from the solution */
6464 if( pricerdata != NULL )
6465 {
6466 for( i = pricerdata->npricingprobs - 1; i>= 0; i-- )
6467 {
6468 SCIPfreeBufferArray(masterprob, &(pricingvals[i]));
6469 SCIPfreeBufferArray(masterprob, &(pricingvars[i]));
6470 }
6471
6472 SCIPfreeBufferArray(masterprob, &npricingvars);
6473 SCIPfreeBufferArray(masterprob, &pricingvals);
6474 SCIPfreeBufferArray(masterprob, &pricingvars);
6475 }
6476 SCIPfreeBufferArray(masterprob, &origsolvals);
6477
6478 return SCIP_OKAY;
6479}
6480
6481
6482/** create initial master variables */
6483extern "C"
6485 GCG* gcg /**< GCG data structure */
6486 )
6487{
6488 SCIP* origprob;
6489 int i;
6490 SCIP_VAR** vars;
6491 int nvars;
6492 int npricingprobs;
6493 int v;
6495
6497
6499 assert(origprob != NULL);
6500
6501 npricingprobs = GCGgetNPricingprobs(gcg);
6502 assert(npricingprobs >= 0);
6503
6504 /* for variables in the original problem that do not belong to any block,
6505 * create the corresponding variable in the master problem
6506 */
6509 for( v = 0; v < nvars; v++ )
6510 {
6511 SCIP_Real* coefs;
6512 int blocknr;
6513 int ncoefs;
6514 SCIP_VAR* var;
6515
6516 /* var = SCIPvarGetProbvar(vars[v]); */
6517 var = vars[v];
6518 blocknr = GCGvarGetBlock(var);
6519 coefs = GCGoriginalVarGetCoefs(var);
6520 ncoefs = GCGoriginalVarGetNCoefs(var);
6521
6523 if( blocknr < 0 )
6524 {
6525 SCIP_CONS** linkconss;
6526 SCIP_VAR* newvar;
6527
6529 SCIP_CALL( SCIPaddVar(masterprob, newvar) );
6530
6531 SCIP_CALL( GCGoriginalVarAddMasterVar(gcg, var, newvar, 1.0) );
6532
6533 linkconss = GCGoriginalVarGetMasterconss(var);
6534
6535 /* add variable in the master to the master constraints it belongs to */
6536 for( i = 0; i < ncoefs; i++ )
6537 {
6538 assert(!SCIPisZero(masterprob, coefs[i]));
6539
6540 SCIP_CALL( SCIPaddCoefLinear(masterprob, linkconss[i], newvar, coefs[i]) );
6541 }
6542
6543 /* we copied a linking variable into the master, add it to the linkcons */
6545 {
6546 SCIP_CONS** linkingconss;
6547 linkingconss = GCGlinkingVarGetLinkingConss(var);
6548
6549 /* the linking constraints could be NULL if the Benders' decomposition is used. */
6550 if( linkingconss != NULL )
6551 {
6552 for( i = 0; i < npricingprobs; i++ )
6553 {
6554 if( linkingconss[i] != NULL )
6555 {
6556 SCIP_CALL( SCIPaddCoefLinear(masterprob, linkingconss[i], newvar, 1.0) );
6557 }
6558 }
6559 }
6560 }
6561
6562 SCIP_CALL( SCIPreleaseVar(masterprob, &newvar) );
6563 }
6564 }
6565 return SCIP_OKAY;
6566}
6567
6568/** get root node degeneracy */
6569extern "C"
6571 GCG* gcg /**< GCG data structure */
6572 )
6573{
6574 ObjPricerGcg* pricer;
6575 SCIP_PRICERDATA* pricerdata;
6577
6579
6580 pricer = GCGgetObjPricer(gcg);
6581 assert(pricer != NULL);
6582
6583 pricerdata = pricer->getPricerdata();
6584 assert(pricerdata != NULL);
6585
6587 {
6588 return pricerdata->avgrootnodedegeneracy;
6589 }
6590 else
6591 return SCIPinfinity(masterprob);
6592}
6593
6594/** check if current sol is valid */
6595extern "C"
6597 GCG* gcg /**< GCG data structure */
6598 )
6599{
6600 ObjPricerGcg* pricer;
6601 SCIP_PRICERDATA* pricerdata;
6602 SCIP_SOL* sol;
6603 int i;
6605
6607
6608 /* checking the decomposition mode. If Benders' is used, then the solution is assumed to be valid. */
6610 return TRUE;
6611
6612 pricer = GCGgetObjPricer(gcg);
6613 assert(pricer != NULL);
6614
6615 pricerdata = pricer->getPricerdata();
6616 assert(pricerdata != NULL);
6617
6618 if( pricerdata->nartificialvars == 0 )
6619 return TRUE;
6620
6622 sol = NULL;
6625 else
6626 return TRUE;
6627
6628 for( i = 0; i < pricerdata->nartificialvars; ++i )
6629 {
6632
6634 return FALSE;
6635 }
6636
6637 return TRUE;
6638}
6639
6640extern "C"
6642 GCG* gcg /**< GCG data structure */
6643 )
6644{
6645 ObjPricerGcg* pricer;
6646 SCIP_PRICERDATA* pricerdata;
6647 SCIP_SOL* sol;
6648 int i;
6650
6652
6653 /* checking the decomposition mode. If Benders' is used, then the solution is assumed to be valid. */
6655 return TRUE;
6656
6657 pricer = GCGgetObjPricer(gcg);
6658 assert(pricer != NULL);
6659
6660 pricerdata = pricer->getPricerdata();
6661 assert(pricerdata != NULL);
6662
6664
6665 if( sol == NULL )
6666 return TRUE;
6667
6668 for( i = 0; i < pricerdata->nartificialvars; ++i )
6669 {
6672
6674 return FALSE;
6675 }
6676
6677 return TRUE;
6678}
6679
6680extern "C"
6682 GCG* gcg, /**< GCG data structure */
6683 SCIP_SOL* mastersol /**< solution of the master problem, or NULL for current LP solution */
6684 )
6685{
6686 ObjPricerGcg* pricer;
6687 SCIP_PRICERDATA* pricerdata;
6688 int i;
6690
6692
6693 /* checking the decomposition mode. If Benders' is used, then the solution is assumed to be valid. */
6695 return TRUE;
6696
6697 pricer = GCGgetObjPricer(gcg);
6698 assert(pricer != NULL);
6699
6700 pricerdata = pricer->getPricerdata();
6701 assert(pricerdata != NULL);
6702
6703 for( i = 0; i < pricerdata->nartificialvars; ++i )
6704 {
6706 solval = SCIPgetSolVal(masterprob, mastersol, pricerdata->artificialvars[i]);
6707
6709 return FALSE;
6710 }
6711
6712 return TRUE;
6713}
6714
6715
6716/* get number of iterations in pricing problems */
6717extern "C"
6719 GCG* gcg /**< GCG data structure */
6720 )
6721{
6722 ObjPricerGcg* pricer;
6723 SCIP_PRICERDATA* pricerdata;
6724
6725 pricer = GCGgetObjPricer(gcg);
6726 assert(pricer != NULL);
6727
6728 pricerdata = pricer->getPricerdata();
6729 assert(pricerdata != NULL);
6730
6731 return pricerdata->pricingiters;
6732}
6733
6734/** print simplex iteration statistics */
6735extern "C"
6737 GCG* gcg, /**< GCG data structure */
6738 FILE* file /**< output file */
6739 )
6740{
6741 ObjPricerGcg* pricer;
6742 SCIP_PRICERDATA* pricerdata;
6744
6746
6747 pricer = GCGgetObjPricer(gcg);
6748 assert(pricer != NULL);
6749
6750 pricerdata = pricer->getPricerdata();
6751 assert(pricerdata != NULL);
6752
6753 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(masterprob), file, "Simplex iterations : iter\n");
6755 {
6757 }
6758 else
6759 {
6760 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(masterprob), file, " Master LP : %10lld\n", 0LL);
6761 }
6762 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(masterprob), file, " Pricing LP : %10lld\n", pricerdata->pricingiters);
6763
6764 if( SCIPgetStage(pricer->getOrigprob()) >= SCIP_STAGE_SOLVING )
6765 {
6766 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(masterprob), file, " Original LP : %10lld\n", SCIPgetNLPIterations(pricer->getOrigprob()));
6767 }
6768 else
6769 {
6770 SCIPmessageFPrintInfo(SCIPgetMessagehdlr(masterprob), file, " Original LP : %10lld\n", 0LL);
6771 }
6772
6773 return SCIP_OKAY;
6774}
6775
6777{
6778 return pricerdata->solvers;
6779}
6780
6782{
6783 return pricerdata->nsolvers;
6784}
6785
6786extern "C"
6788 GCG* gcg
6789 )
6790{
6791 ObjPricerGcg* pricer;
6792
6793 pricer = GCGgetObjPricer(gcg);
6794 assert(pricer != NULL);
6795
6796 return pricer->colpool;
6797}
6798
6799/** get a weak reference to the current and latest varhistory pointer */
6801 GCG* gcg /**< GCG data structure */
6802 )
6803{
6804 ObjPricerGcg* pricer;
6805 SCIP_PRICERDATA* pricerdata;
6806
6807 assert(gcg != NULL);
6808
6809 pricer = GCGgetObjPricer(gcg);
6810 assert(pricer != NULL);
6811
6812 pricerdata = pricer->getPricerdata();
6813 assert(pricerdata != NULL);
6814
6815 return pricerdata->varhistory;
6816}
6817
6818#ifdef _OPENMP
6819extern "C"
6820int GCGpricerGetMaxNThreads(
6821 GCG* gcg /**< GCG data structure */
6822 )
6823{
6824 ObjPricerGcg* pricer;
6825 SCIP_PRICERDATA* pricerdata;
6826
6827 pricer = GCGgetObjPricer(gcg);
6828 assert(pricer != NULL);
6829
6830 pricerdata = pricer->getPricerdata();
6831 assert(pricerdata != NULL);
6832
6833 return pricerdata->maxnthreads;
6834}
6835#endif
6836
6837/** returns the GCG data structure */
6838extern "C"
6840 SCIP* masterprob /**< SCIP data structure */
6841 )
6842{
6843 ObjPricerGcg* pricer;
6844
6846
6847 pricer = static_cast<ObjPricerGcg*>(SCIPfindObjPricer(masterprob, PRICER_NAME));
6848 assert(pricer != NULL);
6849
6850 return pricer->getGcg();
6851}
6852
6853/** return number of active pricing modifications for a specific pricing problem */
6854extern "C"
6856 GCG* gcg, /**< GCG data structure */
6857 int probnr /**< number of pricing problem */
6858 )
6859{
6860 ObjPricerGcg* pricer;
6861 SCIP_PRICERDATA* pricerdata;
6862
6863 pricer = GCGgetObjPricer(gcg);
6864 assert(pricer != NULL);
6865
6866 pricerdata = pricer->getPricerdata();
6867 assert(pricerdata != NULL);
6868
6869 assert(probnr < pricerdata->npricingprobs);
6870 return pricerdata->nactivepricingmods[probnr];
6871}
6872
6873/** return number of actually applied pricing modifications for a specific pricing problem */
6874extern "C"
6876 GCG* gcg, /**< GCG data structure */
6877 int probnr /**< number of pricing problem */
6878 )
6879{
6880 ObjPricerGcg* pricer;
6881 SCIP_PRICERDATA* pricerdata;
6882
6883 pricer = GCGgetObjPricer(gcg);
6884 assert(pricer != NULL);
6885
6886 pricerdata = pricer->getPricerdata();
6887 assert(pricerdata != NULL);
6888
6889 assert(probnr < pricerdata->npricingprobs);
6890 return pricerdata->nappliedpricingmods[probnr];
6891}
SCIP_DECL_EVENTEXEC(EventhdlrNewSol::scip_exec)
SCIP_DECL_EVENTFREE(EventhdlrNewSol::scip_free)
int GCGbranchGenericBranchdataGetConsSsize(GCG_BRANCHDATA *branchdata)
GCG_COMPSEQUENCE * GCGbranchGenericBranchdataGetConsS(GCG_BRANCHDATA *branchdata)
#define EVENTHDLR_DESC
SCIP_Bool GCGisBranchruleGeneric(GCG_BRANCHRULE *branchrule)
#define EVENTHDLR_NAME
branching rule based on vanderbeck's generic branching scheme
@ GCG_COMPSENSE_GE
struct ComponentBoundSequence GCG_COMPSEQUENCE
SCIP_Real * r
FarkasPricing()=delete
SCIP_RETCODE createPricingcontroller()
SCIP_RETCODE computeColOriginalSepaCuts(GCG_COL *gcgcol)
GCG * getGcg() const
SCIP_RETCODE priceNewVariables(PricingType *pricetype, SCIP_RESULT *result, double *lowerbound)
const ReducedCostPricing * getReducedCostPricing() const
SCIP_Real computeRedCostGcgCol(PricingType *pricetype, GCG_Col *gcgcol, SCIP_Real *objvalptr) const
int getMaxColsRound() const
int getMaxColsProb() const
GCG_SOLVER ** getSolvers() const
void getBestCols(GCG_COL **pricingprobcols)
int getNumSolvers() const
SCIP_RETCODE createNewMasterVarFromGcgCol(PricingType *pricetype, GCG_COL *gcgcol, SCIP_Bool force, SCIP_Bool *added, SCIP_VAR **addedvar, SCIP_Real score)
SCIP_RETCODE createPricingTypes()
ReducedCostPricing * getReducedCostPricingNonConst()
SCIP_RETCODE createNewMasterVar(PricingType *pricetype, SCIP_SOL *sol, SCIP_VAR **solvars, double *solvals, int nsolvars, unsigned int solisray, int prob, unsigned int force, unsigned int *added, SCIP_VAR **addedvar)
ObjPricerGcg(GCG *gcgstruct, const char *name, const char *desc, int priority, unsigned int delay, SCIP_PRICERDATA *p_pricerdata)
SCIP_PRICERDATA * pricerdata
const FarkasPricing * getFarkasPricing() const
SCIP_RETCODE addArtificialVars()
SCIP_RETCODE getStabilizedDualObjectiveValue(PricingType *pricetype, SCIP_Real *stabdualval, SCIP_Bool stabilize)
SCIP_RETCODE createColpool()
SCIP_PRICERDATA * getPricerdata()
SCIP_RETCODE createPricestore()
SCIP_RETCODE setPricingObjs(PricingType *pricetype, SCIP_Bool stabilize)
SCIP_Real getDualconvsum(GCG_COL **bestcols)
GCG_PRICESTORE * pricestore
SCIP * getOrigprob() const
GCG_COLPOOL * colpool
SCIP_RETCODE pricingLoop(PricingType *pricetype, SCIP_RESULT *result, int *nfoundvars, SCIP_Real *lowerbound, SCIP_Bool *bestredcostvalid)
SCIP_RETCODE addColToPricestore(GCG_COL *col, SCIP_Bool *added)
SCIP_RETCODE computeDualDiff(SCIP_Real **dualvals1, SCIP_Real *dualconv1, SCIP_Real **dualvals2, SCIP_Real *dualconv2, SCIP_Real *dualdiff)
SCIP_Real getConvconsDualsol(PricingType *pricetype, int probnr)
FarkasPricing * getFarkasPricingNonConst()
SCIP_RETCODE addVariableToMastersepacutsFromGCGCol(SCIP_VAR *newvar, GCG_COL *gcgcol)
SCIP_RETCODE addVariableToMastersepacuts(SCIP_VAR *newvar, int prob, SCIP_VAR **solvars, SCIP_Real *solvals, int nsolvars)
void createStabilization()
SCIP_RETCODE computeColMastersepacutCoeffs(GCG_COL *gcgcol)
SCIP_RETCODE computeColMastercoefs(GCG_COL *gcgcol)
int getCalls() const
virtual void incCalls()
virtual SCIP_Real rowGetDual(SCIP_ROW *row) const =0
virtual SCIP_Real extendedmasterconsGetDual(GCG_EXTENDEDMASTERCONSDATA *extendedmasterconsdata) const =0
virtual SCIP_Real consGetDual(SCIP_CONS *cons) const =0
GCG_PRICETYPE getType() const
virtual SCIP_Real varGetObj(SCIP_VAR *var) const =0
virtual SCIP_Real getClockTime() const
ReducedCostPricing()=delete
pricing controller managing the pricing strategy
abstraction for SCIP pricing types
class with functions for dual variable smoothing
ObjPricer(SCIP *scip, const char *name, const char *desc, int priority, SCIP_Bool delay)
SCIP_DECL_HASHGETKEY(SCIPhashGetKeyCons)
GCG_BRANCHRULE * GCGconsMasterbranchGetBranchrule(SCIP_CONS *cons)
SCIP_RETCODE GCGconsMasterbranchAddRootCons(GCG *gcg)
GCG_BRANCHDATA * GCGconsMasterbranchGetBranchdata(SCIP_CONS *cons)
SCIP_CONS * GCGconsMasterbranchGetActiveCons(GCG *gcg)
constraint handler for storing the branching decisions at each node of the tree
#define SCIP_MAXSTRLEN
#define SCIP_Longint
#define SCIP_Bool
#define MIN(x, y)
#define SCIP_Real
#define ABS(x)
#define SQR(x)
#define MAX(x, y)
#define SCIP_CALL_ABORT(x)
#define SCIP_LONGINT_FORMAT
#define TRUE
#define FALSE
SCIP_DECL_PARAMCHGD(SCIPparamChgdDispActive)
SCIP_RETCODE GCGactivateEventHdlrDisplay(GCG *gcg)
eventhdlr to disable the master display after the root node
int GCGgetNActiveMastersepacuts(GCG *gcg)
GCG_EXTENDEDMASTERCONSDATA ** GCGgetActiveMastersepacuts(GCG *gcg)
SCIP_VAR * GCGpricingmodificationGetCoefVar(GCG_PRICINGMODIFICATION *pricingmodification)
SCIP_Real GCGextendedmasterconsGetRhs(GCG *gcg, GCG_EXTENDEDMASTERCONSDATA *extendedmasterconsdata)
int GCGextendedmasterconsGetNPricingModifications(GCG_EXTENDEDMASTERCONSDATA *extendedmasterconsdata)
SCIP_ROW * GCGextendedmasterconsGetRow(GCG_EXTENDEDMASTERCONSDATA *extendedmasterconsdata)
SCIP_Real GCGextendedmasterconsGetConstant(GCG *gcg, GCG_EXTENDEDMASTERCONSDATA *extendedmasterconsdata)
SCIP_Bool GCGextendedmasterconsIsActive(GCG_EXTENDEDMASTERCONSDATA *extendedmasterconsdata)
GCG_EXTENDEDMASTERCONSTYPE GCGextendedmasterconsGetType(GCG_EXTENDEDMASTERCONSDATA *extendedmasterconsdata)
int GCGpricingmodificationGetBlock(GCG_PRICINGMODIFICATION *pricingmodification)
const char * GCGextendedmasterconsGetName(GCG_EXTENDEDMASTERCONSDATA *extendedmasterconsdata)
SCIP_Real GCGextendedmasterconsGetLhs(GCG *gcg, GCG_EXTENDEDMASTERCONSDATA *extendedmasterconsdata)
GCG_PRICINGMODIFICATION ** GCGextendedmasterconsGetPricingModifications(GCG_EXTENDEDMASTERCONSDATA *extendedmasterconsdata)
SCIP_RETCODE GCGpricingmodificationApply(SCIP *pricingscip, GCG_PRICINGMODIFICATION *pricingmodification)
SCIP_RETCODE GCGextendedmasterconsUndoPricingModifications(GCG *gcg, GCG_EXTENDEDMASTERCONSDATA *extendedmasterconsdata)
SCIP_CONS * GCGextendedmasterconsGetCons(GCG_EXTENDEDMASTERCONSDATA *extendedmasterconsdata)
internal methods for interacting with GCG_EXTENDEDMASTERCONSDATA
GCG interface methods.
void GCGmasterVarSetIndex(SCIP_VAR *var, int index)
Definition gcgvar.c:2056
SCIP_RETCODE GCGoriginalVarAddMasterVar(GCG *gcg, SCIP_VAR *origvar, SCIP_VAR *var, SCIP_Real val)
Definition gcgvar.c:1206
SCIP_Bool GCGvarIsOriginal(SCIP_VAR *var)
Definition gcgvar.c:231
SCIP_VAR ** GCGlinkingVarGetPricingVars(SCIP_VAR *var)
Definition gcgvar.c:488
int GCGlinkingVarGetNBlocks(SCIP_VAR *var)
Definition gcgvar.c:572
int GCGmasterVarGetNOrigvars(SCIP_VAR *var)
Definition gcgvar.c:971
void GCGsetRootRedcostCall(SCIP_VAR *var, SCIP_Longint rootredcostcall)
Definition gcgvar.c:1805
SCIP_VAR ** GCGoriginalVarGetMastervars(SCIP_VAR *var)
Definition gcgvar.c:666
SCIP_RETCODE GCGcreateInitialMasterVar(GCG *gcg, SCIP_VAR *var, SCIP_VAR **newvar)
Definition gcgvar.c:1586
SCIP_VAR ** GCGpricingVarGetOrigvars(SCIP_VAR *var)
Definition gcgvar.c:1100
SCIP_Bool GCGoriginalVarIsLinking(SCIP_VAR *var)
Definition gcgvar.c:247
SCIP_CONS ** GCGoriginalVarGetMasterconss(SCIP_VAR *var)
Definition gcgvar.c:792
SCIP_VAR * GCGoriginalVarGetPricingVar(SCIP_VAR *var)
Definition gcgvar.c:281
SCIP_CONS ** GCGlinkingVarGetLinkingConss(SCIP_VAR *var)
Definition gcgvar.c:872
SCIP_RETCODE GCGcreateArtificialVar(GCG *gcg, SCIP_VAR **newvar, const char *name, SCIP_Real objcoef)
Definition gcgvar.c:1638
int GCGoriginalVarGetNCoefs(SCIP_VAR *var)
Definition gcgvar.c:720
SCIP_RETCODE GCGcreateMasterVar(GCG *gcg, SCIP *pricingscip, SCIP_VAR **newvar, const char *varname, SCIP_Real objcoeff, SCIP_VARTYPE vartype, SCIP_Bool solisray, int prob, int nsolvars, SCIP_Real *solvals, SCIP_VAR **solvars, SCIP_Bool auxiliaryvar)
Definition gcgvar.c:1398
SCIP_VAR ** GCGmasterVarGetOrigvars(SCIP_VAR *var)
Definition gcgvar.c:993
SCIP_Real * GCGoriginalVarGetCoefs(SCIP_VAR *var)
Definition gcgvar.c:702
SCIP_Bool GCGvarIsMaster(SCIP_VAR *var)
Definition gcgvar.c:176
SCIP_Bool GCGoriginalVarIsTransVar(SCIP_VAR *var)
Definition gcgvar.c:264
SCIP_Real * GCGmasterVarGetOrigvals(SCIP_VAR *var)
Definition gcgvar.c:1017
SCIP_RETCODE GCGlinkingVarGetBlocks(SCIP_VAR *var, int nblocks, int *blocks)
Definition gcgvar.c:529
int GCGcountInferredCoefPricingVars(SCIP_VAR **vars, int nvars)
Definition gcgvar.c:210
SCIP_RETCODE GCGoriginalVarRemoveMasterVar(GCG *gcg, SCIP_VAR *origvar, SCIP_VAR *var)
Definition gcgvar.c:1257
void GCGupdateVarStatistics(GCG *gcg, SCIP_VAR *newvar, SCIP_Real redcost)
Definition gcgvar.c:1919
GCG_EXPORT SCIP_Bool GCGvarIsInferredPricing(SCIP_VAR *var)
Definition gcgvar.c:195
GCG_EXTENDEDMASTERCONSDATA * GCGinferredPricingVarGetExtendedmasterconsdata(SCIP_VAR *var)
Definition gcgvar.c:2070
int GCGoriginalVarGetNMastervars(SCIP_VAR *var)
Definition gcgvar.c:648
SCIP_Bool GCGinferredPricingVarIsCoefVar(SCIP_VAR *var)
Definition gcgvar.c:2085
int GCGmasterVarGetIndex(SCIP_VAR *var)
Definition gcgvar.c:2043
int GCGvarGetBlock(SCIP_VAR *var)
Definition gcgvar.c:1118
SCIP_RETCODE GCGvarhistoryFreeReference(SCIP *scip, GCG_VARHISTORY **pointer)
SCIP_RETCODE GCGvarhistoryAddVar(SCIP *scip, GCG_VARHISTORY *pointer, SCIP_VAR *var)
SCIP_RETCODE GCGvarhistoryJumpToLatest(SCIP *scip, GCG_VARHISTORY *pointer)
SCIP_RETCODE GCGvarhistoryCreate(SCIP *scip, GCG_VARHISTORY **pointer)
methods for managing variable history
SCIP_Real SCIPgetRhsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_VAR ** SCIPgetVarsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPaddCoefLinear(SCIP *scip, SCIP_CONS *cons, SCIP_VAR *var, SCIP_Real val)
SCIP_Real SCIPgetLhsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_Bool GCGmasterIsBestsolValid(GCG *gcg)
int GCGpricerGetNSolvers(GCG *gcg)
SCIP_Real GCGmasterGetDegeneracy(GCG *gcg)
SCIP_RETCODE GCGcreateNewMasterVarFromGcgCol(GCG *gcg, SCIP_Bool infarkas, GCG_COL *gcgcol, SCIP_Bool force, SCIP_Bool *added, SCIP_VAR **addedvar, SCIP_Real score)
SCIP_RETCODE GCGpricerAddColResult(GCG *gcg, GCG_COL *col, SCIP_Bool *added)
SCIP_RETCODE GCGmasterPrintSimplexIters(GCG *gcg, FILE *file)
int GCGmasterGetNPricedvars(GCG *gcg)
SCIP_RETCODE GCGsetPricingObjs(GCG *gcg, SCIP_Real *dualsolconv)
SCIP_RETCODE GCGmasterTransOrigSolToMasterVars(GCG *gcg, SCIP_SOL *origsol, SCIP_Bool *stored)
GCG_PRICINGCB ** GCGpricerGetPricingcbs(GCG *gcg)
int GCGpricerGetNRaysProb(GCG *gcg, int probnr)
SCIP_RETCODE GCGmasterAddMasterconsToHashmap(GCG *gcg, SCIP_CONS *cons, int pos)
void GCGsetPricingObjDualWeight(GCG *gcg, SCIP_Real dualweight)
int GCGpricerGetMaxColsRound(GCG *gcg)
SCIP_Bool GCGmasterIsCurrentSolValid(GCG *gcg)
SCIP_RETCODE GCGcomputeColMastercoefs(GCG *gcg, GCG_COL *gcgcol)
GCG_VARHISTORY * GCGgetCurrentVarhistoryReference(GCG *gcg)
SCIP_RETCODE GCGpricerAddCol(GCG *gcg, GCG_COL *col)
SCIP_RETCODE GCGpricerExistRays(GCG *gcg, SCIP_Bool *exist)
int GCGgetNAppliedPricingproblemModifications(GCG *gcg, int probnr)
void GCGsetPricingObjRelaxWeight(GCG *gcg, SCIP_Real *weights, int *weightids, int nweights)
GCG_SOLVER ** GCGpricerGetSolvers(GCG *gcg)
GCG * GCGpricerGetGcg(SCIP *masterprob)
int GCGpricerGetMaxColsProb(GCG *gcg)
SCIP_Bool GCGmasterIsSolValid(GCG *gcg, SCIP_SOL *mastersol)
int GCGpricerGetNPricingcbs(GCG *gcg)
void GCGpricerPrintListOfSolvers(GCG *gcg)
void GCGpricerPrintStatistics(GCG *gcg, FILE *file)
SCIP_Longint GCGmasterGetPricingSimplexIters(GCG *gcg)
SCIP_RETCODE GCGincludePricerGcg(GCG *gcg)
GCG_EXPORT SCIP_RETCODE GCGmasterSetRootLPSol(GCG *gcg, SCIP_SOL **sol)
GCG_COLPOOL * GCGgetColpool(GCG *gcg)
GCG_PRICINGCB * GCGpricerFindPricingcb(GCG *gcg, const char *name)
SCIP_Real GCGcomputeRedCostGcgCol(GCG *gcg, SCIP_Bool infarkas, GCG_COL *gcgcol, SCIP_Real *objvalptr)
int GCGgetNActivePricingproblemModifications(GCG *gcg, int probnr)
SCIP_RETCODE GCGmasterCreateInitialMastervars(GCG *gcg)
void GCGpricerPrintPricingStatistics(GCG *gcg, FILE *file)
SCIP_VAR ** GCGmasterGetPricedvars(GCG *gcg)
SCIP_RETCODE GCGpricerIncludePricingcb(GCG *gcg, const char *name, const char *desc, int priority, GCG_DECL_PRICINGCBFREE((*pricingcbfree)), GCG_DECL_PRICINGCBINIT((*pricingcbinit)), GCG_DECL_PRICINGCBEXIT((*pricingcbexit)), GCG_DECL_PRICINGCBINITSOL((*pricingcbinitsol)), GCG_DECL_PRICINGCBEXITSOL((*pricingcbexitsol)), GCG_DECL_PRICINGCBPREPRICING((*pricingcbprepricing)), GCG_DECL_PRICINGCBPOSTPRICING((*pricingcbpostpricing)), GCG_PRICINGCBDATA *pricingcbdata)
int GCGpricerGetNPointsProb(GCG *gcg, int probnr)
void GCGcolpoolEndFarkas(GCG_COLPOOL *colpool)
Definition colpool.c:418
void GCGcolpoolStartFarkas(GCG_COLPOOL *colpool)
Definition colpool.c:410
SCIP_RETCODE GCGcolpoolUpdateNode(GCG_COLPOOL *colpool)
Definition colpool.c:358
SCIP_RETCODE GCGcolpoolCreate(GCG *gcg, GCG_COLPOOL **colpool, int agelimit)
Definition colpool.c:89
SCIP_RETCODE GCGcolpoolFree(GCG_COLPOOL **colpool)
Definition colpool.c:127
SCIP_RETCODE GCGcolpoolPrice(GCG_COLPOOL *colpool, SCIP_SOL *sol, int *nfoundvars)
Definition colpool.c:288
SCIP_RETCODE GCGcolpoolUpdateRedcost(GCG_COLPOOL *colpool)
Definition colpool.c:380
SCIP_Real * GCGcolGetMastercoefs(GCG_COL *gcgcol)
Definition gcgcol.c:509
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
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_Real * GCGcolGetMastersepaCutCoeffs(GCG_COL *gcgcol)
Definition gcgcol.c:776
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
int * GCGcolGetLinkvars(GCG_COL *gcgcol)
Definition gcgcol.c:635
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
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 GCGcolGetNInferredPricingVars(GCG_COL *gcgcol)
Definition gcgcol.c:1149
SCIP_RETCODE GCGextendedmasterconsUpdateDualValue(GCG *gcg, GCG_EXTENDEDMASTERCONSDATA *extendedmasterconsdata, SCIP_Real dualvalue)
GCG * GCGorigGetGcg(SCIP *origprob)
Definition gcg.cpp:165
GCG_EXPORT SCIP * GCGgetPricingprob(GCG *gcg, int pricingprobnr)
Definition relax_gcg.c:4075
ObjPricerGcg * GCGgetObjPricer(GCG *gcg)
Definition gcg.cpp:187
GCG_EXPORT SCIP_CONS ** GCGgetMasterConss(GCG *gcg)
Definition relax_gcg.c:4228
GCG_EXPORT int GCGgetNTransvars(GCG *gcg)
Definition relax_gcg.c:5256
GCG_EXPORT SCIP_CONS ** GCGgetOrigMasterConss(GCG *gcg)
Definition relax_gcg.c:4245
GCG_EXPORT SCIP_CONS * GCGgetConvCons(GCG *gcg, int blocknr)
Definition relax_gcg.c:4262
GCG_EXPORT int GCGgetNMasterConss(GCG *gcg)
Definition relax_gcg.c:4211
SCIP_Bool GCGisOriginal(SCIP *scip)
Definition misc.c:699
GCG_EXPORT SCIP_CONS ** GCGgetVarLinkingconss(GCG *gcg)
Definition relax_gcg.c:5188
GCG_EXPORT int GCGgetNVarLinkingconss(GCG *gcg)
Definition relax_gcg.c:5222
GCG_EXPORT SCIP_Real GCGgetPricingprobsMemUsed(GCG *gcg)
Definition relax_gcg.c:5114
GCG_EXPORT int GCGgetNRelPricingprobs(GCG *gcg)
Definition relax_gcg.c:4095
SCIP * GCGgetOrigprob(GCG *gcg)
Definition gcg.cpp:87
GCG_EXPORT int GCGgetNIdenticalBlocks(GCG *gcg, int pricingprobnr)
Definition relax_gcg.c:4185
GCG_EXPORT int GCGgetNLinkingvars(GCG *gcg)
Definition relax_gcg.c:5239
SCIP_Bool GCGisMaster(SCIP *scip)
Definition misc.c:709
GCG_EXPORT int GCGgetNPricingprobs(GCG *gcg)
Definition relax_gcg.c:4113
GCG_EXPORT int GCGgetBlockRepresentative(GCG *gcg, int pricingprobnr)
Definition relax_gcg.c:4155
SCIP * GCGgetMasterprob(GCG *gcg)
Definition gcg.cpp:99
GCG_EXPORT GCG_DECMODE GCGgetDecompositionMode(GCG *gcg)
Definition relax_gcg.c:5294
GCG_EXPORT int * GCGgetVarLinkingconssBlock(GCG *gcg)
Definition relax_gcg.c:5205
GCG_EXPORT SCIP_Bool GCGisPricingprobRelevant(GCG *gcg, int pricingprobnr)
Definition relax_gcg.c:4132
SCIP_Bool SCIPisStopped(SCIP *scip)
SCIP_STATUS SCIPgetStatus(SCIP *scip)
SCIP_STAGE SCIPgetStage(SCIP *scip)
SCIP_RETCODE SCIPaddVar(SCIP *scip, SCIP_VAR *var)
int SCIPgetNContVars(SCIP *scip)
SCIP_RETCODE SCIPaddPricedVar(SCIP *scip, SCIP_VAR *var, SCIP_Real score)
SCIP_VAR ** SCIPgetOrigVars(SCIP *scip)
int SCIPgetNVars(SCIP *scip)
SCIP_VAR ** SCIPgetVars(SCIP *scip)
int SCIPgetNOrigVars(SCIP *scip)
SCIP_Bool SCIPisObjIntegral(SCIP *scip)
void SCIPhashmapFree(SCIP_HASHMAP **hashmap)
void * SCIPhashmapGetImage(SCIP_HASHMAP *hashmap, void *origin)
SCIP_RETCODE SCIPhashmapInsert(SCIP_HASHMAP *hashmap, void *origin, void *image)
SCIP_RETCODE SCIPhashmapCreate(SCIP_HASHMAP **hashmap, BMS_BLKMEM *blkmem, int mapsize)
void SCIPhashtableFree(SCIP_HASHTABLE **hashtable)
SCIP_RETCODE SCIPhashtableCreate(SCIP_HASHTABLE **hashtable, BMS_BLKMEM *blkmem, int tablesize, SCIP_DECL_HASHGETKEY((*hashgetkey)), SCIP_DECL_HASHKEYEQ((*hashkeyeq)), SCIP_DECL_HASHKEYVAL((*hashkeyval)), void *userptr)
void * SCIPhashtableRetrieve(SCIP_HASHTABLE *hashtable, void *key)
#define SCIPhashSeven(a, b, c, d, e, f, g)
SCIP_RETCODE SCIPhashtableInsert(SCIP_HASHTABLE *hashtable, void *element)
SCIP_Real SCIPgetNodeLowerbound(SCIP *scip, SCIP_NODE *node)
SCIP_Bool GCGisRootNode(GCG *gcg)
Definition scip_misc.c:918
SCIP_Real GCGconsGetRhs(SCIP *scip, SCIP_CONS *cons)
Definition scip_misc.c:109
SCIP_RETCODE GCGconsGetVars(SCIP *scip, SCIP_CONS *cons, SCIP_VAR **vars, int nvars)
Definition scip_misc.c:487
SCIP_Real GCGconsGetLhs(SCIP *scip, SCIP_CONS *cons)
Definition scip_misc.c:207
SCIP_RETCODE GCGconsGetVals(SCIP *scip, SCIP_CONS *cons, SCIP_Real *vals, int nvals)
Definition scip_misc.c:618
int GCGconsGetNVars(SCIP *scip, SCIP_CONS *cons)
Definition scip_misc.c:433
void SCIPverbMessage(SCIP *scip, SCIP_VERBLEVEL msgverblevel, FILE *file, const char *formatstr,...)
SCIP_MESSAGEHDLR * SCIPgetMessagehdlr(SCIP *scip)
void SCIPdialogMessage(SCIP *scip, FILE *file, const char *formatstr,...)
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
SCIP_DECL_HASHKEYEQ(SCIPhashKeyEqString)
SCIP_DECL_HASHKEYVAL(SCIPhashKeyValString)
GCG_PRICINGPROB * GCGpricingjobGetPricingprob(GCG_PRICINGJOB *pricingjob)
Definition pricingjob.c:135
SCIP * GCGpricingprobGetPricingscip(GCG_PRICINGPROB *pricingprob)
GCG_EXPORT int GCGsolverGetPriority(GCG_SOLVER *solver)
Definition solver.c:441
GCG_EXPORT const char * GCGsolverGetDesc(GCG_SOLVER *solver)
Definition solver.c:431
GCG_EXPORT SCIP_Bool GCGsolverIsHeurEnabled(GCG_SOLVER *solver)
Definition solver.c:451
GCG_EXPORT int GCGsolverGetOptRedcostCalls(GCG_SOLVER *solver)
Definition solver.c:481
GCG_EXPORT SCIP_Real GCGsolverGetOptFarkasTime(GCG *gcg, GCG_SOLVER *solver)
Definition solver.c:511
GCG_EXPORT int GCGsolverGetHeurFarkasCalls(GCG_SOLVER *solver)
Definition solver.c:491
GCG_EXPORT int GCGsolverGetHeurRedcostCalls(GCG_SOLVER *solver)
Definition solver.c:501
GCG_EXPORT SCIP_Real GCGsolverGetHeurFarkasTime(GCG *gcg, GCG_SOLVER *solver)
Definition solver.c:535
GCG_EXPORT SCIP_Real GCGsolverGetHeurRedcostTime(GCG *gcg, GCG_SOLVER *solver)
Definition solver.c:547
GCG_EXPORT int GCGsolverGetOptFarkasCalls(GCG_SOLVER *solver)
Definition solver.c:471
GCG_EXPORT SCIP_Real GCGsolverGetOptRedcostTime(GCG *gcg, GCG_SOLVER *solver)
Definition solver.c:523
GCG_EXPORT SCIP_Bool GCGsolverIsExactEnabled(GCG_SOLVER *solver)
Definition solver.c:461
GCG_EXPORT const char * GCGsolverGetName(GCG_SOLVER *solver)
Definition solver.c:421
SCIP_RETCODE SCIPgetBoolParam(SCIP *scip, const char *name, SCIP_Bool *value)
SCIP_RETCODE SCIPaddIntParam(SCIP *scip, const char *name, const char *desc, int *valueptr, SCIP_Bool isadvanced, int defaultvalue, int minvalue, int maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
SCIP_RETCODE SCIPaddRealParam(SCIP *scip, const char *name, const char *desc, SCIP_Real *valueptr, SCIP_Bool isadvanced, SCIP_Real defaultvalue, SCIP_Real minvalue, SCIP_Real maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
SCIP_RETCODE SCIPsetIntParam(SCIP *scip, const char *name, int value)
SCIP_RETCODE SCIPgetRealParam(SCIP *scip, const char *name, SCIP_Real *value)
SCIP_RETCODE SCIPsetPresolving(SCIP *scip, SCIP_PARAMSETTING paramsetting, SCIP_Bool quiet)
SCIP_RETCODE SCIPaddBoolParam(SCIP *scip, const char *name, const char *desc, SCIP_Bool *valueptr, SCIP_Bool isadvanced, SCIP_Bool defaultvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
SCIP_RETCODE SCIPgetIntParam(SCIP *scip, const char *name, int *value)
SCIP_RETCODE SCIPfixParam(SCIP *scip, const char *name)
SCIP_RETCODE SCIPsetRealParam(SCIP *scip, const char *name, SCIP_Real value)
SCIP_Bool GCGpricingcbIsEnabled(GCG_PRICINGCB *pricingcb)
Definition pricingcb.c:592
SCIP_Bool GCGpricingcbIsExclusive(GCG_PRICINGCB *pricingcb)
Definition pricingcb.c:602
const char * GCGpricingcbGetName(GCG_PRICINGCB *pricingcb)
Definition pricingcb.c:498
SCIP_Real SCIPgetColRedcost(SCIP *scip, SCIP_COL *col)
SCIP_VAR * SCIPcolGetVar(SCIP_COL *col)
SCIP_Real SCIPcolGetLb(SCIP_COL *col)
SCIP_Real SCIPcolGetPrimsol(SCIP_COL *col)
SCIP_Real SCIPcolGetUb(SCIP_COL *col)
SCIP_Bool SCIPcolIsInLP(SCIP_COL *col)
const char * SCIPconsGetName(SCIP_CONS *cons)
SCIP_RETCODE SCIPgetTransformedCons(SCIP *scip, SCIP_CONS *cons, SCIP_CONS **transcons)
int SCIPgetNPoolCuts(SCIP *scip)
SCIP_ROW * SCIPcutGetRow(SCIP_CUT *cut)
SCIP_CUT ** SCIPgetPoolCuts(SCIP *scip)
SCIP_RETCODE SCIPincludeEventhdlr(SCIP *scip, const char *name, const char *desc, SCIP_DECL_EVENTCOPY((*eventcopy)), SCIP_DECL_EVENTFREE((*eventfree)), SCIP_DECL_EVENTINIT((*eventinit)), SCIP_DECL_EVENTEXIT((*eventexit)), SCIP_DECL_EVENTINITSOL((*eventinitsol)), SCIP_DECL_EVENTEXITSOL((*eventexitsol)), SCIP_DECL_EVENTDELETE((*eventdelete)), SCIP_DECL_EVENTEXEC((*eventexec)), SCIP_EVENTHDLRDATA *eventhdlrdata)
SCIP_EVENTHDLR * SCIPfindEventhdlr(SCIP *scip, const char *name)
SCIP_EVENTHDLRDATA * SCIPeventhdlrGetData(SCIP_EVENTHDLR *eventhdlr)
SCIP_EVENTTYPE SCIPeventGetType(SCIP_EVENT *event)
SCIP_RETCODE SCIPcatchVarEvent(SCIP *scip, SCIP_VAR *var, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int *filterpos)
SCIP_RETCODE SCIPdropVarEvent(SCIP *scip, SCIP_VAR *var, SCIP_EVENTTYPE eventtype, SCIP_EVENTHDLR *eventhdlr, SCIP_EVENTDATA *eventdata, int filterpos)
SCIP_VAR * SCIPeventGetVar(SCIP_EVENT *event)
const char * SCIPheurGetName(SCIP_HEUR *heur)
SCIP_RETCODE SCIPgetLPBasisInd(SCIP *scip, int *basisind)
SCIP_ROW ** SCIPgetLPRows(SCIP *scip)
int SCIPgetNLPRows(SCIP *scip)
SCIP_RETCODE SCIPgetLPI(SCIP *scip, SCIP_LPI **lpi)
SCIP_LPSOLSTAT SCIPgetLPSolstat(SCIP *scip)
SCIP_COL ** SCIPgetLPCols(SCIP *scip)
SCIP_Real SCIPgetLPObjval(SCIP *scip)
int SCIPgetNLPCols(SCIP *scip)
SCIP_Bool SCIPisLPSolBasic(SCIP *scip)
#define SCIPfreeMemoryArrayNull(scip, ptr)
#define SCIPfreeBlockMemoryArray(scip, ptr, num)
#define SCIPreallocMemoryArray(scip, ptr, newnum)
SCIP_Longint SCIPgetMemUsed(SCIP *scip)
BMS_BLKMEM * SCIPblkmem(SCIP *scip)
#define SCIPallocMemoryArray(scip, ptr, num)
#define SCIPallocClearBlockMemoryArray(scip, ptr, num)
#define SCIPallocClearBufferArray(scip, ptr, num)
int SCIPcalcMemGrowSize(SCIP *scip, int num)
#define SCIPallocBufferArray(scip, ptr, num)
#define SCIPallocMemory(scip, ptr)
#define SCIPfreeMemoryArray(scip, ptr)
#define SCIPallocBlockMemoryArray(scip, ptr, num)
#define SCIPreallocBlockMemoryArray(scip, ptr, oldnum, newnum)
#define SCIPfreeBlockMemory(scip, ptr)
#define SCIPfreeBlockMemoryArrayNull(scip, ptr, num)
#define SCIPfreeBufferArrayNull(scip, ptr)
#define SCIPallocBlockMemory(scip, ptr)
SCIP_NODETYPE SCIPnodeGetType(SCIP_NODE *node)
int SCIPnodeGetDepth(SCIP_NODE *node)
void SCIPpricerSetData(SCIP_PRICER *pricer, SCIP_PRICERDATA *pricerdata)
SCIP_Real SCIProwGetLhs(SCIP_ROW *row)
int SCIProwGetNNonz(SCIP_ROW *row)
SCIP_COL ** SCIProwGetCols(SCIP_ROW *row)
SCIP_Real SCIProwGetRhs(SCIP_ROW *row)
SCIP_Bool SCIProwIsLocal(SCIP_ROW *row)
SCIP_RETCODE SCIPaddVarToRow(SCIP *scip, SCIP_ROW *row, SCIP_VAR *var, SCIP_Real val)
const char * SCIProwGetName(SCIP_ROW *row)
SCIP_Real SCIPgetRowActivity(SCIP *scip, SCIP_ROW *row)
int SCIProwGetRank(SCIP_ROW *row)
SCIP_Real SCIProwGetConstant(SCIP_ROW *row)
SCIP_Bool SCIProwIsInLP(SCIP_ROW *row)
SCIP_Real SCIProwGetDualsol(SCIP_ROW *row)
SCIP_Real * SCIProwGetVals(SCIP_ROW *row)
SCIP_SOL * SCIPgetBestSol(SCIP *scip)
SCIP_RETCODE SCIPcreateSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
SCIP_RETCODE SCIPfreeSol(SCIP *scip, SCIP_SOL **sol)
SCIP_Real SCIPtransformObj(SCIP *scip, SCIP_Real obj)
int SCIPgetNSols(SCIP *scip)
SCIP_HEUR * SCIPsolGetHeur(SCIP_SOL *sol)
SCIP_RETCODE SCIPgetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
SCIP_RETCODE SCIPincSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var, SCIP_Real incval)
SCIP_RETCODE SCIPsetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
SCIP_SOL ** SCIPgetSols(SCIP *scip)
SCIP_RETCODE SCIPcheckSol(SCIP *scip, SCIP_SOL *sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *feasible)
SCIP_RETCODE SCIPtrySolFree(SCIP *scip, SCIP_SOL **sol, SCIP_Bool printreason, SCIP_Bool completely, SCIP_Bool checkbounds, SCIP_Bool checkintegrality, SCIP_Bool checklprows, SCIP_Bool *stored)
SCIP_Real SCIPgetSolOrigObj(SCIP *scip, SCIP_SOL *sol)
SCIP_RETCODE SCIPsetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var, SCIP_Real val)
SCIP_Real SCIPgetSolVal(SCIP *scip, SCIP_SOL *sol, SCIP_VAR *var)
SCIP_Real SCIPretransformObj(SCIP *scip, SCIP_Real obj)
SCIP_RETCODE SCIPtransformProb(SCIP *scip)
SCIP_RETCODE SCIPfreeTransform(SCIP *scip)
SCIP_Longint SCIPgetNNodes(SCIP *scip)
SCIP_Longint SCIPgetNLPIterations(SCIP *scip)
SCIP_RETCODE SCIPcreateCPUClock(SCIP *scip, SCIP_CLOCK **clck)
SCIP_RETCODE SCIPstopClock(SCIP *scip, SCIP_CLOCK *clck)
SCIP_Real SCIPgetSolvingTime(SCIP *scip)
SCIP_RETCODE SCIPfreeClock(SCIP *scip, SCIP_CLOCK **clck)
SCIP_Real SCIPgetClockTime(SCIP *scip, SCIP_CLOCK *clck)
SCIP_RETCODE SCIPstartClock(SCIP *scip, SCIP_CLOCK *clck)
SCIP_Bool SCIPisFeasGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Real SCIPinfinity(SCIP *scip)
SCIP_Bool SCIPisDualfeasNegative(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisIntegral(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisDualfeasLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisPositive(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
SCIP_Real SCIPround(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisFeasLT(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisSumEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisFeasIntegral(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisDualfeasEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisNegative(SCIP *scip, SCIP_Real val)
SCIP_Real SCIPceil(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_NODE * SCIPgetCurrentNode(SCIP *scip)
SCIP_NODE * SCIPgetRootNode(SCIP *scip)
SCIP_RETCODE SCIPtightenVarLb(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound, SCIP_Bool force, SCIP_Bool *infeasible, SCIP_Bool *tightened)
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
void SCIPvarMarkDeletable(SCIP_VAR *var)
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
SCIP_RETCODE SCIPtightenVarUb(SCIP *scip, SCIP_VAR *var, SCIP_Real newbound, SCIP_Bool force, SCIP_Bool *infeasible, SCIP_Bool *tightened)
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
int SCIPvarGetIndex(SCIP_VAR *var)
int SCIPvarGetProbindex(SCIP_VAR *var)
const char * SCIPvarGetName(SCIP_VAR *var)
SCIP_RETCODE SCIPreleaseVar(SCIP *scip, SCIP_VAR **var)
SCIP_Bool SCIPvarIsIntegral(SCIP_VAR *var)
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
SCIP_RETCODE SCIPchgVarObj(SCIP *scip, SCIP_VAR *var, SCIP_Real newobj)
void SCIPsortPtr(void **ptrarray, SCIP_DECL_SORTPTRCOMP((*ptrcomp)), int len)
int SCIPsnprintf(char *t, int len, const char *s,...)
SCIP_Bool GCGvarIsPricing(SCIP_VAR *var)
Definition gcgvar.c:159
SCIPfreeMemory(GCGgetOrigprob(gcg), &divingdata)
static assert(heur !=NULL)
SCIP_CALL(SCIPgetExternBranchCands(origprob, &lpcands, &lpcandssol, NULL, &nlpcands, NULL, NULL, NULL, NULL))
SCIP * origprob
* result
SCIP_VAR * var
SCIP_VAR ** vars
int j
SCIP_Real solval
SCIPdebugMessage("feasibility pump finished [%d iterations done].\n", nloops)
SCIP_RETCODE retcode
int i
int nvars
SCIPfreeBufferArray(scip, &cycles)
SCIP_SOL * sol
SCIP_Real obj
#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_MASTERSEPACUT * GCGextendedmasterconsGetMastersepacut(GCG_EXTENDEDMASTERCONSDATA *extendedmasterconsdata)
GCG_VARHISTORY * GCGmastersepacutGetVarHistory(GCG_MASTERSEPACUT *mastersepacut)
#define BMSclearMemoryArray(ptr, num)
void SCIPmessageFPrintInfo(SCIP_MESSAGEHDLR *messagehdlr, FILE *file, const char *formatstr,...)
SCIP_RETCODE SCIPincludeObjPricer(SCIP *scip, scip::ObjPricer *objpricer, SCIP_Bool deleteobject)
scip::ObjPricer * SCIPfindObjPricer(SCIP *scip, const char *name)
GCG variable pricer.
int SCIPparamGetInt(SCIP_PARAM *param)
#define DEFAULT_PRICE_MINCOLORTH
#define DEFAULT_STABILIZATIONTREE
#define eventExitVardeleted
SCIP_RETCODE GCGpricerIncludeSolver(GCG *gcg, const char *name, const char *desc, int priority, SCIP_Bool heurenabled, SCIP_Bool exactenabled, GCG_DECL_SOLVERUPDATE((*solverupdate)), GCG_DECL_SOLVERSOLVE((*solversolve)), GCG_DECL_SOLVERSOLVEHEUR((*solversolveheur)), GCG_DECL_SOLVERFREE((*solverfree)), GCG_DECL_SOLVERINIT((*solverinit)), GCG_DECL_SOLVEREXIT((*solverexit)), GCG_DECL_SOLVERINITSOL((*solverinitsol)), GCG_DECL_SOLVEREXITSOL((*solverexitsol)), GCG_SOLVERDATA *solverdata)
#define DEFAULT_USEARTIFICIALVARS
#define GCGpricerPrintInfo(scip, pricerdata,...)
static SCIP_Bool getMastervarKey(SCIP *masterprob, SCIP_VAR *mastervar, GCG_MASTERVARKEY *mvkey)
#define DEFAULT_PRICE_OBJPARALFAC
#define DEFAULT_PRICE_REDCOSTFAC
#define eventInitsolVardeleted
#define DEFAULT_BIGMARTIFICIAL
#define DEFAULT_PRICE_ORTHOFAC
#define DEFAULT_ABORTPRICINGINT
#define DEFAULT_DISPINFOS
#define DEFAULT_PRICE_EFFICIACYCHOICE
#define DEFAULT_USECOLPOOL
#define DEFAULT_PREVENTDUPLICATECOLS
#define DEFAULT_ONLYRELIABLEBIGM
#define eventInitVardeleted
#define PRICER_PRIORITY
#define PRICER_STAT_ARRAYLEN_VARS
#define PRICER_NAME
#define DEFAULT_STABILIZATION
SCIP_DECL_PRICERINITSOL(ObjPricerGcg::scip_initsol)
#define DEFAULT_FACTORUNRELIABLE
#define eventExitsolVardeleted
struct GCG_MastervarKey GCG_MASTERVARKEY
SCIP_DECL_PRICEREXITSOL(ObjPricerGcg::scip_exitsol)
#define DEFAULT_ABORTPRICINGGAP
#define PRICER_DELAY
#define PRICER_STAT_ARRAYLEN_TIME
#define DEFAULT_DISABLECUTOFF
#define DEFAULT_NTHREADS
#define DEFAULT_USEMAXOBJ
#define eventDeleteVardeleted
#define PRICER_DESC
#define DEFAULT_COLPOOL_AGELIMIT
#define DEFAULT_HYBRIDASCENT
SCIP_DECL_PRICEREXIT(ObjPricerGcg::scip_exit)
#define PRICER_STAT_BUCKETSIZE_TIME
SCIP_DECL_PRICERFREE(ObjPricerGcg::scip_free)
#define DEFAULT_HYBRIDASCENT_NOAGG
#define PRICER_STAT_BUCKETSIZE_VARS
GCG variable pricer.
SCIP_DECL_PRICERINIT(ObjPricerVRP::scip_init)
SCIP_DECL_PRICERREDCOST(ObjPricerVRP::scip_redcost)
SCIP_DECL_PRICERFARKAS(ObjPricerVRP::scip_farkas)
void GCGpricestoreEndFarkas(GCG_PRICESTORE *pricestore)
SCIP_RETCODE GCGpricestoreApplyCols(GCG_PRICESTORE *pricestore, GCG_COLPOOL *colpool, SCIP_Bool usecolpool, int *nfoundvars)
SCIP_RETCODE GCGpricestoreFree(GCG_PRICESTORE **pricestore)
int GCGpricestoreGetNColsTotal(GCG_PRICESTORE *pricestore)
int GCGpricestoreGetNCols(GCG_PRICESTORE *pricestore, int arrayindex)
void GCGpricestoreStartFarkas(GCG_PRICESTORE *pricestore)
SCIP_RETCODE GCGpricestoreAddCol(GCG_PRICESTORE *pricestore, GCG_COL *col, SCIP_Bool forcecol, SCIP_Bool fromcolpool, SCIP_Bool *added)
GCG_COL ** GCGpricestoreGetCols(GCG_PRICESTORE *pricestore, int arrayindex)
SCIP_RETCODE GCGpricestoreCreate(GCG *gcg, GCG_PRICESTORE **pricestore, SCIP_Real efficiacyfac, SCIP_Real objparalfac, SCIP_Real orthofac, SCIP_Real mincolorth, GCG_EFFICIACYCHOICE efficiacychoice, int hashtablesize)
SCIP_RETCODE GCGpricingcbExit(GCG *gcg, GCG_PRICINGCB *pricingcb)
Definition pricingcb.c:234
SCIP_RETCODE GCGpricingcbInit(GCG *gcg, GCG_PRICINGCB *pricingcb)
Definition pricingcb.c:196
SCIP_RETCODE GCGpricingcbFree(GCG *gcg, GCG_PRICINGCB **pricingcb)
Definition pricingcb.c:168
SCIP_RETCODE GCGpricingcbCreate(GCG *gcg, GCG_PRICINGCB **pricingcb, const char *name, const char *desc, int priority, GCG_DECL_PRICINGCBFREE((*pricingcbfree)), GCG_DECL_PRICINGCBINIT((*pricingcbinit)), GCG_DECL_PRICINGCBEXIT((*pricingcbexit)), GCG_DECL_PRICINGCBINITSOL((*pricingcbinitsol)), GCG_DECL_PRICINGCBEXITSOL((*pricingcbexitsol)), GCG_DECL_PRICINGCBPREPRICING((*pricingcbprepricing)), GCG_DECL_PRICINGCBPOSTPRICING((*pricingcbpostpricing)), GCG_PRICINGCBDATA *pricingcbdata)
Definition pricingcb.c:137
SCIP_RETCODE GCGpricingcbInitsol(GCG *gcg, GCG_PRICINGCB *pricingcb)
Definition pricingcb.c:260
SCIP_RETCODE GCGpricingcbPrepricing(GCG *gcg, GCG_PRICINGCB *pricingcb, SCIP_PRICER *pricer, GCG_PRICETYPE type, SCIP_Bool *abort, SCIP_RESULT *result)
Definition pricingcb.c:314
SCIP_RETCODE GCGpricingcbPostpricing(GCG *gcg, GCG_PRICINGCB *pricingcb, SCIP_PRICER *pricer, GCG_PRICETYPE type, SCIP_RESULT *result)
Definition pricingcb.c:363
SCIP_RETCODE GCGpricingcbExitsol(GCG *gcg, GCG_PRICINGCB *pricingcb)
Definition pricingcb.c:287
internal methods for the pricing callback
SCIP_Bool GCGpricingjobSolverChanged(GCG_PRICINGJOB *pricingjob)
Definition pricingjob.c:216
void GCGpricingjobSolverCalled(GCG_PRICINGJOB *pricingjob)
Definition pricingjob.c:224
GCG_SOLVER * GCGpricingjobGetSolver(GCG_PRICINGJOB *pricingjob)
Definition pricingjob.c:142
SCIP_Bool GCGpricingjobIsHeuristic(GCG_PRICINGJOB *pricingjob)
Definition pricingjob.c:248
void GCGpricingprobMarkBranchconsAdded(GCG_PRICINGPROB *pricingprob)
int GCGpricingprobGetBranchconsIdx(GCG_PRICINGPROB *pricingprob)
void GCGpricingprobGetGenericBranchData(GCG_PRICINGPROB *pricingprob, SCIP_CONS ***branchconss, SCIP_Real **branchduals, int *nbranchconss)
SCIP_Bool GCGpricingprobBranchconsIsAdded(GCG_PRICINGPROB *pricingprob)
int GCGpricingprobGetProbnr(GCG_PRICINGPROB *pricingprob)
int GCGpricingprobGetNGenericBranchconss(GCG_PRICINGPROB *pricingprob)
public methods for storing cols in a col pool
public methods for interacting with GCG_EXTENDEDMASTERCONSDATA
public C++ methods for working with gcg structure
public methods for working with gcg columns
public methods for GCG variables
#define SCIPstatisticMessage
public methods for working with pricing jobs
public methods for working with pricing problems
SCIP_RETCODE GCGrelaxBranchGetAllActiveExtendedMasterConss(GCG *gcg, GCG_BRANCHRULE ***branchrules, GCG_BRANCHDATA ***branchdata, GCG_EXTENDEDMASTERCONSDATA ***extendedmasterconsdata, int *nextendedmasterconss)
Definition relax_gcg.c:3931
SCIP_RETCODE GCGrelaxBranchNewCol(GCG *gcg, GCG_BRANCHRULE *branchrule, GCG_BRANCHDATA *branchdata, SCIP_VAR *mastervar)
Definition relax_gcg.c:3885
GCG relaxator.
various SCIP helper methods
SCIP_RETCODE GCGsepaBasisAddPricingCut(GCG *gcg, int ppnumber, SCIP_ROW *cut)
SCIP_RETCODE SCIPsepaBasisAddPPObjConss(GCG *gcg, int ppnumber, SCIP_Real dualsolconv, SCIP_Bool newcuts)
basis separator
SCIP_ROW ** GCGsepaGetOriginalSepaMastercuts(GCG *gcg)
SCIP_ROW ** GCGsepaGetOriginalSepaOrigcuts(GCG *gcg)
int GCGsepaGetNOriginalSepaCuts(GCG *gcg)
original separator
SCIP_RETCODE GCGsolverFree(GCG *gcg, GCG_SOLVER **solver)
Definition solver.c:152
SCIP_RETCODE GCGsolverCreate(GCG *gcg, GCG_SOLVER **solver, const char *name, const char *desc, int priority, SCIP_Bool heurenabled, SCIP_Bool exactenabled, GCG_DECL_SOLVERUPDATE((*solverupdate)), GCG_DECL_SOLVERSOLVE((*solversolve)), GCG_DECL_SOLVERSOLVEHEUR((*solveheur)), GCG_DECL_SOLVERFREE((*solverfree)), GCG_DECL_SOLVERINIT((*solverinit)), GCG_DECL_SOLVEREXIT((*solverexit)), GCG_DECL_SOLVERINITSOL((*solverinitsol)), GCG_DECL_SOLVEREXITSOL((*solverexitsol)), GCG_SOLVERDATA *solverdata)
Definition solver.c:64
SCIP_RETCODE GCGsolverSolve(GCG *gcg, SCIP *pricingprob, GCG_SOLVER *solver, SCIP_Bool redcost, SCIP_Bool heuristic, int probnr, SCIP_Real dualsolconv, SCIP_Real *lowerbound, GCG_PRICINGSTATUS *status, SCIP_Bool *solved)
Definition solver.c:293
SCIP_RETCODE GCGsolverInit(GCG *gcg, GCG_SOLVER *solver)
Definition solver.c:183
SCIP_RETCODE GCGsolverExitsol(GCG *gcg, GCG_SOLVER *solver)
Definition solver.c:252
SCIP_RETCODE GCGsolverUpdate(GCG *gcg, SCIP *pricingprob, GCG_SOLVER *solver, int probnr, SCIP_Bool varobjschanged, SCIP_Bool varbndschanged, SCIP_Bool consschanged)
Definition solver.c:269
SCIP_RETCODE GCGsolverExit(GCG *gcg, GCG_SOLVER *solver)
Definition solver.c:218
SCIP_RETCODE GCGsolverInitsol(GCG *gcg, GCG_SOLVER *solver)
Definition solver.c:235
public methods for GCG pricing solvers
SCIP_Real * vals
SCIP_VAR ** vars
SCIP_VAR * mastervar
SCIP_CLOCK * duplicatecolclock
SCIP_Longint pricingiters
SCIP_Bool dispinfos
SCIP_Bool usemaxobj
SCIP_Bool useartificialvars
SCIP_HASHMAP * mapcons2idx
GCG_PRICINGCB ** pricingcbs
double * farkasnodetimedist
SCIP_Real abortpricinggap
SCIP_VAR ** artificialvars
SCIP_Real redcostfac
GCG_VARHISTORY * varhistory
SCIP_Real bigmartificial
SCIP_Real ** realdualvalues
SCIP_Bool usecolpool
SCIP_Bool abortpricingint
SCIP_Bool onlyreliablebigm
SCIP_VARTYPE vartype
SCIP_Real mincolorth
double avgrootnodedegeneracy
SCIP_Longint currnodenr
double * redcostnodetimedist
GCG_EFFICIACYCHOICE efficiacychoice
SCIP_Bool stabilizationtree
SCIP_Bool preventduplicatecols
SCIP_Real * dualsolconv
SCIP_Real dualweight
SCIP_Bool hybridascent
SCIP_VAR ** pricedvars
SCIP_Real * solvals
GCG_SOLVER ** solvers
SCIP_EVENTHDLR * eventhdlr
double rootnodedegeneracy
int * nappliedpricingmods
SCIP_CLOCK * freeclock
SCIP_Bool relaxobjective
SCIP_Real * relaxweight
SCIP_Bool artificialused
SCIP_CLOCK * transformclock
SCIP_Real objparalfac
SCIP_Real orthofac
SCIP_Real factorunreliable
SCIP_Real maxpricecolsfarkas
SCIP_Bool stabilization
SCIP_Real maxpricecols
SCIP_Bool hybridascentnoagg
SCIP_CLOCK * duallptime
SCIP_CLOCK * primallptime
SCIP_STAT * stat
gcg data structure
data structures for storing OpenMP locks
data structures for solvers
type definitions for branching rules in GCG projects
struct GCG_BranchData GCG_BRANCHDATA
struct GCG_Branchrule GCG_BRANCHRULE
struct SCIP_Clock SCIP_CLOCK
struct GCG_Colpool GCG_COLPOOL
struct SCIP_Cons SCIP_CONS
struct SCIP_Cut SCIP_CUT
@ GCG_DECMODE_DANTZIGWOLFE
Definition type_decomp.h:62
struct SCIP_Eventhdlr SCIP_EVENTHDLR
#define SCIP_EVENTTYPE_VARDELETED
struct SCIP_EventhdlrData SCIP_EVENTHDLRDATA
type definitions for extended master conss in GCG projects
@ GCG_EXTENDEDMASTERCONSTYPE_SEPA_ROW
@ GCG_EXTENDEDMASTERCONSTYPE_BRANCH_CONS
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 GCG_PRICER GCG_PRICER
struct GCG_VarHistory GCG_VARHISTORY
#define GCG_SET_LOCK(lockname)
Definition type_locks.h:68
#define GCG_UNSET_LOCK(lockname)
Definition type_locks.h:70
void GCG_LOCKS
Definition type_locks.h:66
struct SCIP_Row SCIP_ROW
struct SCIP_Col SCIP_COL
SCIP_LPSOLSTAT_OPTIMAL
struct SCIP_LPi SCIP_LPI
SCIP_VERBLEVEL_NORMAL
struct SCIP_HashMap SCIP_HASHMAP
struct SCIP_HashTable SCIP_HASHTABLE
SCIP_PARAMSETTING_DEFAULT
struct SCIP_Pricer SCIP_PRICER
struct SCIP_PricerData SCIP_PRICERDATA
enum GCG_Efficiacychoice GCG_EFFICIACYCHOICE
enum GCG_Pricetype GCG_PRICETYPE
@ GCG_PRICETYPE_FARKAS
@ GCG_PRICETYPE_REDCOST
#define GCG_DECL_PRICINGCBPREPRICING(x)
#define GCG_DECL_PRICINGCBPOSTPRICING(x)
#define GCG_DECL_PRICINGCBINITSOL(x)
struct GCG_PricingcbData GCG_PRICINGCBDATA
#define GCG_DECL_PRICINGCBEXIT(x)
#define GCG_DECL_PRICINGCBINIT(x)
#define GCG_DECL_PRICINGCBEXITSOL(x)
struct GCG_Pricingcb GCG_PRICINGCB
#define GCG_DECL_PRICINGCBFREE(x)
struct GCG_PricingJob GCG_PRICINGJOB
type definitions for pricing problem data structure
struct GCG_PricingProb GCG_PRICINGPROB
enum GCG_PricingStatus GCG_PRICINGSTATUS
@ GCG_PRICINGSTATUS_NOTAPPLICABLE
@ GCG_PRICINGSTATUS_UNKNOWN
SCIP_DIDNOTRUN
SCIP_SUCCESS
enum SCIP_Result SCIP_RESULT
SCIP_ERROR
enum SCIP_Retcode SCIP_RETCODE
struct Scip SCIP
SCIP_STAGE_INITPRESOLVE
SCIP_STAGE_SOLVING
struct SCIP_Sol SCIP_SOL
struct GCG_Solver GCG_SOLVER
Definition type_solver.h:51
#define GCG_DECL_SOLVERFREE(x)
Definition type_solver.h:60
#define GCG_DECL_SOLVERUPDATE(x)
#define GCG_DECL_SOLVEREXITSOL(x)
Definition type_solver.h:98
#define GCG_DECL_SOLVERINITSOL(x)
Definition type_solver.h:87
#define GCG_DECL_SOLVERSOLVE(x)
#define GCG_DECL_SOLVERINIT(x)
Definition type_solver.h:68
#define GCG_DECL_SOLVEREXIT(x)
Definition type_solver.h:76
#define GCG_DECL_SOLVERSOLVEHEUR(x)
struct GCG_SolverData GCG_SOLVERDATA
Definition type_solver.h:50
SCIP_STATUS_OPTIMAL
SCIP_NODETYPE_PROBINGNODE
struct SCIP_Var SCIP_VAR
SCIP_VARTYPE_INTEGER
SCIP_VARTYPE_CONTINUOUS
enum SCIP_Vartype SCIP_VARTYPE