GCG 4.1.1 (dev)

Generic Column Generation

Loading...
Searching...
No Matches
solver_highs.c
Go to the documentation of this file.
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2/* */
3/* This file is part of the program and library */
4/* GCG --- Generic Column Generation */
5/* a Dantzig-Wolfe decomposition based extension */
6/* of the branch-cut-and-price framework */
7/* SCIP --- Solving Constraint Integer Programs */
8/* */
9/* Copyright (C) 2010-2026 Operations Research, RWTH Aachen University */
10/* Zuse Institute Berlin (ZIB) */
11/* */
12/* Licensed under the Apache License, Version 2.0 (the "License"); */
13/* you may not use this file except in compliance with the License. */
14/* You may obtain a copy of the License at */
15/* */
16/* http://www.apache.org/licenses/LICENSE-2.0 */
17/* */
18/* Unless required by applicable law or agreed to in writing, software */
19/* distributed under the License is distributed on an "AS IS" BASIS, */
20/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
21/* See the License for the specific language governing permissions and */
22/* limitations under the License. */
23/* */
24/* You should have received a copy of the Apache-2.0 license */
25/* along with GCG; see the file LICENSE. If not visit gcg.or.rwth-aachen.de.*/
26/* */
27/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
28
29/**@file solver_highs.c
30 * @brief highs solver for pricing problems
31 * @author Stephen J. Maher
32 */
33
34/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
35/* #define DEBUG_PRICING_ALL_OUTPUT */
36
37#include <math.h>
38#include <string.h>
39#include <stdint.h>
40
41#include "scip/scip.h"
42#include "gcg/gcg.h"
43#include "gcg/solver_highs.h"
44#include "gcg/pub_solver.h"
45#include "gcg/pub_gcgcol.h"
46
47#include "gcg/pricer_gcg.h"
48#include "gcg/scip_misc.h"
49
50#include "interfaces/highs_c_api.h"
51
52#define CHECK_ZERO(x) { int _restat_; \
53 if( (_restat_ = (x)) != 0 ) \
54 { \
55 SCIPerrorMessage("Error in pricing solver: HIGHS returned %d\n", _restat_); \
56 retval = SCIP_INVALIDRESULT; \
57 goto TERMINATE; \
58 } \
59 }
60
61#define CHECK_SOLVER_RUN(x) { int _restat_; \
62 if( (_restat_ = (x)) != 0 && (_restat_ = (x) != 1) ) \
63 { \
64 SCIPerrorMessage("Error in pricing solver: HIGHS returned %d\n", _restat_); \
65 retval = SCIP_INVALIDRESULT; \
66 goto TERMINATE; \
67 } \
68 }
69
70#define SOLVER_NAME "highs"
71#define SOLVER_DESC "highs solver for pricing problems"
72#define SOLVER_PRIORITY 10
73#define SOLVER_HEURENABLED FALSE /**< indicates whether the heuristic solving method of the solver should be enabled */
74#define SOLVER_EXACTENABLED FALSE /**< indicates whether the exact solving method of the solver should be enabled */
75
76#define DEFAULT_CHECKSOLS TRUE /**< should solutions of the pricing MIPs be checked for duplicity? */
77#define DEFAULT_THREADS 1 /**< number of threads the HIGHS pricing solver is allowed to use (0: automatic) */
78#define DEFAULT_STARTNODELIMIT 1000LL /**< start node limit for heuristic pricing */
79#define DEFAULT_STARTGAPLIMIT 0.2 /**< start gap limit for heuristic pricing */
80#define DEFAULT_STARTSOLLIMIT 10LL /**< start solution limit for heuristic pricing */
81#define DEFAULT_NODELIMITFAC 1.25 /**< factor by which to increase node limit for heuristic pricing (1.0: add start limit) */
82#define DEFAULT_STALLNODELIMITFAC 1.25 /**< factor by which to increase stalling node limit for heuristic pricing */
83#define DEFAULT_GAPLIMITFAC 0.8 /**< factor by which to decrease gap limit for heuristic pricing (1.0: subtract start limit) */
84#define DEFAULT_SOLLIMITFAC 1.5 /**< factor by which to increase solution limit for heuristic pricing (1.0: add start limit) */
85
86
87/** pricing solver data */
88struct GCG_SolverData
89{
90 GCG* gcg; /**< GCG instance */
91 SCIP** pricingprobs; /**< array storing the SCIP instances for all pricing problems */
92 int npricingprobs; /**< number of pricing problems */
93 void** highsptr; /**< array of pointers to Highs instances */
94 int* nupdates; /**< array storing the number of updates for all of the pricing problems */
95 SCIP_Longint* curnodelimit; /**< current node limit per pricing problem */
96 SCIP_Real* curgaplimit; /**< current gap limit per pricing problem */
97 SCIP_Longint* cursollimit; /**< current solution limit per pricing problem */
98 /**
99 * information about the basic pricing problem (without potential branching constraints)
100 */
101 SCIP_VAR*** pricingvars; /**< array storing the variables of the pricing problems */
102 int** pricingvartypes; /**< the variable types of the variables in the highs instances */
103 SCIP_CONS*** pricingconss; /**< array storing the constraints of the pricing problems */
104 int* npricingvars; /**< array storing the number of variables of the pricing problems */
105 int* nbasicpricingconss; /**< array storing the basic number of constraints of the pricing problems */
106 /**
107 * parameters
108 */
109 SCIP_Bool checksols; /**< should solutions of the pricing MIPs be checked for duplicity? */
110 int threads; /**< number of threads the HIGHS pricing solver is allowed to use (0: automatic) */
111 SCIP_Longint startnodelimit; /**< start node limit for heuristic pricing */
112 SCIP_Real startgaplimit; /**< start gap limit for heuristic pricing */
113 SCIP_Longint startsollimit; /**< start solution limit for heuristic pricing */
114 SCIP_Real nodelimitfac; /**< factor by which to increase node limit for heuristic pricing (1.0: add start limit) */
115 SCIP_Real gaplimitfac; /**< factor by which to decrease gap limit for heuristic pricing (1.0: subtract start limit) */
116 SCIP_Real sollimitfac; /**< factor by which to increase solution limit for heuristic pricing (1.0: add start limit) */
117
118 SCIP_Bool* ismip; /**< array storing whether the subproblem is a MIP. */
119};
120
121/*
122 * local methods
123 */
124
125/** creates a HIGHS environment and builds the pricing problem */
126static
128 GCG* gcg, /**< GCG data structure */
129 GCG_SOLVERDATA* solverdata, /**< solver data structure */
130 SCIP* pricingprob, /**< pricing problem */
131 int probnr /**< problem number */
132 )
133{
134 SCIP* scip;
135 SCIP_CONS** conss;
136 SCIP_VAR** vars;
137 SCIP_VAR** consvars;
138 SCIP_Real* consvals;
139 SCIP_VAR* var;
140
141 /* the data to supply to Highs */
142 int sense;
143 double* varobj;
144 double* varlb;
145 double* varub;
146 int* vartype;
147 double* rowupper;
148 double* rowlower;
149 int* astart;
150 int* aindex;
151 double* avalue;
152
153 SCIP_Real lhs;
154 SCIP_Real rhs;
155 SCIP_VARTYPE type;
156 SCIP_RETCODE retval;
157 int nconss = 0;
158 int nvars = 0;
159 int varidx;
160 int nconsvars;
161 int nnonzeros;
162 int idx;
163 int c;
164 int i;
165 int v;
166
168
169 /* open HIGHS environment and create problem */
170 solverdata->highsptr[probnr] = Highs_create();
171 solverdata->pricingprobs[probnr] = pricingprob;
172
173 retval = SCIP_OKAY;
174
175 /* set parameters */
176 CHECK_ZERO( Highs_setDoubleOptionValue(solverdata->highsptr[probnr],
177 "mip_rel_gap", 0.0) );
178 CHECK_ZERO( Highs_setDoubleOptionValue(solverdata->highsptr[probnr],
179 "mip_abs_gap", 0.0) );
180 CHECK_ZERO( Highs_setDoubleOptionValue(solverdata->highsptr[probnr],
181 "mip_feasibility_tolerance", SCIPfeastol(pricingprob)) );
182 CHECK_ZERO( Highs_setIntOptionValue(solverdata->highsptr[probnr],
183 "threads", solverdata->threads) );
184 CHECK_ZERO( Highs_setBoolOptionValue(solverdata->highsptr[probnr],
185 "output_flag", FALSE) );
186#ifdef DEBUG_PRICING_ALL_OUTPUT
187 CHECK_ZERO( Highs_setBoolOptionValue(solverdata->highsptr[probnr],
188 "output_flag", TRUE) );
189#endif
190
191 /* set objective sense */
193 sense = 1; // minimisation
194
195 conss = SCIPgetOrigConss(pricingprob);
196 nconss = SCIPgetNOrigConss(pricingprob);
197 vars = SCIPgetOrigVars(pricingprob);
198 nvars = SCIPgetNOrigVars(pricingprob);
199
200 /* arrays for storing the basic constraints and variables */
201 solverdata->npricingvars[probnr] = nvars;
202 solverdata->nbasicpricingconss[probnr] = nconss;
203
204 SCIP_CALL( SCIPallocMemoryArray(scip, &solverdata->pricingvars[probnr], nvars) ); /*lint !e866*/
205 SCIP_CALL( SCIPallocMemoryArray(scip, &solverdata->pricingvartypes[probnr], nvars) ); /*lint !e866*/
206 SCIP_CALL( SCIPallocMemoryArray(scip, &solverdata->pricingconss[probnr], nconss) ); /*lint !e866*/
207
208 /* temporary memory for storing all data about the variables */
213
214 /* temporary memory for storing data about the constraints */
215 SCIP_CALL( SCIPallocBufferArray(scip, &rowlower, nconss) );
216 SCIP_CALL( SCIPallocBufferArray(scip, &rowupper, nconss) );
217 SCIP_CALL( SCIPallocBufferArray(scip, &astart, nconss + 1) );
218
219 /* collect information about variables: bounds, objective function, name, type */
220 for( i = 0; i < nvars; i++ )
221 {
222 var = vars[i];
223 varidx = SCIPvarGetIndex(var);
224 assert(0 <= varidx);
225 assert(varidx < nvars);
226 solverdata->pricingvars[probnr][varidx] = var;
227 SCIP_CALL( SCIPcaptureVar(pricingprob, var) );
228
229 varlb[varidx] = SCIPvarGetLbLocal(var);
230 varub[varidx] = SCIPvarGetUbLocal(var);
231 varobj[varidx] = SCIPvarGetObj(var);
232
233 type = SCIPvarGetType(var);
234
235 switch( type )
236 {
238 vartype[varidx] = 0;
239 break;
242 vartype[varidx] = 1;
243 break;
244 default:
245 SCIPerrorMessage("invalid variable type\n");
246 return SCIP_INVALIDDATA;
247 }
248
249 /* storing whether the problem is a MIP */
250 if( vartype[varidx] > 0 )
251 solverdata->ismip[probnr] = TRUE;
252
253 /* storing the pricing variable type */
254 solverdata->pricingvartypes[probnr][varidx] = vartype[varidx];
255 }
256
257 /* collect right hand sides and ranges of the constraints, count total number of nonzeros */
258 nnonzeros = 0;
259 for( c = 0; c < nconss; ++c )
260 {
261 solverdata->pricingconss[probnr][c] = conss[c];
262 SCIP_CALL( SCIPcaptureCons(pricingprob, conss[c]) );
263
264 nnonzeros += GCGconsGetNVars(scip, conss[c]);
265 lhs = GCGconsGetLhs(pricingprob, conss[c]);
266 rhs = GCGconsGetRhs(pricingprob, conss[c]);
267
268 if( SCIPisInfinity(scip, -lhs) )
269 rowlower[c] = -Highs_getInfinity(solverdata->highsptr[probnr]);
270 else
271 rowlower[c] = lhs;
272
273 if( SCIPisInfinity(scip, rhs) )
274 rowupper[c] = Highs_getInfinity(solverdata->highsptr[probnr]);
275 else
276 rowupper[c] = rhs;
277 }
278
279 /* temporary memory for storing data about coefficients in the constraints */
282
283 /* temporary memory for storing the CSR matrix */
284 SCIP_CALL( SCIPallocBufferArray(scip, &aindex, nnonzeros) );
285 SCIP_CALL( SCIPallocBufferArray(scip, &avalue, nnonzeros) );
286
287 /* collect nonzeros */
288 for( c = 0, idx = 0; c < nconss; ++c )
289 {
290 /* storing the start index for the constraint */
291 astart[c] = idx;
292
293 nconsvars = GCGconsGetNVars(scip, conss[c]);
294
295 /* while this should not happen, sometimes a subproblem is detected that
296 * has empty constraints.
297 */
298 if (nconsvars == 0)
299 continue;
300
301 SCIP_CALL( GCGconsGetVals(pricingprob, conss[c], consvals, nvars) );
302 SCIP_CALL( GCGconsGetVars(pricingprob, conss[c], consvars, nvars) );
303
304 /* get coefficients */
305 for( v = 0; v < nconsvars; ++v )
306 {
307 aindex[idx] = SCIPvarGetIndex(consvars[v]);
308 avalue[idx] = (double)consvals[v];
309 idx++;
310 }
311 }
312 assert(idx == nnonzeros);
313 astart[nconss] = nnonzeros;
314
315 /* passing the data to Highs to build the MIP model
316 * NOTE: the format is row-wise, where HiGHS typically expects col-wise. The value for row-wise is 2,
317 * col-wise is 1*/
318 CHECK_ZERO( Highs_passMip(solverdata->highsptr[probnr], nvars, nconss, nnonzeros, 2, sense, 0, varobj, varlb,
319 varub, rowlower, rowupper, astart, aindex, avalue, vartype) );
320
321#ifdef WRITEPROBLEMS
322 {
323 char filename[SCIP_MAXSTRLEN];
324 (void) SCIPsnprintf(filename, SCIP_MAXSTRLEN, "highs-%s.lp", SCIPgetProbName(pricingprob));
325 SCIPinfoMessage(pricingprob, NULL, "print pricing problem to %s\n", filename);
326 CHECK_ZERO( Highs_writeModel(solverdata->highsptr[probnr], filename) );
327 }
328#endif
329
330 TERMINATE:
331 /* free temporary memory */
332 if( avalue != NULL )
333 {
334 SCIPfreeBufferArray(scip, &avalue);
335 SCIPfreeBufferArray(scip, &aindex);
336
337 SCIPfreeBufferArray(scip, &consvals);
338 SCIPfreeBufferArray(scip, &consvars);
339
340 SCIPfreeBufferArray(scip, &astart);
341 SCIPfreeBufferArray(scip, &rowupper);
342 SCIPfreeBufferArray(scip, &rowlower);
343
344 SCIPfreeBufferArray(scip, &varub);
345 SCIPfreeBufferArray(scip, &varlb);
346 SCIPfreeBufferArray(scip, &vartype);
347 SCIPfreeBufferArray(scip, &varobj);
348 }
349
350 return retval;
351}
352
353
354/** updates bounds and objective coefficients of variables in the given pricing problem */
355static
357 SCIP* scip, /**< SCIP data structure */
358 GCG_SOLVERDATA* solverdata, /**< solver data structure */
359 SCIP* pricingprob, /**< pricing problem */
360 int probnr, /**< problem number */
361 SCIP_Bool varobjschanged, /**< have the objective coefficients changed? */
362 SCIP_Bool varbndschanged /**< have the lower and upper bounds changed? */
363 )
364{
365 SCIP_VAR** vars;
366 double* varobj;
367 double* collower;
368 double* colupper;
369 int* objidx;
370 int* updatevaridx;
371 int nvars;
372 int npricingvars;
373
374 SCIP_RETCODE retval;
375 int i;
376
377 vars = SCIPgetOrigVars(pricingprob);
378 nvars = SCIPgetNOrigVars(pricingprob);
379 npricingvars = solverdata->npricingvars[probnr];
380
381 assert(npricingvars == nvars);
382 assert(npricingvars == Highs_getNumCol(solverdata->highsptr[probnr]));
383
384 retval = SCIP_OKAY;
385
386 if( varobjschanged )
387 {
388 SCIP_CALL( SCIPallocBufferArray(scip, &objidx, npricingvars) );
389 SCIP_CALL( SCIPallocBufferArray(scip, &varobj, npricingvars) );
390 }
391
392 if( varbndschanged )
393 {
394 SCIP_CALL( SCIPallocBufferArray(scip, &updatevaridx, npricingvars) );
395 SCIP_CALL( SCIPallocBufferArray(scip, &collower, npricingvars) );
396 SCIP_CALL( SCIPallocBufferArray(scip, &colupper, npricingvars) );
397 }
398
399 /* get new bounds and objective coefficients of variables */
400 for( i = 0; i < nvars; i++ )
401 {
402 SCIP_VAR* origvar;
403 SCIP_VAR* var;
404 int varidx;
405
406 origvar = vars[i];
407 varidx = SCIPvarGetIndex(origvar);
408 assert(0 <= varidx);
409 assert(varidx < npricingvars);
410
411 if( SCIPgetStage(pricingprob) >= SCIP_STAGE_TRANSFORMED )
412 var = SCIPvarGetTransVar(origvar);
413 else
414 var = origvar;
415
416 if( varbndschanged )
417 {
418 updatevaridx[(size_t)varidx] = varidx;
419 collower[(size_t)varidx] = (double) SCIPvarGetLbGlobal(var);
420 colupper[(size_t)varidx] = (double) SCIPvarGetUbGlobal(var);
421 }
422
423 if( varobjschanged )
424 {
425 objidx[varidx] = varidx;
426 varobj[varidx] = SCIPvarGetObj(origvar);
427 }
428 }
429
430 /* update bounds and objective coefficient of basic variables */
431 if( varbndschanged )
432 {
433 CHECK_ZERO( Highs_changeColsBoundsBySet(solverdata->highsptr[probnr], nvars, updatevaridx, collower, colupper) );
434 }
435 if( varobjschanged )
436 {
437 CHECK_ZERO( Highs_changeColsCostBySet(solverdata->highsptr[probnr], nvars, objidx, varobj) );
438 }
439
440TERMINATE:
441 if( varbndschanged )
442 {
443 SCIPfreeBufferArray(scip, &colupper);
444 SCIPfreeBufferArray(scip, &collower);
445 SCIPfreeBufferArray(scip, &updatevaridx);
446 }
447 if( varobjschanged)
448 {
449 SCIPfreeBufferArray(scip, &varobj);
450 SCIPfreeBufferArray(scip, &objidx);
451 }
452
453 return retval;
454}
455
456/** updates branching constraints in the given pricing problem */
457static
459 SCIP* scip, /**< SCIP data structure */
460 GCG_SOLVERDATA* solverdata, /**< solver data structure */
461 SCIP* pricingprob, /**< pricing problem */
462 int probnr /**< problem number */
463 )
464{
465 SCIP_CONS** conss;
466 SCIP_VAR** consvars;
467 SCIP_Real* consvals;
468
469 /* data for the rows */
470 double* newrowlower;
471 double* newrowupper;
472 int* newstart;
473 int* newindex;
474 double* newvalue;
475
476 int nconss;
477 int nbasicpricingconss;
478 int nhighsrows;
479 int nnewconss = 0;
480 int nnonzeros;
481 int nvars;
482
483 SCIP_RETCODE retval;
484 int idx;
485 int c;
486
487 conss = SCIPgetOrigConss(pricingprob);
488 nconss = SCIPgetNOrigConss(pricingprob);
489 nbasicpricingconss = solverdata->nbasicpricingconss[probnr];
490
491 nvars = SCIPgetNOrigVars(pricingprob);
492
493 retval = SCIP_OKAY;
494
495 nhighsrows = Highs_getNumRow(solverdata->highsptr[probnr]);
496
497 if( nbasicpricingconss < nhighsrows )
498 {
499 CHECK_ZERO( Highs_deleteRowsByRange(solverdata->highsptr[probnr], nbasicpricingconss, nhighsrows - 1) );
500 }
501
502 nnewconss = nconss - nbasicpricingconss;
503
504 if( nnewconss == 0 )
505 return retval;
506
507 /* temporary arrays for storing data about new constraints */
508 SCIP_CALL( SCIPallocClearBufferArray(scip, &newrowlower, nnewconss) );
509 SCIP_CALL( SCIPallocClearBufferArray(scip, &newrowupper, nnewconss) );
510 SCIP_CALL( SCIPallocClearBufferArray(scip, &newstart, nnewconss + 1) );
511
512 /* get information about new constraints */
513 nnonzeros = 0;
514
515 for( c = 0; c < nconss; ++c )
516 {
517 SCIP_Real lhs;
518 SCIP_Real rhs;
519 int nconsvars;
520 int considx;
521
522 /* we assume that nothing changed about the basic constraints */
523 if( c < nbasicpricingconss )
524 {
525 assert(conss[c] == solverdata->pricingconss[probnr][c]);
526 continue;
527 }
528
529 considx = c - nbasicpricingconss;
530 assert(considx >= 0);
531
532 nconsvars = GCGconsGetNVars(scip, conss[c]);
533 lhs = GCGconsGetLhs(pricingprob, conss[c]);
534 rhs = GCGconsGetRhs(pricingprob, conss[c]);
535
536 if( SCIPisInfinity(scip, -lhs) )
537 newrowlower[considx] = -Highs_getInfinity(solverdata->highsptr[probnr]);
538 else
539 newrowlower[considx] = lhs;
540
541 if( SCIPisInfinity(scip, rhs) )
542 newrowupper[considx] = Highs_getInfinity(solverdata->highsptr[probnr]);
543 else
544 newrowupper[considx] = rhs;
545
546 nnonzeros += nconsvars;
547 }
548
549 /* temporary arrays for getting variables and coefficients in new constraints */
552
553 /* temporary arrays for storing data about new constraints */
554 SCIP_CALL( SCIPallocBufferArray(scip, &newindex, nnonzeros) );
555 SCIP_CALL( SCIPallocBufferArray(scip, &newvalue, nnonzeros) );
556
557 /* collect coefficients in new constriants */
558 for( c = 0, idx = 0; c < nconss; ++c )
559 {
560 int considx;
561 int nconsvars;
562 int v;
563
564 /* we assume that nothing changed about the basic constraints */
565 if( c < nbasicpricingconss )
566 {
567 assert(conss[c] == solverdata->pricingconss[probnr][c]);
568 continue;
569 }
570
571 considx = c - nbasicpricingconss;
572 assert(considx >= 0);
573
574 newstart[considx] = idx;
575 nconsvars = GCGconsGetNVars(scip, conss[c]);
576 SCIP_CALL( GCGconsGetVars(pricingprob, conss[c], consvars, nvars) );
577 SCIP_CALL( GCGconsGetVals(pricingprob, conss[c], consvals, nvars) );
578
579 /* get coefficients */
580 for( v = 0; v < nconsvars; ++v )
581 {
582 newindex[idx] = SCIPvarGetIndex(consvars[v]);
583 newvalue[idx] = (double)consvals[v];
584 idx++;
585 }
586 }
587 assert(idx == nnonzeros);
588 newstart[nconss - nbasicpricingconss] = idx;
589
590 /* add new constraints */
591 CHECK_ZERO( Highs_addRows(solverdata->highsptr[probnr], nnewconss, newrowlower, newrowupper, nnonzeros, newstart,
592 newindex, newvalue) );
593
594TERMINATE:
595 if( nnewconss > 0 )
596 {
597 SCIPfreeBufferArray(scip, &newvalue);
598 SCIPfreeBufferArray(scip, &newindex);
599
600 SCIPfreeBufferArray(scip, &consvals);
601 SCIPfreeBufferArray(scip, &consvars);
602
603 SCIPfreeBufferArray(scip, &newstart);
604 SCIPfreeBufferArray(scip, &newrowupper);
605 SCIPfreeBufferArray(scip, &newrowlower);
606 }
607
608 return retval;
609}
610
611
612/** solves the pricing problem with HIGHS */
613static
615 GCG* gcg, /**< GCG data structure */
616 GCG_SOLVERDATA* solverdata, /**< solver data structure */
617 SCIP* pricingprob, /**< pricing problem */
618 int probnr, /**< problem number */
619 SCIP_Real dualsolconv, /**< dual solution value of the corresponding convexity constraint */
620 SCIP_Real* lowerbound, /**< pointer to store lower bound */
621 int* ncols, /**< pointer to store number of columns */
622 GCG_PRICINGSTATUS* status /**< pointer to store the pricing status */
623 )
624{ /*lint -e715*/
625 SCIP* scip;
626 GCG_COL* col;
627 SCIP_RETCODE retval;
628 SCIP_Bool predisabled = FALSE;
629 double* highssolvals;
630 double upperbound;
631 double* primsol = NULL;
632 int numcols;
633 int modelstatus;
634 int runretval;
635
636 SCIP_SOL* sol;
637 SCIP_Bool feasible;
638
640 *ncols = 0;
642 upperbound = SCIPinfinity(pricingprob);
643
644 retval = SCIP_OKAY;
645
646 numcols = Highs_getNumCol(solverdata->highsptr[probnr]);
647 assert(numcols == SCIPgetNOrigVars(pricingprob));
648
649 SCIP_CALL( SCIPallocBufferArray(scip, &highssolvals, numcols) );
650 SOLVEAGAIN:
651 /* the optimization call */
652 runretval = Highs_run(solverdata->highsptr[probnr]);
653 CHECK_SOLVER_RUN(runretval);
654
655 /* get model status from Highs */
656 modelstatus = Highs_getModelStatus(solverdata->highsptr[probnr]);
657
658 /* handle HIGHS solution status */
659 switch( modelstatus )
660 {
661 /* pricing problem was solved to optimality.
662 * NOTE: the optimal status is also returned when a gap limit is reached. As such, the heuristic pricing with
663 * gap limits needs to be handled here.
664 */
665 case 7: /* HighsModelStatus::kOptimal */
666 {
667 double mipgap;
668 assert(runretval == 0);
669
670 /* getting the MIP gap for the solution */
671 CHECK_ZERO( Highs_getDoubleInfoValue(solverdata->highsptr[probnr], "mip_gap", &mipgap) );
672
673 /* if the gap is 0, then we have an optimal solution */
674 if( !solverdata->ismip[probnr] || SCIPisFeasZero(scip, mipgap) )
675 {
677 }
678 else
679 {
680 if( solverdata->gaplimitfac < 1.0 )
681 solverdata->curgaplimit[probnr] *= solverdata->gaplimitfac;
682 else
683 solverdata->curgaplimit[probnr] = MAX(solverdata->curgaplimit[probnr] - solverdata->startgaplimit, 0.0);
684 SCIPdebugMessage(" -> gap limit reached, decreasing to %g\n", solverdata->curgaplimit[probnr]);
686 }
687
688 upperbound = Highs_getObjectiveValue(solverdata->highsptr[probnr]);
689 break;
690 }
691
692 /* pricing problem was proven to be infeasible */
693 case 8: /* HighsModelStatus::kInfeasible */
694 assert(runretval == 0);
696 break;
697
698 /* pricing problem is possibly unbounded */
699 case 9: /* HighsModelStatus::kUnboundedOrInfeasible */
700 case 10: /* HighsModelStatus::kUnbounded */
701 {
702 int highsretval;
703 SCIP_Bool hasprimalray;
704
705 assert(runretval == 0);
706
707 SCIP_CALL( SCIPallocBufferArray(scip, &primsol, numcols) );
708
709 CHECK_ZERO( Highs_getSolution(solverdata->highsptr[probnr], primsol, NULL, NULL, NULL) );
710
711 highsretval = Highs_getPrimalRay(solverdata->highsptr[probnr], &hasprimalray, highssolvals);
712
713 if( highsretval != 0 )
714 {
715 assert(!predisabled);
716
717 SCIPdebugMessage(" -> disable presolving in HIGHS and only solve the LP relaxation to get primal ray\n");
718
719 CHECK_ZERO( Highs_setStringOptionValue(solverdata->highsptr[probnr], "presolve", "off") );
720 CHECK_ZERO( Highs_setBoolOptionValue(solverdata->highsptr[probnr], "solve_relaxation", TRUE) );
721
722 predisabled = TRUE;
723
724 SCIPfreeBufferArray(scip, &primsol);
725
726 goto SOLVEAGAIN;
727 }
728 else
729 {
730 CHECK_ZERO( highsretval );
731 }
732
733 /* since the primal ray is found by solving an LP, then it is necessary to round the integer variables in
734 * the direction of the objective function.
735 */
736 for (int i = 0; i < numcols; i++)
737 {
738 /* checking for integer or binary variables. These have the variable type 1 */
739 if( solverdata->pricingvartypes[probnr][i] == 1 && !SCIPisIntegral(scip, highssolvals[i]) )
740 {
741 if( SCIPgetObjsense(pricingprob) == SCIP_OBJSENSE_MINIMIZE )
742 highssolvals[i] = SCIPisPositive(pricingprob, SCIPvarGetObj(solverdata->pricingvars[probnr][i])) ?
743 SCIPfloor(pricingprob, highssolvals[i]) : SCIPceil(pricingprob, highssolvals[i]);
744 else
745 highssolvals[i] = SCIPisNegative(pricingprob, SCIPvarGetObj(solverdata->pricingvars[probnr][i])) ?
746 SCIPfloor(pricingprob, highssolvals[i]) : SCIPceil(pricingprob, highssolvals[i]);
747 }
748 assert(SCIPisIntegral(scip, highssolvals[i]));
749 }
750
751
752 SCIP_CALL( GCGcreateGcgCol(gcg, pricingprob, &col, probnr, solverdata->pricingvars[probnr], highssolvals, numcols, TRUE, SCIPinfinity(pricingprob)) );
754 ++(*ncols);
755
757
758 SCIPfreeBufferArray(scip, &primsol);
759
760 goto TERMINATE;
761 }
762
763 /* a heuristic pricing limit was reached and may be increased in the next round */
764 /* The iteration limit model status is used for indicating a node or a solution is reached. It must be checked
765 * to identify what limit actually triggered the termination. Since HiGHS doesn't record the number of
766 * solutions found, we can only determine the limit from the number of processed nodes.
767 */
768 case 14: /* HighsModelStatus::kIterationLimit */
769 {
770 int64_t nodecount;
771
772 assert(runretval == 1);
773
774 /* getting the node and solution count */
775 CHECK_ZERO( Highs_getInt64InfoValue(solverdata->highsptr[probnr], "mip_node_count", &nodecount) );
776
777 if( nodecount > solverdata->curnodelimit[probnr] )
778 {
779 int solstatus;
780 SCIP_Longint nodelimitfac;
781
782 /* checking whether a solution exists. If not, then we don't know the current solution status */
783 CHECK_ZERO( Highs_getIntInfoValue(solverdata->highsptr[probnr], "primal_solution_status", &solstatus) );
784
785 if( solstatus < 2 ) /* either infeasible or no solution */
786 {
788 break;
789 }
790
791 nodelimitfac = solverdata->nodelimitfac;
792
793 if( nodelimitfac > 1.0 )
794 solverdata->curnodelimit[probnr] = (SCIP_Longint) (solverdata->curnodelimit[probnr] * solverdata->nodelimitfac);
795 else
796 solverdata->curnodelimit[probnr] += solverdata->startnodelimit;
797 SCIPdebugMessage(" -> node limit reached, increasing to %"SCIP_LONGINT_FORMAT"\n", solverdata->curnodelimit[probnr]);
798 }
799 else
800 {
801 if( solverdata->sollimitfac > 1.0 )
802 solverdata->cursollimit[probnr] = (SCIP_Longint) (solverdata->cursollimit[probnr] * solverdata->sollimitfac);
803 else
804 solverdata->cursollimit[probnr] += solverdata->startsollimit;
805 SCIPdebugMessage(" -> solution limit reached, increasing to %"SCIP_LONGINT_FORMAT"\n", solverdata->cursollimit[probnr]);
806 }
808 upperbound = Highs_getObjectiveValue(solverdata->highsptr[probnr]);
809 break;
810 }
811
812 /* a limit is reached, but not handled by GCG. We check the solution status to determine whether we can use the
813 * upper bound
814 */
815 case 13: /* HighsModelStatus::kTimeLimit */
816 {
817 int solstatus;
818
819 assert(runretval == 1);
820
821 /* checking whether a solution exists. If not, then we don't know the current solution status */
822 CHECK_ZERO( Highs_getIntInfoValue(solverdata->highsptr[probnr], "primal_solution_status", &solstatus) );
823
824 if( solstatus == 2 ) /* the solution is feasible */
825 {
826 upperbound = Highs_getObjectiveValue(solverdata->highsptr[probnr]);
827 }
829 break;
830 }
831
832 case 15: /* HighsModelStatus::kUnknown */
833 {
834 int solstatus;
835
836 assert(runretval == 1);
837
838 /* checking whether a solution exists. If not, then we don't know the current solution status */
839 CHECK_ZERO( Highs_getIntInfoValue(solverdata->highsptr[probnr], "primal_solution_status", &solstatus) );
840
841 if( solstatus == 2 ) /* the solution is feasible */
842 {
843 upperbound = Highs_getObjectiveValue(solverdata->highsptr[probnr]);
844 }
846 break;
847 }
848
849 default:
851 goto TERMINATE;
852 }
853
854 /* if the pricing problem is a MIP, then we can collect the dual bound. Otherwise, if it is an LP, we expect that
855 * the problem is solved to optimality, so the upperbound == lowerbound
856 */
857 if( solverdata->ismip[probnr] )
858 {
859 CHECK_ZERO( Highs_getDoubleInfoValue(solverdata->highsptr[probnr], "mip_dual_bound", lowerbound) );
860 }
861 else
862 *lowerbound = upperbound;
863
864 /* checking whether the lower bound is returned from Highs as inf */
865 if (isinf(*lowerbound))
866 *lowerbound = -SCIPinfinity(scip);
867
868 assert(SCIPisFeasLE(scip, *lowerbound, upperbound));
869
870 SCIPdebugMessage(" -> pricing problem %d solved: status=%d, modelstatus=%d, lowerbound=%g, upperbound=%g\n",
871 probnr, *status, modelstatus, *lowerbound, upperbound);
872
873 assert(SCIPisFeasEQ(scip, *lowerbound, upperbound) || *status != GCG_PRICINGSTATUS_OPTIMAL);
874
875 /* extracting the best solution and checked if it has a negative reduced cost */
876 CHECK_ZERO( Highs_getSolution(solverdata->highsptr[probnr], highssolvals, NULL, NULL, NULL) );
877
878 /* creating a solution from the column generated from solving Highs */
879 SCIP_CALL( SCIPcreateOrigSol(pricingprob, &sol, NULL) );
880 SCIP_CALL( SCIPsetSolVals(pricingprob, sol, numcols, solverdata->pricingvars[probnr], highssolvals) );
881
882 feasible = FALSE;
883
884 /* check whether the solution is feasible */
885 if( !solverdata->checksols )
886 {
887 SCIP_CALL( SCIPcheckSolOrig(pricingprob, sol, &feasible, FALSE, FALSE) );
888
889 /* if the optimal solution is not feasible, we return GCG_PRICINGSTATUS_UNKNOWN as status */
890 if( !feasible )
892 }
893 else
894 feasible = TRUE;
895
896 if( feasible )
897 {
898 SCIP_CALL( GCGcreateGcgColFromSol(gcg, pricingprob, NULL, NULL, &col, probnr, sol, FALSE, SCIPinfinity(pricingprob)) );
900 ++(*ncols);
901 }
902
903 SCIP_CALL( SCIPfreeSol(pricingprob, &sol) );
904
905 assert(*status != GCG_PRICINGSTATUS_OPTIMAL || *ncols > 0);
906 TERMINATE:
907 if( predisabled )
908 {
909 CHECK_ZERO( Highs_setStringOptionValue(solverdata->highsptr[probnr], "presolve", "on") );
910 CHECK_ZERO( Highs_setBoolOptionValue(solverdata->highsptr[probnr], "solve_relaxation", FALSE) );
911 }
912
913 if( primsol != NULL )
914 SCIPfreeBufferArray(scip, &primsol);
915
916 SCIPfreeBufferArray(scip, &highssolvals);
917
918 return retval;
919}
920
921
922/** destructor of pricing solver to free user data (called when SCIP is exiting) */
923static
924GCG_DECL_SOLVERFREE(solverFreeHighs)
925{
926 GCG_SOLVERDATA* solverdata;
927
928 assert(gcg != NULL);
929 assert(solver != NULL);
930
931 solverdata = GCGsolverGetData(solver);
932 assert(solverdata != NULL);
933
935 GCGsolverSetData(solver, NULL);
936
937 return SCIP_OKAY;
938}
939
940/** solving process initialization method of pricing solver (called when branch and bound process is about to begin) */
941static
942GCG_DECL_SOLVERINITSOL(solverInitsolHighs)
943{
944 SCIP* scip;
945 GCG_SOLVERDATA* solverdata;
946 int npricingprobs;
947
948 int i;
949
950 assert(gcg != NULL);
951 assert(solver != NULL);
952
954 solverdata = GCGsolverGetData(solver);
955 assert(solverdata != NULL);
956
958 npricingprobs = solverdata->npricingprobs;
959
960 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(solverdata->highsptr), npricingprobs) );
961 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(solverdata->nupdates), npricingprobs) );
962 BMSclearMemoryArray(solverdata->nupdates, npricingprobs);
963
964 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(solverdata->pricingprobs), npricingprobs) );
965 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(solverdata->pricingvars), npricingprobs) );
966 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(solverdata->pricingvartypes), npricingprobs) );
967 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(solverdata->pricingconss), npricingprobs) );
968 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(solverdata->npricingvars), npricingprobs) );
969 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(solverdata->nbasicpricingconss), npricingprobs) );
970 BMSclearMemoryArray(solverdata->npricingvars, npricingprobs);
971 BMSclearMemoryArray(solverdata->nbasicpricingconss, npricingprobs);
972
973 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &solverdata->curnodelimit, npricingprobs) );
974 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &solverdata->curgaplimit, npricingprobs) );
975 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &solverdata->cursollimit, npricingprobs) );
976 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &solverdata->ismip, npricingprobs) );
977
978 BMSclearMemoryArray(solverdata->ismip, npricingprobs);
979
980 for( i = 0; i < npricingprobs; ++i )
981 {
983 {
984 SCIP_CALL( buildProblem(gcg, solverdata, GCGgetPricingprob(gcg, i), i) );
985 }
986
987 solverdata->curnodelimit[i] = solverdata->startnodelimit;
988 solverdata->curgaplimit[i] = solverdata->startgaplimit;
989 solverdata->cursollimit[i] = solverdata->startsollimit;
990 }
991
992 return SCIP_OKAY;
993}
994
995/** solving process deinitialization method of pricing solver (called before branch and bound process data is freed) */
996static
997GCG_DECL_SOLVEREXITSOL(solverExitsolHighs)
998{
999 SCIP* scip;
1000 GCG_SOLVERDATA* solverdata;
1001 SCIP_RETCODE retval;
1002 int npricingprobs;
1003 int i;
1004 int j;
1005
1006 assert(gcg != NULL);
1007 assert(solver != NULL);
1008
1010 solverdata = GCGsolverGetData(solver);
1011 assert(solverdata != NULL);
1012
1013 retval = SCIP_OKAY;
1014
1015 npricingprobs = GCGgetNPricingprobs(gcg);
1016
1017 /* free pricing problems */
1018 for( i = 0; i < npricingprobs; ++i )
1019 {
1021 {
1022 /* free the HiGHS instance */
1023 Highs_destroy(solverdata->highsptr[i]);
1024
1025 if( solverdata->nbasicpricingconss[i] > 0 )
1026 {
1027 /* release stored constraints */
1028 for( j = 0; j < solverdata->nbasicpricingconss[i]; ++j )
1029 {
1030 SCIP_CALL( SCIPreleaseCons(solverdata->pricingprobs[i], &solverdata->pricingconss[i][j]) );
1031 }
1032 SCIPfreeMemoryArray(scip, &(solverdata->pricingconss[i]));
1033 }
1034
1035 if( solverdata->npricingvars[i] > 0 )
1036 {
1037 /* release stored constraints */
1038 for( j = 0; j < solverdata->npricingvars[i]; ++j )
1039 {
1040 SCIP_CALL( SCIPreleaseVar(solverdata->pricingprobs[i], &solverdata->pricingvars[i][j]) );
1041 }
1042 SCIPfreeMemoryArray(scip, &(solverdata->pricingvartypes[i]));
1043 SCIPfreeMemoryArray(scip, &(solverdata->pricingvars[i]));
1044 }
1045 }
1046 }
1047
1048 SCIPfreeBlockMemoryArray(scip, &solverdata->ismip, solverdata->npricingprobs);
1049
1050 SCIPfreeBlockMemoryArray(scip, &solverdata->cursollimit, solverdata->npricingprobs);
1051 SCIPfreeBlockMemoryArray(scip, &solverdata->curgaplimit, solverdata->npricingprobs);
1052 SCIPfreeBlockMemoryArray(scip, &solverdata->curnodelimit, solverdata->npricingprobs);
1053
1054 SCIPfreeBlockMemoryArray(scip, &(solverdata->nbasicpricingconss), solverdata->npricingprobs);
1055 SCIPfreeBlockMemoryArray(scip, &(solverdata->npricingvars), solverdata->npricingprobs);
1056 SCIPfreeBlockMemoryArray(scip, &(solverdata->pricingconss), solverdata->npricingprobs);
1057 SCIPfreeBlockMemoryArray(scip, &(solverdata->pricingvartypes), solverdata->npricingprobs);
1058 SCIPfreeBlockMemoryArray(scip, &(solverdata->pricingvars), solverdata->npricingprobs);
1059 SCIPfreeBlockMemoryArray(scip, &(solverdata->pricingprobs), solverdata->npricingprobs);
1060
1061 SCIPfreeBlockMemoryArray(scip, &(solverdata->nupdates), solverdata->npricingprobs);
1062 SCIPfreeBlockMemoryArray(scip, &(solverdata->highsptr), solverdata->npricingprobs);
1063
1064 return retval;
1065}
1066
1067#define solverInitHighs NULL
1068#define solverExitHighs NULL
1069
1070/** update method for pricing solver, used to update solver specific pricing problem data */
1071static
1072GCG_DECL_SOLVERUPDATE(solverUpdateHighs)
1073{
1074 GCG_SOLVERDATA* solverdata;
1075
1076 solverdata = GCGsolverGetData(solver);
1077 assert(solverdata != NULL);
1078
1079 SCIPdebugMessage("HIGHS solver -- update data for problem %d: varobjschanged = %u, varbndschanged = %u, consschanged = %u\n",
1080 probnr, varobjschanged, varbndschanged, consschanged);
1081
1082 /* update pricing problem information */
1083 SCIP_CALL( updateVars(GCGgetMasterprob(gcg), solverdata, pricingprob, probnr, varobjschanged, varbndschanged) );
1084 if( consschanged )
1085 {
1086 SCIP_CALL( updateBranchingConss(GCGgetMasterprob(gcg), solverdata, pricingprob, probnr) );
1087 }
1088
1089 solverdata->curnodelimit[probnr] = solverdata->startnodelimit;
1090 solverdata->curgaplimit[probnr] = solverdata->startgaplimit;
1091 solverdata->cursollimit[probnr] = solverdata->startsollimit;
1092
1093#ifdef WRITEPROBLEMS
1094 /* Print the pricing problem after updating:
1095 * * after checking variable bounds, because they change in particular when a new generic branching subproblem is considered
1096 * * but not after adding new branching constraints, since objectives will be set afterwards before solving
1097 */
1098 if( varbndschanged && !consschanged )
1099 {
1100 char filename[SCIP_MAXSTRLEN];
1101
1102 ++(solverdata->nupdates[probnr]);
1103
1104 (void) SCIPsnprintf(filename, SCIP_MAXSTRLEN, "highs-%s-%d-%d.lp", SCIPgetProbName(pricingprob), SCIPgetNNodes(scip), solverdata->nupdates[probnr]);
1105 SCIPinfoMessage(pricingprob, NULL, "print pricing problem to %s\n", filename);
1106 CHECK_ZERO( Highs_writeModel(solverdata->highsptr[probnr], filename) );
1107 }
1108#endif
1109
1110 return SCIP_OKAY;
1111}
1112
1113/** heuristic solving method of HIGHS solver */
1114static
1115GCG_DECL_SOLVERSOLVEHEUR(solverSolveHeurHighs)
1116{
1117 GCG_SOLVERDATA* solverdata;
1118 int ncols;
1119 SCIP_RETCODE retval;
1120
1121 solverdata = GCGsolverGetData(solver);
1122 assert(solverdata != NULL);
1123
1124 SCIPdebugMessage("calling heuristic pricing with HIGHS for pricing problem %d\n", probnr);
1125
1126 retval = SCIP_OKAY;
1127
1128 /* set heuristic limits */
1129 CHECK_ZERO( Highs_setIntOptionValue(solverdata->highsptr[probnr], "mip_max_nodes",
1130 (int) solverdata->curnodelimit[probnr]) );
1131 CHECK_ZERO( Highs_setDoubleOptionValue(solverdata->highsptr[probnr], "mip_rel_gap",
1132 (double) solverdata->curgaplimit[probnr]) );
1133 CHECK_ZERO( Highs_setIntOptionValue(solverdata->highsptr[probnr], "mip_max_improving_sols",
1134 (int) solverdata->cursollimit[probnr]) );
1135
1136 /* solve the pricing problem and evaluate solution */
1137 SCIP_CALL( solveHighs(gcg, solverdata, pricingprob, probnr, dualsolconv, lowerbound, &ncols, status) );
1138 assert(*status != GCG_PRICINGSTATUS_OPTIMAL || ncols > 0);
1139
1140 TERMINATE:
1141 return retval;
1142}
1143
1144/** solving method for pricing solver which solves the pricing problem to optimality */
1145static
1146GCG_DECL_SOLVERSOLVE(solverSolveHighs)
1147{
1148 GCG_SOLVERDATA* solverdata;
1149 int ncols;
1150 SCIP_RETCODE retval;
1151
1152 assert(solver != NULL);
1153
1154 solverdata = GCGsolverGetData(solver);
1155 assert(solverdata != NULL);
1156
1157 SCIPdebugMessage("calling exact pricing with HIGHS for pricing problem %d\n", probnr);
1158
1159 retval = SCIP_OKAY;
1160
1161 /* set limits to (infinite/zero) default values */
1162 CHECK_ZERO( Highs_setIntOptionValue(solverdata->highsptr[probnr], "mip_max_nodes", INT_MAX) );
1163 CHECK_ZERO( Highs_setDoubleOptionValue(solverdata->highsptr[probnr], "mip_rel_gap", 0.0) );
1164 CHECK_ZERO( Highs_setIntOptionValue(solverdata->highsptr[probnr], "mip_max_improving_sols", INT_MAX) );
1165
1166 /* solve the pricing problem and evaluate solution */
1167 SCIP_CALL( solveHighs(gcg, solverdata, pricingprob, probnr, dualsolconv, lowerbound, &ncols, status) );
1168 assert(*status != GCG_PRICINGSTATUS_OPTIMAL || ncols > 0);
1169
1170 TERMINATE:
1171 return retval;
1172}
1173
1174/** creates the HIGHS pricing solver and includes it in GCG */
1176 GCG* gcg /**< GCG data structure */
1177 )
1178{
1179 SCIP* origprob;
1180 GCG_SOLVERDATA* solverdata;
1181 char name[SCIP_MAXSTRLEN];
1182
1185
1188 solverUpdateHighs, solverSolveHighs, solverSolveHeurHighs, solverFreeHighs, solverInitHighs,
1189 solverExitHighs, solverInitsolHighs, solverExitsolHighs, solverdata));
1190
1191 SCIP_CALL( SCIPaddBoolParam(origprob, "pricingsolver/highs/checksols",
1192 "should solutions of the pricing MIPs be checked for duplicity?",
1193 &solverdata->checksols, TRUE, DEFAULT_CHECKSOLS, NULL, NULL));
1194
1195 SCIP_CALL( SCIPaddIntParam(origprob, "pricingsolver/highs/threads",
1196 "number of threads the HiGHS pricing solver is allowed to use (0: automatic)",
1197 &solverdata->threads, TRUE, DEFAULT_THREADS, 0, INT_MAX, NULL, NULL));
1198
1199 SCIP_CALL( SCIPaddLongintParam(origprob, "pricingsolver/highs/startnodelimit",
1200 "start node limit for heuristic pricing",
1201 &solverdata->startnodelimit, TRUE, DEFAULT_STARTNODELIMIT, 0, INT_MAX, NULL, NULL) );
1202
1203 SCIP_CALL( SCIPaddRealParam(origprob, "pricingsolver/highs/startgaplimit",
1204 "start gap limit for heuristic pricing",
1205 &solverdata->startgaplimit, TRUE, DEFAULT_STARTGAPLIMIT, 0.0, 1.0, NULL, NULL) );
1206
1207 SCIP_CALL( SCIPaddLongintParam(origprob, "pricingsolver/highs/startsollimit",
1208 "start solution limit for heuristic pricing",
1209 &solverdata->startsollimit, TRUE, DEFAULT_STARTSOLLIMIT, 0, INT_MAX, NULL, NULL) );
1210
1211 SCIP_CALL( SCIPaddRealParam(origprob, "pricingsolver/highs/nodelimitfac",
1212 "factor by which to increase node limit for heuristic pricing (1.0: add start limit)",
1214
1215 SCIP_CALL( SCIPaddRealParam(origprob, "pricingsolver/highs/gaplimitfac",
1216 "factor by which to decrease gap limit for heuristic pricing (1.0: subtract start limit)",
1217 &solverdata->gaplimitfac, TRUE, DEFAULT_GAPLIMITFAC, 0.0, 1.0, NULL, NULL) );
1218
1219 SCIP_CALL( SCIPaddRealParam(origprob, "pricingsolver/highs/sollimitfac",
1220 "factor by which to increase solution limit for heuristic pricing (1.0: add start limit)",
1222
1223 SCIPsnprintf(name, SCIP_MAXSTRLEN, "HiGHS %s", Highs_version());
1224 SCIP_CALL( SCIPincludeExternalCodeInformation(origprob, name, "High performance serial and parallel solver for large-scale sparse LP, MIP, and QP models (https://highs.dev/)") );
1225
1226 return SCIP_OKAY;
1227}
#define DEFAULT_THREADS
#define SCIP_MAXSTRLEN
#define SCIP_Longint
#define SCIP_Bool
#define SCIP_Real
#define MAX(x, y)
#define SCIP_LONGINT_FORMAT
#define TRUE
#define FALSE
GCG interface methods.
SCIP_RETCODE GCGpricerAddCol(GCG *gcg, GCG_COL *col)
SCIP_RETCODE GCGcreateGcgColFromSol(GCG *gcg, SCIP *pricingprob, SCIP *subproblem, SCIP_HASHMAP *varmap, GCG_COL **gcgcol, int prob, SCIP_SOL *sol, SCIP_Bool isray, SCIP_Real redcost)
Definition gcgcol.c:267
SCIP_RETCODE GCGcreateGcgCol(GCG *gcg, SCIP *pricingprob, GCG_COL **gcgcol, int probnr, SCIP_VAR **vars, SCIP_Real *vals, int nvars, SCIP_Bool isray, SCIP_Real redcost)
Definition gcgcol.c:53
GCG_EXPORT SCIP * GCGgetPricingprob(GCG *gcg, int pricingprobnr)
Definition relax_gcg.c:4075
SCIP * GCGgetDwMasterprob(GCG *gcg)
Definition gcg.cpp:123
SCIP * GCGgetOrigprob(GCG *gcg)
Definition gcg.cpp:87
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_STAGE SCIPgetStage(SCIP *scip)
const char * SCIPgetProbName(SCIP *scip)
int SCIPgetNOrigConss(SCIP *scip)
SCIP_VAR ** SCIPgetOrigVars(SCIP *scip)
int SCIPgetNOrigVars(SCIP *scip)
SCIP_CONS ** SCIPgetOrigConss(SCIP *scip)
SCIP_OBJSENSE SCIPgetObjsense(SCIP *scip)
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 SCIPinfoMessage(SCIP *scip, FILE *file, const char *formatstr,...)
GCG_EXPORT GCG_SOLVERDATA * GCGsolverGetData(GCG_SOLVER *solver)
Definition solver.c:400
GCG_EXPORT void GCGsolverSetData(GCG_SOLVER *solver, GCG_SOLVERDATA *solverdata)
Definition solver.c:410
SCIP_RETCODE SCIPaddLongintParam(SCIP *scip, const char *name, const char *desc, SCIP_Longint *valueptr, SCIP_Bool isadvanced, SCIP_Longint defaultvalue, SCIP_Longint minvalue, SCIP_Longint maxvalue, 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 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 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 SCIPreleaseCons(SCIP *scip, SCIP_CONS **cons)
SCIP_RETCODE SCIPcaptureCons(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPincludeExternalCodeInformation(SCIP *scip, const char *name, const char *description)
#define SCIPfreeBlockMemoryArray(scip, ptr, num)
#define SCIPallocMemoryArray(scip, ptr, num)
#define SCIPallocClearBufferArray(scip, ptr, num)
#define SCIPallocBufferArray(scip, ptr, num)
#define SCIPallocMemory(scip, ptr)
#define SCIPfreeMemoryArray(scip, ptr)
#define SCIPallocBlockMemoryArray(scip, ptr, num)
SCIP_RETCODE SCIPcheckSolOrig(SCIP *scip, SCIP_SOL *sol, SCIP_Bool *feasible, SCIP_Bool printreason, SCIP_Bool completely)
SCIP_RETCODE SCIPfreeSol(SCIP *scip, SCIP_SOL **sol)
SCIP_RETCODE SCIPcreateOrigSol(SCIP *scip, SCIP_SOL **sol, SCIP_HEUR *heur)
SCIP_RETCODE SCIPsetSolVals(SCIP *scip, SCIP_SOL *sol, int nvars, SCIP_VAR **vars, SCIP_Real *vals)
SCIP_Longint SCIPgetNNodes(SCIP *scip)
SCIP_Real SCIPinfinity(SCIP *scip)
SCIP_Bool SCIPisIntegral(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisFeasEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisPositive(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisFeasZero(SCIP *scip, SCIP_Real val)
SCIP_Real SCIPfloor(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisFeasLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Real SCIPfeastol(SCIP *scip)
SCIP_Bool SCIPisNegative(SCIP *scip, SCIP_Real val)
SCIP_Real SCIPceil(SCIP *scip, SCIP_Real val)
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
SCIP_VARTYPE SCIPvarGetType(SCIP_VAR *var)
SCIP_Real SCIPvarGetUbGlobal(SCIP_VAR *var)
int SCIPvarGetIndex(SCIP_VAR *var)
SCIP_RETCODE SCIPreleaseVar(SCIP *scip, SCIP_VAR **var)
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
SCIP_Real SCIPvarGetLbGlobal(SCIP_VAR *var)
SCIP_VAR * SCIPvarGetTransVar(SCIP_VAR *var)
SCIP_RETCODE SCIPcaptureVar(SCIP *scip, SCIP_VAR *var)
int SCIPsnprintf(char *t, int len, const char *s,...)
SCIPfreeMemory(GCGgetOrigprob(gcg), &divingdata)
static assert(heur !=NULL)
SCIP_CALL(SCIPgetExternBranchCands(origprob, &lpcands, &lpcandssol, NULL, &nlpcands, NULL, NULL, NULL, NULL))
SCIP * origprob
SCIP_VAR * var
SCIP_VAR ** vars
int j
SCIPdebugMessage("feasibility pump finished [%d iterations done].\n", nloops)
int i
int nvars
SCIPfreeBufferArray(scip, &cycles)
SCIP_SOL * sol
#define NULL
#define BMSclearMemoryArray(ptr, num)
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)
GCG variable pricer.
public methods for working with gcg columns
#define SCIPerrorMessage
various SCIP helper methods
#define SOLVER_HEURENABLED
#define SOLVER_EXACTENABLED
#define SOLVER_NAME
#define SOLVER_DESC
#define SOLVER_PRIORITY
#define DEFAULT_SOLLIMITFAC
#define DEFAULT_STARTSOLLIMIT
static SCIP_RETCODE buildProblem(GCG *gcg, GCG_SOLVERDATA *solverdata, SCIP *pricingprob, int probnr)
static SCIP_RETCODE updateVars(SCIP *scip, GCG_SOLVERDATA *solverdata, SCIP *pricingprob, int probnr, SCIP_Bool varobjschanged, SCIP_Bool varbndschanged)
#define CHECK_ZERO(x)
#define DEFAULT_CHECKSOLS
#define DEFAULT_STARTGAPLIMIT
#define DEFAULT_STARTNODELIMIT
static SCIP_RETCODE updateBranchingConss(SCIP *scip, GCG_SOLVERDATA *solverdata, SCIP *pricingprob, int probnr)
#define DEFAULT_GAPLIMITFAC
#define DEFAULT_NODELIMITFAC
#define solverExitHighs
#define solverInitHighs
static SCIP_RETCODE solveHighs(GCG *gcg, GCG_SOLVERDATA *solverdata, SCIP *pricingprob, int probnr, SCIP_Real dualsolconv, SCIP_Real *lowerbound, int *ncols, GCG_PRICINGSTATUS *status)
#define CHECK_SOLVER_RUN(x)
SCIP_RETCODE GCGincludeSolverHighs(GCG *gcg)
highs solver for pricing problems
SCIP_VAR *** pricingvars
SCIP_CONS *** pricingconss
SCIP_Longint startnodelimit
SCIP_Real * curgaplimit
SCIP_Real nodelimitfac
SCIP_Bool * ismip
SCIP_Real startgaplimit
SCIP_Bool checksols
SCIP_Real gaplimitfac
SCIP_Longint * cursollimit
SCIP_Longint * curnodelimit
int ** pricingvartypes
int * nbasicpricingconss
SCIP_Longint startsollimit
SCIP ** pricingprobs
SCIP_Real sollimitfac
struct SCIP_Cons SCIP_CONS
struct Gcg GCG
Definition type_gcg.h:44
struct GCG_Col GCG_COL
Definition type_gcgcol.h:44
enum GCG_PricingStatus GCG_PRICINGSTATUS
@ GCG_PRICINGSTATUS_OPTIMAL
@ GCG_PRICINGSTATUS_UNBOUNDED
@ GCG_PRICINGSTATUS_SOLVERLIMIT
@ GCG_PRICINGSTATUS_INFEASIBLE
@ GCG_PRICINGSTATUS_UNKNOWN
SCIP_OBJSENSE_MINIMIZE
SCIP_INVALIDDATA
enum SCIP_Retcode SCIP_RETCODE
struct Scip SCIP
SCIP_STAGE_TRANSFORMED
struct SCIP_Sol SCIP_SOL
#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_SOLVERSOLVEHEUR(x)
struct GCG_SolverData GCG_SOLVERDATA
Definition type_solver.h:50
struct SCIP_Var SCIP_VAR
SCIP_VARTYPE_INTEGER
SCIP_VARTYPE_CONTINUOUS
SCIP_VARTYPE_BINARY
enum SCIP_Vartype SCIP_VARTYPE