Scippy

GCG

Branch-and-Price & Column Generation for Everyone

solver_knapsack.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_knapsack.c
30 * @brief knapsack solver for pricing problems
31 * @author Gerald Gamrath
32 * @author Martin Bergner
33 * @author Christian Puchert
34 */
35
36/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
37
38#include <assert.h>
39#include <string.h>
40
41#include "gcg/solver_knapsack.h"
42#include "scip/cons_linear.h"
43#include "scip/cons_knapsack.h"
44#include "gcg/pricer_gcg.h"
45#include "gcg/pub_solver.h"
46#include "gcg/relax_gcg.h"
47#include "gcg/pub_gcgcol.h"
48
49#define SOLVER_NAME "knapsack"
50#define SOLVER_DESC "knapsack solver for pricing problems"
51#define SOLVER_PRIORITY 200
52
53#define SOLVER_HEURENABLED FALSE /**< indicates whether the heuristic solving method of the solver should be enabled */
54#define SOLVER_EXACTENABLED TRUE /**< indicates whether the exact solving method of the solver should be enabled */
55
56/* knapsack pricing solver needs no solverdata */
57/* struct GCG_SolverData {}; */
58
59
60/*
61 * Local methods
62 */
63
64/** solve the pricing problem as a knapsack problem, either exactly or approximately */
65static
67 SCIP_Bool exactly, /**< should the pricing problem be solved to optimality or heuristically? */
68 GCG* gcg, /**< GCG data structure */
69 SCIP* pricingprob, /**< pricing problem SCIP data structure */
70 GCG_SOLVER* solver, /**< solver data structure */
71 int probnr, /**< problem number */
72 SCIP_Real* lowerbound, /**< pointer to store lower bound */
73 GCG_PRICINGSTATUS* status /**< pointer to store pricing problem status */
74 )
75{ /*lint -e715 */
76 int nsolvars;
77 GCG_COL* col;
78 SCIP_Real solval;
79 SCIP_VAR** solvars = NULL;
80 SCIP_Real* solvals = NULL;
81
82 assert(pricingprob != NULL);
83
84 SCIP_CALL( GCGsolverKnapsackSolveKnapsack(exactly, pricingprob, &solval, status, &solvars, &solvals, &nsolvars) );
85
86 if( solvars != NULL )
87 {
88 assert(solvals != NULL);
89
90 if( *status == GCG_PRICINGSTATUS_OPTIMAL )
91 {
92 *lowerbound = exactly ? solval : -SCIPinfinity(pricingprob);
93
94 SCIP_CALL( GCGcreateGcgCol(gcg, pricingprob, &col, probnr, solvars, solvals, nsolvars, FALSE, SCIPinfinity(pricingprob)) );
96 }
97
98 SCIPfreeBufferArray(pricingprob, &solvals);
99 SCIPfreeBufferArray(pricingprob, &solvars);
100 }
101
102 return SCIP_OKAY;
103}
104
105
108 SCIP_Bool exactly, /**< should the pricing problem be solved to optimality or heuristically? */
109 SCIP* pricingprob, /**< pricing problem SCIP data structure */
110 SCIP_Real* solval, /**< pointer to store the solution objective value */
111 GCG_PRICINGSTATUS* status, /**< pointer to store pricing problem status */
112 SCIP_VAR*** solvars, /**< pointer to store solution vars (will be allocated as buffer array and must be freed afterwards) */
113 SCIP_Real** solvals, /**< pointer to store solution vals (will be allocated as buffer array and must be freed afterwards) */
114 int* nsolvars /**< pointer to store the number of solution vars */
115 )
116{
117 SCIP_CONS* cons;
118 SCIP_CONSHDLR* conshdlr;
119 SCIP_VAR** consvars;
120 SCIP_Longint* consvals;
121 int nconsvars;
122
123 SCIP_VAR** pricingprobvars;
124 int npricingprobvars;
125 int nconss;
126 int nitems;
127 SCIP_Longint* weights;
128 SCIP_Real* profits;
129 SCIP_Real* ubs;
130 SCIP_Longint capacity;
131 SCIP_Longint prelcapacity;
132 int* items;
133 int* solitems;
134 int nsolitems;
135 int* nonsolitems;
136 int nnonsolitems;
137 SCIP_Bool success;
138 SCIP_Bool inferbounds;
139 int i;
140 int j;
141 int k;
142
143 /* check preconditions */
144 assert(pricingprob != NULL);
145 assert(status != NULL);
146
147 assert(SCIPgetObjsense(pricingprob) == SCIP_OBJSENSE_MINIMIZE);
148
149 pricingprobvars = SCIPgetVars(pricingprob);
150 npricingprobvars = SCIPgetNVars(pricingprob);
151
152 SCIPdebugMessage("Knapsack solver -- checking prerequisites\n");
153
155
156 /* check prerequisites: the pricing problem can be solved as a knapsack problem only if
157 * - all variables are nonnegative integer variables
158 * - there is only one constraint, which has infinite lhs and integer rhs
159 */
160 nconss = SCIPgetNConss(pricingprob);
161 if( nconss != 1 )
162 {
163 SCIPdebugMessage(" -> pricing problem has more than one constraint\n");
164 return SCIP_OKAY;
165 }
166 if( SCIPgetNBinVars(pricingprob) + SCIPgetNIntVars(pricingprob) < npricingprobvars )
167 {
168 SCIPdebugMessage(" -> pricing problem has continuous variables\n");
169 return SCIP_OKAY;
170 }
171 for( i = SCIPgetNBinVars(pricingprob); i < SCIPgetNBinVars(pricingprob) + SCIPgetNIntVars(pricingprob); ++i )
172 {
173 if( SCIPisNegative(pricingprob, SCIPvarGetLbLocal(pricingprobvars[i])) )
174 {
175 SCIPdebugMessage(" -> pricing problem has variables with negative lower bounds\n");
176 return SCIP_OKAY;
177 }
178 }
179
180 cons = SCIPgetConss(pricingprob)[0];
181 assert(cons != NULL);
182
183 conshdlr = SCIPconsGetHdlr(cons);
184 assert(conshdlr != NULL);
185
186 consvals = NULL;
187
188 /*
189 * Check if the constraint is a knapsack constraint, and in that case,
190 * get its variables, their coefficients as well as the capacity
191 *
192 * @note The constraint may be either of type 'linear' or 'knapsack';
193 * the latter might be the case if the pricing problem has already been treated before in the loop
194 * and if the constraint has therefore already been upgraded
195 */
196 if( strcmp(SCIPconshdlrGetName(conshdlr), "linear") == 0 )
197 {
198 SCIP_Real* realconsvals;
199
200 if( !SCIPisIntegral(pricingprob, SCIPgetRhsLinear(pricingprob, cons)) ||
201 !SCIPisInfinity(pricingprob, - SCIPgetLhsLinear(pricingprob, cons)) )
202 {
203 SCIPdebugMessage(" -> pricing constraint is bounded from below or has fractional rhs\n");
204 return SCIP_OKAY;
205 }
206
207 consvars = SCIPgetVarsLinear(pricingprob, cons);
208 realconsvals = SCIPgetValsLinear(pricingprob, cons);
209 nconsvars = SCIPgetNVarsLinear(pricingprob, cons);
210
211 SCIP_CALL( SCIPallocBufferArray(pricingprob, &consvals, nconsvars) );
212
213 /* Check integrality of coefficients */
214 for( i = 0; i < nconsvars; i++ )
215 {
216 if( !SCIPisIntegral(pricingprob, realconsvals[i]) )
217 {
218 SCIPdebugMessage(" -> pricing constraint has fractional coefficient\n");
219 SCIPfreeBufferArray(pricingprob, &consvals);
220 return SCIP_OKAY;
221 }
222 else
223 consvals[i] = (SCIP_Longint) SCIPfloor(pricingprob, realconsvals[i]);
224 }
225 capacity = (SCIP_Longint) SCIPfloor(pricingprob, SCIPgetRhsLinear(pricingprob, cons));
226
227 /* Check signs of variable coefficients in constraint and objective;
228 * compute a preliminary capacity, used to deduce upper bounds for unbounded variables
229 */
230 prelcapacity = capacity;
231 inferbounds = FALSE;
232 for( i = 0; i < nconsvars; i++ )
233 {
234 if( SCIPisInfinity(pricingprob, SCIPvarGetUbLocal(consvars[i])) )
235 inferbounds = TRUE;
236
237 if( consvals[i] < 0 )
238 {
239 /* If a variable has an infinite upper bound, the capacity is not deducible */
240 if( SCIPisInfinity(pricingprob, SCIPvarGetUbLocal(consvars[i])) )
241 {
242 SCIPdebugMessage(" -> variable with negative coefficient has no upper bound\n");
243 SCIPfreeBufferArray(pricingprob, &consvals);
244 return SCIP_OKAY;
245 }
246
247 /* increase capacity */
248 prelcapacity -= (SCIP_Longint) SCIPfloor(pricingprob, consvals[i] * SCIPvarGetUbLocal(consvars[i]));
249 }
250 }
251
252 SCIP_CALL( SCIPallocBufferArray(pricingprob, &ubs, nconsvars) );
253
254 SCIPdebugMessage("Set variable upper bounds\n");
255
256 /* infer upper bounds for unbounded variables */
257 for( i = 0; i < nconsvars; i++ )
258 {
259 if( inferbounds && SCIPisInfinity(pricingprob, SCIPvarGetUbLocal(consvars[i])) )
260 {
261 ubs[i] = SCIPfloor(pricingprob, ABS((SCIP_Real)prelcapacity/consvals[i]));
262 SCIPdebugMessage(" -> var <%s> %.2f/%"SCIP_LONGINT_FORMAT" = %.2f\n",
263 SCIPvarGetName(consvars[i]), (SCIP_Real)prelcapacity, consvals[i], ubs[i]);
264 }
265 else
266 {
267 ubs[i] = SCIPvarGetUbLocal(consvars[i]);
268 SCIPdebugMessage(" -> var <%s> %.2f\n", SCIPvarGetName(consvars[i]), ubs[i]);
269 }
270
271 }
272 }
273 else if( strcmp(SCIPconshdlrGetName(conshdlr), "knapsack") == 0 )
274 {
275 SCIP_Longint* consweights = SCIPgetWeightsKnapsack(pricingprob, cons);
276
277 SCIPdebugMessage("Use knapsack solver – constraint is already of type 'knapsack'\n");
278
279 consvars = SCIPgetVarsKnapsack(pricingprob, cons);
280 nconsvars = SCIPgetNVarsKnapsack(pricingprob, cons);
281 capacity = SCIPgetCapacityKnapsack(pricingprob, cons);
282
283 SCIP_CALL( SCIPallocBufferArray(pricingprob, &consvals, nconsvars) );
284 SCIP_CALL( SCIPallocBufferArray(pricingprob, &ubs, nconsvars) );
285 BMScopyMemoryArray(consvals, consweights, nconsvars);
286
287 for( i = 0; i < nconsvars; ++i )
288 {
289 assert(consvals[i] >= 0);
290 assert(SCIPisGE(pricingprob, SCIPvarGetLbLocal(consvars[i]), 0.0));
291 assert(SCIPisLE(pricingprob, SCIPvarGetUbLocal(consvars[i]), 1.0));
292
293 ubs[i] = SCIPvarGetUbLocal(consvars[i]);
294 }
295 }
296 else
297 {
298 SCIPdebugMessage(" -> constraint is of unknown type\n");
299 return SCIP_OKAY;
300 }
301
303
304 /* Count number of knapsack items */
305 SCIPdebugMessage("Count number of knapsack items:\n");
306 nitems = 0;
307 for( i = 0; i < nconsvars; i++ )
308 {
309 assert(!SCIPisInfinity(pricingprob, ubs[i]));
310 SCIPdebugMessage(" -> <%s>: %d+%d\n", SCIPvarGetName(consvars[i]), nitems, (int)(ubs[i] - SCIPvarGetLbLocal(consvars[i]) + 0.5));
311 nitems += (int)(ubs[i] - SCIPvarGetLbLocal(consvars[i]) + 0.5);
312 }
313 SCIPdebugMessage("-> %d items\n", nitems);
314
315 SCIP_CALL( SCIPallocBufferArray(pricingprob, solvars, npricingprobvars) );
316 SCIP_CALL( SCIPallocBufferArray(pricingprob, solvals, npricingprobvars) );
317 SCIP_CALL( SCIPallocBufferArray(pricingprob, &items, nitems) );
318 SCIP_CALL( SCIPallocBufferArray(pricingprob, &weights, nitems) );
319 SCIP_CALL( SCIPallocBufferArray(pricingprob, &profits, nitems) );
320 SCIP_CALL( SCIPallocBufferArray(pricingprob, &solitems, nitems) );
321 SCIP_CALL( SCIPallocBufferArray(pricingprob, &nonsolitems, nitems) );
322
323 BMSclearMemoryArray(weights, nitems);
324
325 /* Map variables to knapsack items, and set profits */
326 SCIPdebugMessage("Set knapsack items\n");
327 k = 0;
328 for( i = 0; i < nconsvars; i++ )
329 {
330 assert(!SCIPisInfinity(pricingprob, ubs[i]));
331 for( j = 0; j < (int)(ubs[i] - SCIPvarGetLbLocal(consvars[i]) + 0.5); ++j )
332 {
333 items[k] = i;
334 profits[k] = - SCIPvarGetObj(consvars[i]);
335 SCIPdebugMessage(" -> item %3d: <%s> (index %3d)\n", k, SCIPvarGetName(consvars[i]), i);
336
337 k++;
338 }
339 }
340 assert(k == nitems);
341
342 /* Compute knapsack capacity, and set weights */
343 SCIPdebugMessage("Compute knapsack capacity, current capacity = %"SCIP_LONGINT_FORMAT"\n", capacity);
344 for( i = 0; i < nconsvars; i++ )
345 {
346 if( SCIPisEQ(pricingprob, SCIPvarGetUbLocal(consvars[i]), 0.0) )
347 continue;
348 if( SCIPisGE(pricingprob, SCIPvarGetLbLocal(consvars[i]), 1.0) )
349 {
350 SCIPdebugMessage(" -> variable <%s> has coeff %"SCIP_LONGINT_FORMAT" and lb %f --> increase capacity by %"SCIP_LONGINT_FORMAT"\n",
351 SCIPvarGetName(consvars[i]), consvals[i], SCIPvarGetLbLocal(consvars[i]),
352 (SCIP_Longint)SCIPfloor(pricingprob, SCIPvarGetLbLocal(consvars[i]) * consvals[i]));
353 capacity -= (SCIP_Longint)SCIPfloor(pricingprob, SCIPvarGetLbLocal(consvars[i])) * consvals[i];
354 }
355 }
356
357 SCIPdebugMessage("Compute weights\n");
358
359 for( k = 0; k < nitems; k++ )
360 {
361 i = items[k];
362 if( consvals[i] > 0 )
363 {
364 weights[k] = consvals[i];
365 SCIPdebugMessage(" -> item %3d: weight = %"SCIP_LONGINT_FORMAT"\n", k, weights[k]);
366 }
367 else
368 {
369 capacity -= consvals[i];
370 weights[k] = -consvals[i];
371 profits[k] *= -1.0;
372
373 SCIPdebugMessage(" -> item %3d: weight = %"SCIP_LONGINT_FORMAT" (negated from consval = %"SCIP_LONGINT_FORMAT")\n", k, weights[k], consvals[i]);
374 }
375 }
376
377 SCIPdebugMessage("Knapsack capacity = %"SCIP_LONGINT_FORMAT"\n", capacity);
378
379 success = TRUE;
380
381 /* problem is infeasible */
382 if( capacity < 0 )
383 {
384 SCIPdebugMessage("Pricing problem is infeasible\n");
386 goto TERMINATE;
387 }
388 else if( capacity == 0 )
389 {
390 SCIPdebugMessage("Knapsack has zero capacity\n");
391
392 nsolitems = 0;
393 nnonsolitems = nitems;
394 for( i = 0; i < nitems; ++i )
395 nonsolitems[i] = items[i];
397 }
398 else
399 {
400 SCIPdebugMessage("Solve pricing problem as knapsack\n");
401
402 /* solve knapsack problem, all result pointers are needed! */
403 if( exactly )
404 {
405 SCIP_CALL( SCIPsolveKnapsackExactly(pricingprob, nitems, weights, profits, capacity, items, solitems,
406 nonsolitems, &nsolitems, &nnonsolitems, solval, &success ));
407 }
408 else
409 {
410 SCIP_CALL( SCIPsolveKnapsackApproximately(pricingprob, nitems, weights, profits, capacity, items, solitems,
411 nonsolitems, &nsolitems, &nnonsolitems, solval ));
412 }
413
414 if( !success )
415 {
416 SCIPwarningMessage(pricingprob, "Knapsack solver could not solve pricing problem!");
417 goto TERMINATE;
418 }
419 else if( exactly )
421
422 SCIPdebugMessage("Knapsack solved, solval = %g\n", *solval);
423 }
424
425 *nsolvars = 0;
426
427 for( i = 0; i < nsolitems; i++ )
428 {
429 assert(consvals[solitems[i]] >= 0 || !SCIPvarIsNegated(consvars[solitems[i]]));
430
431 if( consvals[solitems[i]] >= 0 && !SCIPvarIsNegated(consvars[solitems[i]]) )
432 {
433 for( j = 0; j < *nsolvars; ++j )
434 if( (*solvars)[j] == consvars[solitems[i]] )
435 break;
436
437 if( j == *nsolvars )
438 {
439 (*solvars)[j] = consvars[solitems[i]];
440 (*solvals)[j] = 1.0;
441 ++(*nsolvars);
442 }
443 else
444 (*solvals)[j] += 1.0;
445 }
446 }
447
448 for( i = 0; i < nnonsolitems; i++ )
449 {
450 assert(consvals[nonsolitems[i]] >= 0 || !SCIPvarIsNegated(consvars[nonsolitems[i]]));
451
452 if( consvals[nonsolitems[i]] < 0 || SCIPvarIsNegated(consvars[nonsolitems[i]]) )
453 {
454 SCIP_VAR* solvar = SCIPvarIsNegated(consvars[nonsolitems[i]]) ? SCIPvarGetNegatedVar(consvars[nonsolitems[i]]) : consvars[nonsolitems[i]];
455
456 for( j = 0; j < *nsolvars; ++j )
457 if( (*solvars)[j] == solvar )
458 break;
459
460 if( j == *nsolvars )
461 {
462 (*solvars)[j] = solvar;
463 (*solvals)[j] = 1.0;
464 ++(*nsolvars);
465 }
466 else
467 (*solvals)[j] += 1.0;
468 }
469 }
470
471 for( i = 0; i < npricingprobvars; i++ )
472 {
473 if( SCIPisGE(pricingprob, SCIPvarGetLbLocal(pricingprobvars[i]), 1.0) )
474 {
475 for( j = 0; j < *nsolvars; ++j )
476 if( (*solvars)[j] == pricingprobvars[i] )
477 break;
478
479 if( j == *nsolvars )
480 {
481 (*solvars)[j] = pricingprobvars[i];
482 (*solvals)[j] = SCIPfloor(pricingprob, SCIPvarGetLbLocal(pricingprobvars[i]));
483 ++(*nsolvars);
484 }
485 else
486 (*solvals)[j] += SCIPfloor(pricingprob, SCIPvarGetLbLocal(pricingprobvars[i]));
487 }
488 }
489
490 *solval = 0.0;
491
492 for( i = 0; i < *nsolvars; ++i )
493 (*solval) += (*solvals)[i] * SCIPvarGetObj((*solvars)[i]);
494
495 TERMINATE:
496 SCIPfreeBufferArray(pricingprob, &nonsolitems);
497 SCIPfreeBufferArray(pricingprob, &solitems);
498 SCIPfreeBufferArray(pricingprob, &profits);
499 SCIPfreeBufferArray(pricingprob, &weights);
500 SCIPfreeBufferArray(pricingprob, &items);
501 SCIPfreeBufferArray(pricingprob, &ubs);
502 SCIPfreeBufferArray(pricingprob, &consvals);
503
504 return SCIP_OKAY;
505}
506
507
508/*
509 * Callback methods for pricing problem solver
510 */
511
512#define solverFreeKnapsack NULL
513#define solverInitsolKnapsack NULL
514#define solverExitsolKnapsack NULL
515#define solverInitKnapsack NULL
516#define solverExitKnapsack NULL
517#define solverUpdateKnapsack NULL
518
519/** exact solving method for knapsack solver */
520static
521GCG_DECL_SOLVERSOLVE(solverSolveKnapsack)
522{ /*lint --e{715}*/
523
524 /* solve the knapsack problem exactly */
525 SCIP_CALL( solveKnapsack(TRUE, gcg, pricingprob, solver, probnr, lowerbound, status) );
526
527 return SCIP_OKAY;
528}
529
530
531/** heuristic solving method of knapsack solver */
532static
533GCG_DECL_SOLVERSOLVEHEUR(solverSolveHeurKnapsack)
534{ /*lint --e{715}*/
535
536 /* solve the knapsack problem approximately */
537 SCIP_CALL( solveKnapsack(FALSE, gcg, pricingprob, solver, probnr, lowerbound, status) );
538
539 return SCIP_OKAY;
540}
541
542
543/** creates the knapsack solver for pricing problems and includes it in GCG */
545 GCG* gcg /**< GCG data structure */
546 )
547{
550 solverUpdateKnapsack, solverSolveKnapsack, solverSolveHeurKnapsack,
553
554 return SCIP_OKAY;
555}
#define GCG_EXPORT
Definition: def.h:59
#define SCIP_Longint
#define SCIP_Bool
#define SCIP_Real
#define ABS(x)
#define SCIP_LONGINT_FORMAT
#define SCIP_CALL(x)
#define TRUE
#define FALSE
int SCIPgetNVarsKnapsack(SCIP *scip, SCIP_CONS *cons)
SCIP_Real SCIPgetRhsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_VAR ** SCIPgetVarsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPsolveKnapsackApproximately(SCIP *scip, int nitems, SCIP_Longint *weights, SCIP_Real *profits, SCIP_Longint capacity, int *items, int *solitems, int *nonsolitems, int *nsolitems, int *nnonsolitems, SCIP_Real *solval)
SCIP_Real SCIPgetLhsLinear(SCIP *scip, SCIP_CONS *cons)
int SCIPgetNVarsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_Real * SCIPgetValsLinear(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPsolveKnapsackExactly(SCIP *scip, int nitems, SCIP_Longint *weights, SCIP_Real *profits, SCIP_Longint capacity, int *items, int *solitems, int *nonsolitems, int *nsolitems, int *nnonsolitems, SCIP_Real *solval, SCIP_Bool *success)
SCIP_Longint * SCIPgetWeightsKnapsack(SCIP *scip, SCIP_CONS *cons)
SCIP_Longint SCIPgetCapacityKnapsack(SCIP *scip, SCIP_CONS *cons)
SCIP_VAR ** SCIPgetVarsKnapsack(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE GCGpricerAddCol(GCG *gcg, GCG_COL *col)
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
int SCIPgetNIntVars(SCIP *scip)
SCIP_CONS ** SCIPgetConss(SCIP *scip)
int SCIPgetNVars(SCIP *scip)
int SCIPgetNConss(SCIP *scip)
SCIP_VAR ** SCIPgetVars(SCIP *scip)
SCIP_OBJSENSE SCIPgetObjsense(SCIP *scip)
int SCIPgetNBinVars(SCIP *scip)
void SCIPwarningMessage(SCIP *scip, const char *formatstr,...)
const char * SCIPconshdlrGetName(SCIP_CONSHDLR *conshdlr)
SCIP_CONSHDLR * SCIPconsGetHdlr(SCIP_CONS *cons)
#define SCIPallocBufferArray(scip, ptr, num)
#define SCIPfreeBufferArray(scip, ptr)
SCIP_Real SCIPinfinity(SCIP *scip)
SCIP_Bool SCIPisGE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Bool SCIPisIntegral(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisLE(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_Real SCIPfloor(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisInfinity(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisNegative(SCIP *scip, SCIP_Real val)
SCIP_Bool SCIPisEQ(SCIP *scip, SCIP_Real val1, SCIP_Real val2)
SCIP_VAR * SCIPvarGetNegatedVar(SCIP_VAR *var)
SCIP_Real SCIPvarGetUbLocal(SCIP_VAR *var)
SCIP_Real SCIPvarGetObj(SCIP_VAR *var)
const char * SCIPvarGetName(SCIP_VAR *var)
SCIP_Real SCIPvarGetLbLocal(SCIP_VAR *var)
SCIP_Bool SCIPvarIsNegated(SCIP_VAR *var)
#define NULL
#define BMScopyMemoryArray(ptr, source, num)
#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 SCIPdebugMessage
GCG relaxator.
GCG_EXPORT SCIP_RETCODE GCGsolverKnapsackSolveKnapsack(SCIP_Bool exactly, SCIP *pricingprob, SCIP_Real *solval, GCG_PRICINGSTATUS *status, SCIP_VAR ***solvars, SCIP_Real **solvals, int *nsolvars)
static GCG_DECL_SOLVERSOLVE(solverSolveKnapsack)
static GCG_DECL_SOLVERSOLVEHEUR(solverSolveHeurKnapsack)
#define solverInitsolKnapsack
#define SOLVER_HEURENABLED
#define solverExitsolKnapsack
#define SOLVER_EXACTENABLED
static SCIP_RETCODE solveKnapsack(SCIP_Bool exactly, GCG *gcg, SCIP *pricingprob, GCG_SOLVER *solver, int probnr, SCIP_Real *lowerbound, GCG_PRICINGSTATUS *status)
#define solverInitKnapsack
#define SOLVER_NAME
#define SOLVER_DESC
#define solverUpdateKnapsack
#define solverExitKnapsack
SCIP_RETCODE GCGincludeSolverKnapsack(GCG *gcg)
#define solverFreeKnapsack
#define SOLVER_PRIORITY
knapsack solver for pricing problems
Definition: struct_gcg.h:55
enum GCG_PricingStatus GCG_PRICINGSTATUS
@ GCG_PRICINGSTATUS_OPTIMAL
@ GCG_PRICINGSTATUS_NOTAPPLICABLE
@ GCG_PRICINGSTATUS_INFEASIBLE
@ GCG_PRICINGSTATUS_UNKNOWN
SCIP_OBJSENSE_MINIMIZE
SCIP_OKAY
enum SCIP_Retcode SCIP_RETCODE