GCG 4.1.1 (dev)

Generic Column Generation

Loading...
Searching...
No Matches
class_pricingcontroller.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 class_pricingcontroller.cpp
30 * @brief pricing controller managing the pricing strategy
31 * @author Christian Puchert
32 */
33
34/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
35
37#include "gcg/pricer_gcg.h"
39#include "gcg/gcg.h"
40#include "gcg/scip_misc.h"
41#include "gcg/branch_generic.h"
43#include "gcg/pub_gcgpqueue.h"
44#include "gcg/pub_pricingjob.h"
45#include "gcg/pub_pricingprob.h"
46#include "gcg/pub_solver.h"
47#include "gcg/pricingjob.h"
48#include "gcg/pricingprob.h"
49
50#include "scip/scip.h"
51#include "objscip/objscip.h"
52
53#ifdef _OPENMP
54#include "gcg/struct_locks.h"
55#endif
56
57#include <exception>
58
59#define DEFAULT_HEURPRICINGITERS 1 /**< maximum number of heuristic pricing iterations per pricing call and problem */
60#define DEFAULT_MAXHEURDEPTH -1 /**< maximum depth at which heuristic pricing should be performed (-1 for infinity) */
61#define DEFAULT_SORTING 'r' /**< order by which the pricing problems should be sorted:
62 * 'i'ndices
63 * 'd'ual solutions of convexity constraints
64 * 'r'eliability from all previous rounds
65 * reliability from the 'l'ast nroundscol rounds
66 */
67#define DEFAULT_NROUNDSCOL 15
68#define DEFAULT_CHUNKSIZE INT_MAX /**< maximal number of pricing problems to be solved during one pricing loop */
69#define DEFAULT_EAGERFREQ 10 /**< frequency at which all pricingproblems should be solved (0 to disable) */
70
71#define SCIP_CALL_EXC(x) do \
72 { \
73 SCIP_RETCODE _retcode_; \
74 if( (_retcode_ = (x)) != SCIP_OKAY ) \
75 { \
76 SCIPerrorMessage("Error <%d> in function call\n", _retcode_); \
77 throw std::exception(); \
78 } \
79 } \
80 while( FALSE )
81
82
83namespace gcg {
84
86 GCG* gcgstruct
87 )
88{
89 gcg = gcgstruct;
90 scip_ = GCGgetMasterprob(gcg);
91 origprob = GCGgetOrigprob(gcg);
92 pricingprobs = NULL;
93 npricingprobs = 0;
94 pricingjobs = NULL;
95 npricingjobs = 0;
96
97 sorting = DEFAULT_SORTING;
98 nroundscol = DEFAULT_NROUNDSCOL;
99 chunksize = DEFAULT_CHUNKSIZE;
100 eagerfreq = DEFAULT_EAGERFREQ;
101
102 pqueue = NULL;
103 maxniters = INT_MAX;
104 nchunks = 1;
105 curchunk = 0;
106
107 pricingtype_ = NULL;
108
109 eagerage = 0;
110 nsolvedprobs = 0;
111
112#ifdef _OPENMP
113 locks = GCGgetLocks(gcg);
114#endif
115}
116
120
122{
123 SCIP_CALL( SCIPaddIntParam(origprob, "pricing/masterpricer/heurpricingiters",
124 "maximum number of heuristic pricing iterations per pricing call and problem",
125 &heurpricingiters, FALSE, DEFAULT_HEURPRICINGITERS, 0, INT_MAX, NULL, NULL) );
126
127 SCIP_CALL( SCIPaddIntParam(origprob, "pricing/masterpricer/maxheurdepth",
128 "maximum depth at which heuristic pricing should be performed (-1 for infinity)",
129 &maxheurdepth, FALSE, DEFAULT_MAXHEURDEPTH, -1, INT_MAX, NULL, NULL) );
130
131 SCIP_CALL( SCIPaddCharParam(origprob, "pricing/masterpricer/sorting",
132 "order by which the pricing problems should be sorted ('i'ndices, 'd'ual solutions of convexity constraints, 'r'eliability from previous rounds, reliability from the 'l'ast nroundscol rounds)",
133 &sorting, FALSE, DEFAULT_SORTING, "dilr", NULL, NULL) );
134
135 SCIP_CALL( SCIPaddIntParam(origprob, "pricing/masterpricer/nroundscol",
136 "number of previous pricing rounds for which the number of improving columns should be counted",
137 &nroundscol, TRUE, DEFAULT_NROUNDSCOL, 1, INT_MAX, NULL, NULL) );
138
139 SCIP_CALL( SCIPaddIntParam(origprob, "pricing/masterpricer/chunksize",
140 "maximal number of pricing problems to be solved during one pricing loop",
141 &chunksize, TRUE, DEFAULT_CHUNKSIZE, 1, INT_MAX, NULL, NULL) );
142
143 SCIP_CALL( SCIPaddIntParam(origprob, "pricing/masterpricer/eagerfreq",
144 "frequency at which all pricingproblems should be solved (0 to disable)",
145 &eagerfreq, FALSE, DEFAULT_EAGERFREQ, 0, INT_MAX, NULL, NULL) );
146
147 return SCIP_OKAY;
148}
149
150/** comparison operator for pricing jobs w.r.t. their solution priority */
151SCIP_DECL_SORTPTRCOMP(Pricingcontroller::comparePricingjobs)
152{
153 GCG_PRICINGJOB* pricingjob1;
154 GCG_PRICINGJOB* pricingjob2;
155 GCG_PRICINGPROB* pricingprob1;
156 GCG_PRICINGPROB* pricingprob2;
157 GCG_SOLVER* solver1;
158 GCG_SOLVER* solver2;
159
160 pricingjob1 = (GCG_PRICINGJOB*) elem1;
161 pricingjob2 = (GCG_PRICINGJOB*) elem2;
162
163 pricingprob1 = GCGpricingjobGetPricingprob(pricingjob1);
164 pricingprob2 = GCGpricingjobGetPricingprob(pricingjob2);
165
166 solver1 = GCGpricingjobGetSolver(pricingjob1);
167 solver2 = GCGpricingjobGetSolver(pricingjob2);
168
169 /* preliminary order of sorting:
170 * * priority of pricing solvers
171 * * heuristic before exact
172 * * score
173 */
174
175 if( GCGsolverGetPriority(solver1) > GCGsolverGetPriority(solver2) )
176 return -1;
177 else if( GCGsolverGetPriority(solver1) < GCGsolverGetPriority(solver2) )
178 return 1;
179
180 if( GCGpricingjobIsHeuristic(pricingjob1) && GCGpricingjobIsHeuristic(pricingjob2) )
181 {
182 if( GCGpricingjobGetNHeurIters(pricingjob1) < GCGpricingjobGetNHeurIters(pricingjob2) )
183 return -1;
184 else if( GCGpricingjobGetNHeurIters(pricingjob1) > GCGpricingjobGetNHeurIters(pricingjob2) )
185 return 1;
186 }
187
188 if( GCGpricingjobIsHeuristic(pricingjob1) != GCGpricingjobIsHeuristic(pricingjob2) )
189 {
190 if( GCGpricingjobIsHeuristic(pricingjob1) )
191 return -1;
192 else if( GCGpricingjobIsHeuristic(pricingjob2) )
193 return 1;
194 }
195
196 if( GCGpricingjobGetScore(pricingjob1) > GCGpricingjobGetScore(pricingjob2) )
197 return -1;
198 else if( GCGpricingjobGetScore(pricingjob1) < GCGpricingjobGetScore(pricingjob2) )
199 return 1;
200
201 // @todo: preliminary tie breaking by pricing problem index
202 if( GCGpricingprobGetProbnr(pricingprob1) < GCGpricingprobGetProbnr(pricingprob2) )
203 return -1;
204 else
205 return 1;
206
207 return 0;
208}
209
210/** for each pricing problem, get its corresponding generic branching constraints */
211SCIP_RETCODE Pricingcontroller::getGenericBranchconss()
212{
213 /* get current branching rule */
215 GCG_BRANCHRULE* branchrule = GCGconsMasterbranchGetBranchrule(branchcons);
216
217 assert(branchcons != NULL);
218 assert(SCIPnodeGetDepth(GCGconsMasterbranchGetNode(branchcons)) == 0 || branchrule != NULL || SCIPinProbing(scip_));
219
220 while( GCGisBranchruleGeneric(branchrule) )
221 {
222 GCG_BRANCHDATA* branchdata;
223 SCIP_CONS* mastercons;
224 int consblocknr;
225
226 int i;
227
228 branchdata = GCGconsMasterbranchGetBranchdata(branchcons);
229 assert(branchdata != NULL);
230
231 mastercons = GCGbranchGenericBranchdataGetMastercons(branchdata);
232 consblocknr = GCGbranchGenericBranchdataGetConsblocknr(branchdata);
233 assert(mastercons != NULL);
234 assert(consblocknr >= 0 || consblocknr == -3);
235
236 if( consblocknr >= 0 )
237 {
238 for( i = 0; i < npricingprobs; ++i )
239 {
240 /* search for the pricing problem to which the generic branching decision belongs */
241 if( consblocknr == GCGpricingprobGetProbnr(pricingprobs[i]) )
242 {
243 SCIP_CALL( GCGpricingprobAddGenericBranchData(gcg, pricingprobs[i], branchcons,
244 pricingtype_->consGetDual(mastercons)) );
245 break;
246 }
247 }
248 assert(i < npricingprobs);
249 }
250
251 branchcons = GCGconsMasterbranchGetParentcons(branchcons);
252 branchrule = GCGconsMasterbranchGetBranchrule(branchcons);
253 }
254
255 return SCIP_OKAY;
256}
257
258/** check if a pricing problem is done */
259SCIP_Bool Pricingcontroller::pricingprobIsDone(
260 GCG_PRICINGPROB* pricingprob /**< pricing problem structure */
261 ) const
262{
263 return GCGpricingprobGetNImpCols(pricingprob) > 0
267}
268
269/** check whether the next generic branching constraint of a pricing problem must be considered */
270SCIP_Bool Pricingcontroller::pricingprobNeedsNextBranchingcons(
271 GCG_PRICINGPROB* pricingprob /**< pricing problem structure */
272 ) const
273{
274 return GCGpricingprobGetNImpCols(pricingprob) == 0
276 && GCGpricingprobGetBranchconsIdx(pricingprob) > 0;
277}
278
280{
281 int nblocks = GCGgetNPricingprobs(gcg);
283 int nsolvers = GCGpricerGetNSolvers(gcg);
284 int actchunksize = MIN(chunksize, GCGgetNRelPricingprobs(gcg));
285
286 npricingprobs = 0;
287 npricingjobs = 0;
288 nchunks = (int) SCIPceil(scip_, (SCIP_Real) GCGgetNRelPricingprobs(gcg) / actchunksize);
289 curchunk = nchunks - 1;
290 eagerage = 0;
291
292 /* create pricing problem and pricing job data structures */
293 maxpricingprobs = SCIPcalcMemGrowSize(scip_, GCGgetNRelPricingprobs(gcg));
294 maxpricingjobs = SCIPcalcMemGrowSize(scip_, GCGgetNRelPricingprobs(gcg) * nsolvers);
295 SCIP_CALL_EXC( SCIPallocBlockMemoryArray(scip_, &pricingprobs, maxpricingprobs) );
296 SCIP_CALL_EXC( SCIPallocBlockMemoryArray(scip_, &pricingjobs, maxpricingjobs) );
297 for( int i = 0; i < nblocks; ++i )
298 {
300 {
301 SCIP_CALL_EXC( GCGpricingprobCreate(gcg, &pricingprobs[npricingprobs], GCGgetPricingprob(gcg, i), i, nroundscol) );
302
303 for( int j = 0; j < nsolvers; ++j )
304 {
305 if( GCGsolverIsHeurEnabled(solvers[j]) || GCGsolverIsExactEnabled(solvers[j]) )
306 {
307 SCIP_CALL_EXC( GCGpricingjobCreate(gcg, &pricingjobs[npricingjobs], pricingprobs[npricingprobs], solvers[j], npricingprobs / actchunksize) );
308 ++npricingjobs;
309 break;
310 }
311 }
312 ++npricingprobs;
313 }
314 }
315
316#ifdef _OPENMP
317 SCIP_CALL_EXC( GCGpqueueCreate(scip_, &pqueue, npricingjobs, comparePricingjobs, &locks->memorylock) );
318#else
319 SCIP_CALL_EXC( GCGpqueueCreate(scip_, &pqueue, npricingjobs, comparePricingjobs, NULL) );
320#endif
321
322 return SCIP_OKAY;
323}
324
326{
327 GCGpqueueFree(&pqueue);
328
329 for( int i = 0; i < npricingprobs; ++i )
330 {
331 GCGpricingprobFree(gcg, &pricingprobs[i]);
332 }
333 for( int i = 0; i < npricingjobs; ++i )
334 {
335 GCGpricingjobFree(gcg, &pricingjobs[i]);
336 }
337 SCIPfreeBlockMemoryArray(scip_, &pricingprobs, maxpricingprobs);
338 SCIPfreeBlockMemoryArray(scip_, &pricingjobs, maxpricingjobs);
339
340 return SCIP_OKAY;
341}
342
343/** pricing initialization, called right at the beginning of pricing */
345 PricingType* pricingtype /**< type of pricing */
346 )
347{
348 SCIP_Longint tmpmaxniters;
349
350 pricingtype_ = pricingtype;
351
352 /* move chunk index forward */
353 curchunk = (curchunk + 1) % nchunks;
354 startchunk = curchunk;
355
356 for( int i = 0; i < npricingprobs; ++i )
357 GCGpricingprobInitPricing(pricingprobs[i]);
358
359 SCIP_CALL( getGenericBranchconss() );
360
361 /* calculate maximal possible number of pricing iterations per mis-pricing iteration */
362 tmpmaxniters = 0;
363 for( int i = 0; i < npricingprobs; ++i )
364 tmpmaxniters += GCGpricerGetNSolvers(gcg) * ((SCIP_Longint) heurpricingiters + 1) * (GCGpricingprobGetNGenericBranchconss(pricingprobs[i]) + 1);
365 maxniters = (int) MIN(tmpmaxniters, 16383);
366
367 SCIPdebugMessage("initialize pricing, chunk = %d/%d\n", curchunk+1, nchunks);
368
369 return SCIP_OKAY;
370}
371
372/** pricing deinitialization, called when pricing is finished */
374{
375 for( int i = npricingprobs-1; i >= 0; --i )
376 GCGpricingprobExitPricing(pricingprobs[i], nroundscol);
377
378 pricingtype_ = NULL;
379}
380
381/** setup the priority queue (done once per stabilization round): add all pricing jobs to be performed */
383 SCIP_Real* dualsolconv /**< dual solution values / Farkas coefficients of convexity constraints */
384 )
385{
386 SCIPdebugMessage("Setup pricing queue, chunk = %d/%d\n", curchunk+1, nchunks);
387
388 GCGpqueueClear(pqueue);
389
390 /* reset pricing problems */
391 for( int i = 0; i < npricingprobs; ++i )
392 GCGpricingprobReset(gcg, pricingprobs[i]);
393
394 for( int i = 0; i < npricingjobs; ++i )
395 {
396 int probnr = GCGpricingprobGetProbnr(GCGpricingjobGetPricingprob(pricingjobs[i]));
397
398 SCIP_CALL_EXC( GCGpricingjobSetup(gcg, pricingjobs[i],
399 (heurpricingiters > 0 && (maxheurdepth == -1 || SCIPnodeGetDepth(SCIPgetCurrentNode(scip_)) <= maxheurdepth)),
400 sorting, nroundscol, dualsolconv[probnr], GCGpricerGetNPointsProb(gcg, probnr), GCGpricerGetNRaysProb(gcg, probnr)) );
401
402 if( GCGpricingjobGetChunk(pricingjobs[i]) == curchunk )
403 {
404 SCIP_CALL_EXC( GCGpqueueInsert(pqueue, (void*) pricingjobs[i]) );
405 }
406 }
407
408 nsolvedprobs = 0;
409
410 return SCIP_OKAY;
411}
412
413/** get the next pricing job to be performed */
415{
416 GCG_PRICINGJOB* pricingjob = NULL;
417
418 if( SCIPisStopped(scip_) )
419 return NULL;
420
421 do
422 {
423 pricingjob = (GCG_PRICINGJOB*) GCGpqueueRemove(pqueue);
424 }
425 while( pricingjob != NULL && pricingprobIsDone(GCGpricingjobGetPricingprob(pricingjob)) );
426
427 return pricingjob;
428}
429
430/** add the information that the next branching constraint must be added,
431 * and for the pricing job, reset heuristic pricing counter and flag
432 */
434 GCG_PRICINGPROB* pricingprob /**< pricing problem structure */
435 )
436{
437 int i;
439
440 GCGpricingprobNextBranchcons(pricingprob);
441
442 /* reset heuristic pricing counter and flag for every corresponding pricing job */
443 if( heurpricingiters > 0 )
444 for( i = 0; i < npricingjobs; ++i )
445 if( GCGpricingjobGetPricingprob(pricingjobs[i]) == pricingprob )
446 GCGpricingjobResetHeuristic(pricingjobs[i]);
447
448 /* re-sort the priority queue */
449 GCG_SET_LOCK(&locks->pricinglock);
450 retcode = GCGpqueueResort(pqueue);
451 GCG_UNSET_LOCK(&locks->pricinglock);
452
454
455 return SCIP_OKAY;
456}
457
458/** set an individual time limit for a pricing job */
460 GCG_PRICINGJOB* pricingjob /**< pricing job */
461 )
462{
464 SCIP_Real mastertimelimit;
465 SCIP_Real timelimit;
466
467 SCIP_CALL( SCIPgetRealParam(scip_, "limits/time", &mastertimelimit) );
468
469 /* do not give pricing job more time than is left for solving the master problem */
470 timelimit = MAX(0, mastertimelimit - SCIPgetSolvingTime(scip_));
471
472 SCIP_CALL( SCIPsetRealParam(pricingscip, "limits/time", timelimit) );
473
474 return SCIP_OKAY;
475}
476
477/** update solution information of a pricing problem */
479 GCG_PRICINGPROB* pricingprob, /**< pricing problem structure */
480 GCG_PRICINGSTATUS status, /**< new pricing status */
481 SCIP_Real lowerbound, /**< new lower bound */
482 int nimpcols /**< number of new improving columns */
483 )
484{
485 GCGpricingprobUpdate(gcg, pricingprob, status, lowerbound, nimpcols);
486}
487
488/** decide whether a pricing job must be treated again */
490 GCG_PRICINGJOB* pricingjob, /**< pricing job */
491 GCG_PRICINGSTATUS status /**< status of pricing job */
492 )
493{
494 GCG_PRICINGPROB* pricingprob = GCGpricingjobGetPricingprob(pricingjob);
495 SCIP_Bool heuristic = GCGpricingjobIsHeuristic(pricingjob);
496
497 /* Go to the next heuristic pricing iteration */
498 if( heuristic )
500
501 /* If the pricing job has not yielded any improving column, possibly solve it again;
502 * increase at least one of its limits, or solve it exactly if it was solved heuristically before
503 */
504 // @todo: update score of pricing job
505 if( !pricingprobIsDone(pricingprob) )
506 {
507 SCIPdebugMessage("Solving problem %d with <%s> has not yielded improving columns.\n",
509
510 if( heuristic && status != GCG_PRICINGSTATUS_OPTIMAL && status != GCG_PRICINGSTATUS_NOTAPPLICABLE )
511 {
513
514 if( status != GCG_PRICINGSTATUS_SOLVERLIMIT || GCGpricingjobGetNHeurIters(pricingjob) >= heurpricingiters )
515 {
516 GCGpricingjobSetExact(pricingjob);
517 SCIPdebugMessage(" -> set exact\n");
518 }
519 else
520 {
521 SCIPdebugMessage(" -> increase a limit\n");
522 }
523
524 GCG_SET_LOCK(&locks->pricinglock);
525 SCIP_CALL_EXC( GCGpqueueInsert(pqueue, (void*) pricingjob) );
526 GCG_UNSET_LOCK(&locks->pricinglock);
527
528 return;
529 }
530
531 if( pricingprobNeedsNextBranchingcons(pricingprob) )
532 {
533
534 SCIPdebugMessage(" -> consider next generic branching constraint.\n");
535
537
538 GCG_SET_LOCK(&locks->pricinglock);
539 SCIP_CALL_EXC( GCGpqueueInsert(pqueue, (void*) pricingjob) );
540 GCG_UNSET_LOCK(&locks->pricinglock);
541
542 return;
543 }
544
545 GCGpricingjobNextSolver(gcg, pricingjob);
546 if( heurpricingiters > 0 )
547 GCGpricingjobResetHeuristic(pricingjob);
548 if( GCGpricingjobGetSolver(pricingjob) != NULL )
549 {
550 SCIPdebugMessage(" -> use another solver\n");
551
552 GCG_SET_LOCK(&locks->pricinglock);
553 SCIP_CALL_EXC( GCGpqueueInsert(pqueue, (void*) pricingjob) );
554 GCG_UNSET_LOCK(&locks->pricinglock);
555 }
556 }
557 else
558 {
559 #pragma omp atomic update
560 ++nsolvedprobs;
561 }
562}
563
564/** collect solution results from all pricing problems */
566 GCG_COL** bestcols, /**< best found columns per pricing problem */
567 SCIP_Real* dualsolconv, /**< dual solution values of convexity constraints */
568 SCIP_Bool stabilized, /**< whether the pricing was stabilized */
569 SCIP_Bool* infeasible, /**< pointer to store whether pricing is infeasible */
570 SCIP_Bool* optimal, /**< pointer to store whether all pricing problems were solved to optimality */
571 SCIP_Real* bestobjvals, /**< array to store best lower bounds */
572 SCIP_Real* beststabobj, /**< pointer to store total lower bound */
573 SCIP_Real* bestredcost, /**< pointer to store best total reduced cost */
574 SCIP_Bool* bestredcostvalid /**< pointer to store whether best reduced cost is valid */
575 )
576{
577 int nblocks = GCGgetNPricingprobs(gcg);
578 SCIP_Bool foundcols = FALSE;
579
580 /* initializations */
581 *infeasible = FALSE;
582 *optimal = TRUE;
583 *beststabobj = 0.0;
584 *bestredcost = 0.0;
585 for( int i = 0; i < nblocks; ++i )
586 bestobjvals[i] = -SCIPinfinity(scip_);
587
588 for( int i = 0; i < npricingprobs; ++i )
589 {
590 int probnr = GCGpricingprobGetProbnr(pricingprobs[i]);
591 int nidentblocks = GCGgetNIdenticalBlocks(gcg, probnr);
592 SCIP_Real lowerbound;
593
594 if( *bestredcostvalid && !stabilized && bestcols[probnr] != NULL && SCIPgetStatus(pricingprobs[i]->pricingscip) == SCIP_STATUS_OPTIMAL )
595 {
596 /* set dual bound due to numerical issues: the best col may not belong to the lowerbound of this optimal round
597 * caused by numerical instability of the mip solver */
598 lowerbound = dualsolconv[probnr] + GCGcolGetRedcost(bestcols[probnr]);
599 assert(SCIPisFeasEQ(pricingprobs[i]->pricingscip, GCGpricingprobGetLowerbound(pricingprobs[i]), lowerbound));
600 }
601 else
602 {
603 lowerbound = GCGpricingprobGetLowerbound(pricingprobs[i]);
604 }
605
606 /* check infeasibility */
607 *infeasible |= GCGpricingprobGetStatus(pricingprobs[i]) == GCG_PRICINGSTATUS_INFEASIBLE;
608
609 /* check optimality */
610 *optimal &= GCGpricingprobGetStatus(pricingprobs[i]) == GCG_PRICINGSTATUS_OPTIMAL;
611
612 if( GCGpricingprobGetNImpCols(pricingprobs[i]) > 0 )
613 foundcols = TRUE;
614
615 /* update lower bound information */
616 bestobjvals[probnr] = SCIPisInfinity(scip_, ABS(lowerbound)) ? lowerbound : nidentblocks * lowerbound;
617 if( SCIPisInfinity(scip_, -lowerbound) )
618 *beststabobj = -SCIPinfinity(scip_);
619 else if( !SCIPisInfinity(scip_, -(*beststabobj)) )
620 *beststabobj += bestobjvals[probnr];
621
622 if( bestcols[probnr] != NULL )
623 *bestredcost += GCGcolGetRedcost(bestcols[probnr]) * nidentblocks;
624 }
625
626 *infeasible |= (pricingtype_->getType() == GCG_PRICETYPE_FARKAS && *optimal && !foundcols);
627 *bestredcostvalid &= foundcols || *optimal;
628}
629
630/** check if the next chunk of pricing problems is to be used */
632{
633 int nextchunk = (curchunk + 1) % nchunks;
634
635 if( nextchunk == startchunk )
636 {
637 SCIPdebugMessage("not considering next chunk.\n");
638 return FALSE;
639 }
640 else
641 {
642 SCIPdebugMessage("need considering next chunk = %d/%d\n", nextchunk+1, nchunks);
643 curchunk = nextchunk;
644 return TRUE;
645 }
646}
647
648/** decide whether the pricing loop can be aborted */
650 PricingType* pricingtype, /**< type of pricing (reduced cost or Farkas) */
651 int nfoundcols, /**< number of negative reduced cost columns found so far */
652 int nsuccessfulprobs /**< number of pricing problems solved successfully so far */
653 ) const
654{
655 int nrelpricingprobs = GCGgetNRelPricingprobs(gcg);
656 int _nsolvedprobs;
657
658 if( eagerage == eagerfreq )
659 return FALSE;
660
661 #pragma omp atomic read
662 _nsolvedprobs = nsolvedprobs;
663
664 return !((nfoundcols < pricingtype->getMaxcolsround())
665 && nsuccessfulprobs < pricingtype->getMaxsuccessfulprobs()
666 && nsuccessfulprobs < pricingtype->getRelmaxsuccessfulprobs() * nrelpricingprobs
667 && (nfoundcols == 0 || _nsolvedprobs < pricingtype->getRelmaxprobs() * nrelpricingprobs));
668}
669
671{
672 eagerage = 0;
673}
674
676{
677 if( eagerfreq > 0 )
678 {
679 eagerage++;
680 }
681}
682
683/** for a given problem index, get the corresponding pricing problem (or NULL, if it does not exist) */
685 int probnr /**< index of the pricing problem */
686 )
687{
688 for( int i = 0; i < npricingprobs; ++i )
689 if( GCGpricingprobGetProbnr(pricingprobs[i]) == probnr )
690 return pricingprobs[i];
691
692 return NULL;
693}
694
695/** get maximal possible number of pricing iterations */
697{
698 return maxniters;
699}
700
701} /* namespace gcg */
int GCGbranchGenericBranchdataGetConsblocknr(GCG_BRANCHDATA *branchdata)
SCIP_CONS * GCGbranchGenericBranchdataGetMastercons(GCG_BRANCHDATA *branchdata)
SCIP_Bool GCGisBranchruleGeneric(GCG_BRANCHRULE *branchrule)
branching rule based on vanderbeck's generic branching scheme
virtual SCIP_Real consGetDual(SCIP_CONS *cons) const =0
virtual int getMaxcolsround() const =0
#define SCIP_CALL_EXC(x)
#define DEFAULT_NROUNDSCOL
#define DEFAULT_CHUNKSIZE
#define DEFAULT_HEURPRICINGITERS
#define DEFAULT_EAGERFREQ
#define DEFAULT_MAXHEURDEPTH
#define DEFAULT_SORTING
pricing controller managing the pricing strategy
abstraction for SCIP pricing types
void updatePricingprob(GCG_PRICINGPROB *pricingprob, GCG_PRICINGSTATUS status, SCIP_Real lowerbound, int nimpcols)
SCIP_Bool canPricingloopBeAborted(PricingType *pricingtype, int nfoundcols, int nsuccessfulprobs) const
void evaluatePricingjob(GCG_PRICINGJOB *pricingjob, GCG_PRICINGSTATUS status)
GCG_PRICINGPROB * getPricingprob(int probnr)
SCIP_RETCODE setPricingjobTimelimit(GCG_PRICINGJOB *pricingjob)
SCIP_RETCODE initPricing(PricingType *pricingtype)
void collectResults(GCG_COL **bestcols, SCIP_Real *dualsolconv, SCIP_Bool stabilized, SCIP_Bool *infeasible, SCIP_Bool *optimal, SCIP_Real *bestobjvals, SCIP_Real *beststabobj, SCIP_Real *bestredcost, SCIP_Bool *bestredcostvalid)
SCIP_RETCODE pricingprobNextBranchcons(GCG_PRICINGPROB *pricingprob)
SCIP_RETCODE setupPriorityQueue(SCIP_Real *dualsolconv)
GCG_BRANCHRULE * GCGconsMasterbranchGetBranchrule(SCIP_CONS *cons)
SCIP_CONS * GCGconsMasterbranchGetParentcons(SCIP_CONS *cons)
GCG_BRANCHDATA * GCGconsMasterbranchGetBranchdata(SCIP_CONS *cons)
SCIP_CONS * GCGconsMasterbranchGetActiveCons(GCG *gcg)
SCIP_NODE * GCGconsMasterbranchGetNode(SCIP_CONS *cons)
constraint handler for storing the branching decisions at each node of the tree
#define SCIP_Longint
#define SCIP_Bool
#define MIN(x, y)
#define SCIP_Real
#define ABS(x)
#define MAX(x, y)
#define TRUE
#define FALSE
GCG interface methods.
int GCGpricerGetNSolvers(GCG *gcg)
int GCGpricerGetNRaysProb(GCG *gcg, int probnr)
GCG_SOLVER ** GCGpricerGetSolvers(GCG *gcg)
int GCGpricerGetNPointsProb(GCG *gcg, int probnr)
SCIP_Real GCGcolGetRedcost(GCG_COL *gcgcol)
Definition gcgcol.c:475
GCG_EXPORT SCIP * GCGgetPricingprob(GCG *gcg, int pricingprobnr)
Definition relax_gcg.c:4075
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 GCGgetNPricingprobs(GCG *gcg)
Definition relax_gcg.c:4113
SCIP * GCGgetMasterprob(GCG *gcg)
Definition gcg.cpp:99
GCG_EXPORT SCIP_Bool GCGisPricingprobRelevant(GCG *gcg, int pricingprobnr)
Definition relax_gcg.c:4132
SCIP_Bool SCIPisStopped(SCIP *scip)
SCIP_STATUS SCIPgetStatus(SCIP *scip)
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 SCIP_Bool GCGsolverIsHeurEnabled(GCG_SOLVER *solver)
Definition solver.c:451
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 SCIPaddCharParam(SCIP *scip, const char *name, const char *desc, char *valueptr, SCIP_Bool isadvanced, char defaultvalue, const char *allowedvalues, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
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 SCIPgetRealParam(SCIP *scip, const char *name, SCIP_Real *value)
SCIP_RETCODE SCIPsetRealParam(SCIP *scip, const char *name, SCIP_Real value)
void * GCGpqueueRemove(GCG_PQUEUE *pqueue)
Definition gcgpqueue.c:203
SCIP_RETCODE GCGpqueueInsert(GCG_PQUEUE *pqueue, void *elem)
Definition gcgpqueue.c:173
SCIP_RETCODE GCGpqueueCreate(SCIP *scip, GCG_PQUEUE **pqueue, int initsize, SCIP_DECL_SORTPTRCOMP((*ptrcomp)), GCG_LOCK *memorylock)
Definition gcgpqueue.c:124
void GCGpqueueClear(GCG_PQUEUE *pqueue)
Definition gcgpqueue.c:163
SCIP_RETCODE GCGpqueueResort(GCG_PQUEUE *pqueue)
Definition gcgpqueue.c:244
void GCGpqueueFree(GCG_PQUEUE **pqueue)
Definition gcgpqueue.c:152
#define SCIPfreeBlockMemoryArray(scip, ptr, num)
int SCIPcalcMemGrowSize(SCIP *scip, int num)
#define SCIPallocBlockMemoryArray(scip, ptr, num)
int SCIPnodeGetDepth(SCIP_NODE *node)
SCIP_Bool SCIPinProbing(SCIP *scip)
SCIP_Real SCIPgetSolvingTime(SCIP *scip)
SCIP_Real SCIPinfinity(SCIP *scip)
SCIP_Bool SCIPisFeasEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
SCIP_Real SCIPceil(SCIP *scip, SCIP_Real val)
SCIP_NODE * SCIPgetCurrentNode(SCIP *scip)
static assert(heur !=NULL)
SCIP_CALL(SCIPgetExternBranchCands(origprob, &lpcands, &lpcandssol, NULL, &nlpcands, NULL, NULL, NULL, NULL))
int j
SCIPdebugMessage("feasibility pump finished [%d iterations done].\n", nloops)
SCIP_RETCODE retcode
int i
#define NULL
SCIP_DECL_SORTPTRCOMP(Pricingcontroller::comparePricingjobs)
GCG variable pricer.
void GCGpricingjobSetExact(GCG_PRICINGJOB *pricingjob)
Definition pricingjob.c:256
SCIP_RETCODE GCGpricingjobSetup(GCG *gcg, GCG_PRICINGJOB *pricingjob, SCIP_Bool heuristic, int scoring, int nroundscol, SCIP_Real dualsolconv, int npointsprob, int nraysprob)
Definition pricingjob.c:91
GCG_SOLVER * GCGpricingjobGetSolver(GCG_PRICINGJOB *pricingjob)
Definition pricingjob.c:142
SCIP_Real GCGpricingjobGetScore(GCG_PRICINGJOB *pricingjob)
Definition pricingjob.c:240
void GCGpricingjobResetHeuristic(GCG_PRICINGJOB *pricingjob)
Definition pricingjob.c:264
SCIP_Bool GCGpricingjobIsHeuristic(GCG_PRICINGJOB *pricingjob)
Definition pricingjob.c:248
void GCGpricingjobNextSolver(GCG *gcg, GCG_PRICINGJOB *pricingjob)
Definition pricingjob.c:180
void GCGpricingjobFree(GCG *gcg, GCG_PRICINGJOB **pricingjob)
Definition pricingjob.c:75
int GCGpricingjobGetNHeurIters(GCG_PRICINGJOB *pricingjob)
Definition pricingjob.c:285
SCIP_RETCODE GCGpricingjobCreate(GCG *gcg, GCG_PRICINGJOB **pricingjob, GCG_PRICINGPROB *pricingprob, GCG_SOLVER *solver, int chunk)
Definition pricingjob.c:52
SCIP_Real GCGpricingjobGetChunk(GCG_PRICINGJOB *pricingjob)
Definition pricingjob.c:232
void GCGpricingjobIncreaseNHeurIters(GCG_PRICINGJOB *pricingjob)
Definition pricingjob.c:276
private methods for working with pricing jobs, to be used by the pricing controller only
void GCGpricingprobUpdate(GCG *gcg, GCG_PRICINGPROB *pricingprob, GCG_PRICINGSTATUS status, SCIP_Real lowerbound, int nimpcols)
void GCGpricingprobNextBranchcons(GCG_PRICINGPROB *pricingprob)
int GCGpricingprobGetBranchconsIdx(GCG_PRICINGPROB *pricingprob)
void GCGpricingprobInitPricing(GCG_PRICINGPROB *pricingprob)
Definition pricingprob.c:98
SCIP_Real GCGpricingprobGetLowerbound(GCG_PRICINGPROB *pricingprob)
int GCGpricingprobGetNImpCols(GCG_PRICINGPROB *pricingprob)
void GCGpricingprobReset(GCG *gcg, GCG_PRICINGPROB *pricingprob)
void GCGpricingprobFree(GCG *gcg, GCG_PRICINGPROB **pricingprob)
Definition pricingprob.c:84
SCIP_RETCODE GCGpricingprobAddGenericBranchData(GCG *gcg, GCG_PRICINGPROB *pricingprob, SCIP_CONS *branchcons, SCIP_Real branchdual)
GCG_PRICINGSTATUS GCGpricingprobGetStatus(GCG_PRICINGPROB *pricingprob)
int GCGpricingprobGetProbnr(GCG_PRICINGPROB *pricingprob)
int GCGpricingprobGetNGenericBranchconss(GCG_PRICINGPROB *pricingprob)
SCIP_RETCODE GCGpricingprobCreate(GCG *gcg, GCG_PRICINGPROB **pricingprob, SCIP *pricingscip, int probnr, int nroundscol)
Definition pricingprob.c:52
void GCGpricingprobExitPricing(GCG_PRICINGPROB *pricingprob, int nroundscol)
private methods for working with pricing problems, to be used by the pricing controller only
public methods for working with pricing jobs
public methods for working with pricing problems
various SCIP helper methods
data structures for storing OpenMP locks
struct GCG_BranchData GCG_BRANCHDATA
struct GCG_Branchrule GCG_BRANCHRULE
struct SCIP_Cons SCIP_CONS
struct Gcg GCG
Definition type_gcg.h:44
struct GCG_Col GCG_COL
Definition type_gcgcol.h:44
#define GCG_SET_LOCK(lockname)
Definition type_locks.h:68
#define GCG_UNSET_LOCK(lockname)
Definition type_locks.h:70
@ GCG_PRICETYPE_FARKAS
struct GCG_PricingJob GCG_PRICINGJOB
struct GCG_PricingProb GCG_PRICINGPROB
enum GCG_PricingStatus GCG_PRICINGSTATUS
@ GCG_PRICINGSTATUS_OPTIMAL
@ GCG_PRICINGSTATUS_UNBOUNDED
@ GCG_PRICINGSTATUS_SOLVERLIMIT
@ GCG_PRICINGSTATUS_NOTAPPLICABLE
@ GCG_PRICINGSTATUS_INFEASIBLE
@ GCG_PRICINGSTATUS_UNKNOWN
enum SCIP_Retcode SCIP_RETCODE
struct Scip SCIP
struct GCG_Solver GCG_SOLVER
Definition type_solver.h:51
SCIP_STATUS_OPTIMAL