Scippy

SCIP

Solving Constraint Integer Programs

pricer.c
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program and library */
4 /* SCIP --- Solving Constraint Integer Programs */
5 /* */
6 /* Copyright 2002-2022 Zuse Institute Berlin */
7 /* */
8 /* Licensed under the Apache License, Version 2.0 (the "License"); */
9 /* you may not use this file except in compliance with the License. */
10 /* You may obtain a copy of the License at */
11 /* */
12 /* http://www.apache.org/licenses/LICENSE-2.0 */
13 /* */
14 /* Unless required by applicable law or agreed to in writing, software */
15 /* distributed under the License is distributed on an "AS IS" BASIS, */
16 /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
17 /* See the License for the specific language governing permissions and */
18 /* limitations under the License. */
19 /* */
20 /* You should have received a copy of the Apache-2.0 license */
21 /* along with SCIP; see the file LICENSE. If not visit scipopt.org. */
22 /* */
23 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24 
25 /**@file pricer.c
26  * @ingroup OTHER_CFILES
27  * @brief methods for variable pricers
28  * @author Tobias Achterberg
29  * @author Timo Berthold
30  */
31 
32 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
33 
34 #include <assert.h>
35 #include <string.h>
36 
37 #include "scip/def.h"
38 #include "scip/set.h"
39 #include "scip/clock.h"
40 #include "scip/paramset.h"
41 #include "scip/lp.h"
42 #include "scip/prob.h"
43 #include "scip/pricestore.h"
44 #include "scip/scip.h"
45 #include "scip/pricer.h"
46 #include "scip/pub_message.h"
47 #include "scip/pub_misc.h"
48 
49 #include "scip/struct_pricer.h"
50 
51 
52 
53 /** compares two pricers w. r. to their activity and their priority */
54 SCIP_DECL_SORTPTRCOMP(SCIPpricerComp)
55 { /*lint --e{715}*/
56  if( ((SCIP_PRICER*)elem1)->active != ((SCIP_PRICER*)elem2)->active )
57  return ((SCIP_PRICER*)elem1)->active ? -1 : +1;
58  else
59  return ((SCIP_PRICER*)elem2)->priority - ((SCIP_PRICER*)elem1)->priority;
60 }
61 
62 /** comparison method for sorting pricers w.r.t. to their name */
63 SCIP_DECL_SORTPTRCOMP(SCIPpricerCompName)
64 {
65  if( ((SCIP_PRICER*)elem1)->active != ((SCIP_PRICER*)elem2)->active )
66  return ((SCIP_PRICER*)elem1)->active ? -1 : +1;
67  else
68  return strcmp(SCIPpricerGetName((SCIP_PRICER*)elem1), SCIPpricerGetName((SCIP_PRICER*)elem2));
69 }
70 
71 /** method to call, when the priority of a pricer was changed */
72 static
73 SCIP_DECL_PARAMCHGD(paramChgdPricerPriority)
74 { /*lint --e{715}*/
75  SCIP_PARAMDATA* paramdata;
76 
77  paramdata = SCIPparamGetData(param);
78  assert(paramdata != NULL);
79 
80  /* use SCIPsetPricerPriority() to mark the pricers unsorted */
81  SCIP_CALL( SCIPsetPricerPriority(scip, (SCIP_PRICER*)paramdata, SCIPparamGetInt(param)) ); /*lint !e740*/
82 
83  return SCIP_OKAY;
84 }
85 
86 /** copies the given pricer to a new scip */
88  SCIP_PRICER* pricer, /**< pricer */
89  SCIP_SET* set, /**< SCIP_SET of SCIP to copy to */
90  SCIP_Bool* valid /**< was the copying process valid? */
91  )
92 {
93  assert(pricer != NULL);
94  assert(set != NULL);
95  assert(valid != NULL);
96  assert(set->scip != NULL);
97 
98  if( pricer->pricercopy != NULL )
99  {
100  SCIPsetDebugMsg(set, "including pricer %s in subscip %p\n", SCIPpricerGetName(pricer), (void*)set->scip);
101  SCIP_CALL( pricer->pricercopy(set->scip, pricer, valid) );
102  }
103  return SCIP_OKAY;
104 }
105 
106 /** internal method creating a variable pricer */
107 static
109  SCIP_PRICER** pricer, /**< pointer to variable pricer data structure */
110  SCIP_SET* set, /**< global SCIP settings */
111  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
112  BMS_BLKMEM* blkmem, /**< block memory for parameter settings */
113  const char* name, /**< name of variable pricer */
114  const char* desc, /**< description of variable pricer */
115  int priority, /**< priority of the variable pricer */
116  SCIP_Bool delay, /**< should the pricer be delayed until no other pricers or already existing
117  * problem variables with negative reduced costs are found */
118  SCIP_DECL_PRICERCOPY ((*pricercopy)), /**< copy method of pricer or NULL if you don't want to copy your plugin into sub-SCIPs */
119  SCIP_DECL_PRICERFREE ((*pricerfree)), /**< destructor of variable pricer */
120  SCIP_DECL_PRICERINIT ((*pricerinit)), /**< initialize variable pricer */
121  SCIP_DECL_PRICEREXIT ((*pricerexit)), /**< deinitialize variable pricer */
122  SCIP_DECL_PRICERINITSOL((*pricerinitsol)),/**< solving process initialization method of variable pricer */
123  SCIP_DECL_PRICEREXITSOL((*pricerexitsol)),/**< solving process deinitialization method of variable pricer */
124  SCIP_DECL_PRICERREDCOST((*pricerredcost)),/**< reduced cost pricing method of variable pricer for feasible LPs */
125  SCIP_DECL_PRICERFARKAS((*pricerfarkas)), /**< Farkas pricing method of variable pricer for infeasible LPs */
126  SCIP_PRICERDATA* pricerdata /**< variable pricer data */
127  )
128 {
130  char paramdesc[SCIP_MAXSTRLEN];
131 
132  assert(pricer != NULL);
133  assert(name != NULL);
134  assert(desc != NULL);
135  assert(pricerredcost != NULL);
136 
137  SCIP_ALLOC( BMSallocMemory(pricer) );
138  BMSclearMemory(*pricer);
139 
140  SCIP_ALLOC( BMSduplicateMemoryArray(&(*pricer)->name, name, strlen(name)+1) );
141  SCIP_ALLOC( BMSduplicateMemoryArray(&(*pricer)->desc, desc, strlen(desc)+1) );
142  (*pricer)->priority = priority;
143  (*pricer)->pricercopy = pricercopy;
144  (*pricer)->pricerfree = pricerfree;
145  (*pricer)->pricerinit = pricerinit;
146  (*pricer)->pricerexit = pricerexit;
147  (*pricer)->pricerinitsol = pricerinitsol;
148  (*pricer)->pricerexitsol = pricerexitsol;
149  (*pricer)->pricerredcost = pricerredcost;
150  (*pricer)->pricerfarkas = pricerfarkas;
151  (*pricer)->pricerdata = pricerdata;
152  SCIP_CALL( SCIPclockCreate(&(*pricer)->setuptime, SCIP_CLOCKTYPE_DEFAULT) );
153  SCIP_CALL( SCIPclockCreate(&(*pricer)->pricerclock, SCIP_CLOCKTYPE_DEFAULT) );
154  (*pricer)->ncalls = 0;
155  (*pricer)->nvarsfound = 0;
156  (*pricer)->delay = delay;
157  (*pricer)->active = FALSE;
158  (*pricer)->initialized = FALSE;
159 
160  /* add parameters */
161  (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "pricers/%s/priority", name);
162  (void) SCIPsnprintf(paramdesc, SCIP_MAXSTRLEN, "priority of pricer <%s>", name);
163  SCIP_CALL( SCIPsetAddIntParam(set, messagehdlr, blkmem, paramname, paramdesc,
164  &(*pricer)->priority, FALSE, priority, INT_MIN/4, INT_MAX/4,
165  paramChgdPricerPriority, (SCIP_PARAMDATA*)(*pricer)) ); /*lint !e740*/
166 
167  return SCIP_OKAY;
168 }
169 
170 /** creates a variable pricer
171  * To use the variable pricer for solving a problem, it first has to be activated with a call to SCIPactivatePricer().
172  */
174  SCIP_PRICER** pricer, /**< pointer to variable pricer data structure */
175  SCIP_SET* set, /**< global SCIP settings */
176  SCIP_MESSAGEHDLR* messagehdlr, /**< message handler */
177  BMS_BLKMEM* blkmem, /**< block memory for parameter settings */
178  const char* name, /**< name of variable pricer */
179  const char* desc, /**< description of variable pricer */
180  int priority, /**< priority of the variable pricer */
181  SCIP_Bool delay, /**< should the pricer be delayed until no other pricers or already existing
182  * problem variables with negative reduced costs are found */
183  SCIP_DECL_PRICERCOPY ((*pricercopy)), /**< copy method of pricer or NULL if you don't want to copy your plugin into sub-SCIPs */
184  SCIP_DECL_PRICERFREE ((*pricerfree)), /**< destructor of variable pricer */
185  SCIP_DECL_PRICERINIT ((*pricerinit)), /**< initialize variable pricer */
186  SCIP_DECL_PRICEREXIT ((*pricerexit)), /**< deinitialize variable pricer */
187  SCIP_DECL_PRICERINITSOL((*pricerinitsol)),/**< solving process initialization method of variable pricer */
188  SCIP_DECL_PRICEREXITSOL((*pricerexitsol)),/**< solving process deinitialization method of variable pricer */
189  SCIP_DECL_PRICERREDCOST((*pricerredcost)),/**< reduced cost pricing method of variable pricer for feasible LPs */
190  SCIP_DECL_PRICERFARKAS((*pricerfarkas)), /**< Farkas pricing method of variable pricer for infeasible LPs */
191  SCIP_PRICERDATA* pricerdata /**< variable pricer data */
192  )
193 {
194  assert(pricer != NULL);
195  assert(name != NULL);
196  assert(desc != NULL);
197  assert(pricerredcost != NULL);
198 
199  SCIP_CALL_FINALLY( doPricerCreate(pricer, set, messagehdlr, blkmem, name, desc, priority, delay, pricercopy,
200  pricerfree, pricerinit, pricerexit, pricerinitsol, pricerexitsol, pricerredcost, pricerfarkas, pricerdata),
201  (void) SCIPpricerFree(pricer ,set) );
202 
203  return SCIP_OKAY;
204 }
205 
206 /** calls destructor and frees memory of variable pricer */
208  SCIP_PRICER** pricer, /**< pointer to variable pricer data structure */
209  SCIP_SET* set /**< global SCIP settings */
210  )
211 {
212  assert(pricer != NULL);
213  if( *pricer == NULL )
214  return SCIP_OKAY;
215  assert(!(*pricer)->initialized);
216  assert(set != NULL);
217 
218  /* call destructor of variable pricer */
219  if( (*pricer)->pricerfree != NULL )
220  {
221  SCIP_CALL( (*pricer)->pricerfree(set->scip, *pricer) );
222  }
223 
224  SCIPclockFree(&(*pricer)->pricerclock);
225  SCIPclockFree(&(*pricer)->setuptime);
226  BMSfreeMemoryArrayNull(&(*pricer)->name);
227  BMSfreeMemoryArrayNull(&(*pricer)->desc);
228  BMSfreeMemory(pricer);
229 
230  return SCIP_OKAY;
231 }
232 
233 /** initializes variable pricer */
235  SCIP_PRICER* pricer, /**< variable pricer */
236  SCIP_SET* set /**< global SCIP settings */
237  )
238 {
239  assert(pricer != NULL);
240  assert(pricer->active);
241  assert(set != NULL);
242 
243  if( pricer->initialized )
244  {
245  SCIPerrorMessage("variable pricer <%s> already initialized\n", pricer->name);
246  return SCIP_INVALIDCALL;
247  }
248 
249  if( set->misc_resetstat )
250  {
251  SCIPclockReset(pricer->setuptime);
252  SCIPclockReset(pricer->pricerclock);
253 
254  pricer->ncalls = 0;
255  pricer->nvarsfound = 0;
256  }
257 
258  if( pricer->pricerinit != NULL )
259  {
260  /* start timing */
261  SCIPclockStart(pricer->setuptime, set);
262 
263  SCIP_CALL( pricer->pricerinit(set->scip, pricer) );
264 
265  /* stop timing */
266  SCIPclockStop(pricer->setuptime, set);
267  }
268  pricer->initialized = TRUE;
269 
270  return SCIP_OKAY;
271 }
272 
273 /** calls exit method of variable pricer */
275  SCIP_PRICER* pricer, /**< variable pricer */
276  SCIP_SET* set /**< global SCIP settings */
277  )
278 {
279  assert(pricer != NULL);
280  assert(pricer->active);
281  assert(set != NULL);
282 
283  if( !pricer->initialized )
284  {
285  SCIPerrorMessage("variable pricer <%s> not initialized\n", pricer->name);
286  return SCIP_INVALIDCALL;
287  }
288 
289  if( pricer->pricerexit != NULL )
290  {
291  /* start timing */
292  SCIPclockStart(pricer->setuptime, set);
293 
294  SCIP_CALL( pricer->pricerexit(set->scip, pricer) );
295 
296  /* stop timing */
297  SCIPclockStop(pricer->setuptime, set);
298  }
299  pricer->initialized = FALSE;
300 
301  return SCIP_OKAY;
302 }
303 
304 /** informs variable pricer that the branch and bound process is being started */
306  SCIP_PRICER* pricer, /**< variable pricer */
307  SCIP_SET* set /**< global SCIP settings */
308  )
309 {
310  assert(pricer != NULL);
311  assert(set != NULL);
312 
313  /* call solving process initialization method of variable pricer */
314  if( pricer->pricerinitsol != NULL )
315  {
316  /* start timing */
317  SCIPclockStart(pricer->setuptime, set);
318 
319  SCIP_CALL( pricer->pricerinitsol(set->scip, pricer) );
320 
321  /* stop timing */
322  SCIPclockStop(pricer->setuptime, set);
323  }
324 
325  return SCIP_OKAY;
326 }
327 
328 /** informs variable pricer that the branch and bound process data is being freed */
330  SCIP_PRICER* pricer, /**< variable pricer */
331  SCIP_SET* set /**< global SCIP settings */
332  )
333 {
334  assert(pricer != NULL);
335  assert(set != NULL);
336 
337  /* call solving process deinitialization method of variable pricer */
338  if( pricer->pricerexitsol != NULL )
339  {
340  /* start timing */
341  SCIPclockStart(pricer->setuptime, set);
342 
343  SCIP_CALL( pricer->pricerexitsol(set->scip, pricer) );
344 
345  /* stop timing */
346  SCIPclockStop(pricer->setuptime, set);
347  }
348 
349  return SCIP_OKAY;
350 }
351 
352 /** activates pricer such that it is called in LP solving loop */
354  SCIP_PRICER* pricer, /**< variable pricer */
355  SCIP_SET* set /**< global SCIP settings */
356  )
357 {
358  assert(pricer != NULL);
359  assert(set != NULL);
360  assert(set->stage == SCIP_STAGE_PROBLEM);
361 
362  if( !pricer->active )
363  {
364  pricer->active = TRUE;
365  set->nactivepricers++;
366  set->pricerssorted = FALSE;
367  }
368 
369  return SCIP_OKAY;
370 }
371 
372 /** deactivates pricer such that it is no longer called in LP solving loop */
374  SCIP_PRICER* pricer, /**< variable pricer */
375  SCIP_SET* set /**< global SCIP settings */
376  )
377 {
378  assert(pricer != NULL);
379  assert(set != NULL);
380 
381  if( pricer->active )
382  {
383  pricer->active = FALSE;
384  set->nactivepricers--;
385  set->pricerssorted = FALSE;
386  }
387 
388  return SCIP_OKAY;
389 }
390 
391 /** calls reduced cost pricing method of variable pricer */
393  SCIP_PRICER* pricer, /**< variable pricer */
394  SCIP_SET* set, /**< global SCIP settings */
395  SCIP_PROB* prob, /**< transformed problem */
396  SCIP_Real* lowerbound, /**< local lower bound computed by the pricer */
397  SCIP_Bool* stopearly, /**< should pricing be stopped, although new variables were added? */
398  SCIP_RESULT* result /**< result of the pricing process */
399  )
400 {
401  int oldnvars;
402 
403  assert(pricer != NULL);
404  assert(pricer->active);
405  assert(pricer->pricerredcost != NULL);
406  assert(set != NULL);
407  assert(prob != NULL);
408  assert(lowerbound != NULL);
409  assert(result != NULL);
410 
411  SCIPsetDebugMsg(set, "executing reduced cost pricing of variable pricer <%s>\n", pricer->name);
412 
413  oldnvars = prob->nvars;
414 
415  /* start timing */
416  SCIPclockStart(pricer->pricerclock, set);
417 
418  /* call external method */
419  SCIP_CALL( pricer->pricerredcost(set->scip, pricer, lowerbound, stopearly, result) );
420 
421  /* stop timing */
422  SCIPclockStop(pricer->pricerclock, set);
423 
424  /* evaluate result */
425  pricer->ncalls++;
426  pricer->nvarsfound += prob->nvars - oldnvars;
427 
428  return SCIP_OKAY;
429 }
430 
431 /** calls Farkas pricing method of variable pricer */
433  SCIP_PRICER* pricer, /**< variable pricer */
434  SCIP_SET* set, /**< global SCIP settings */
435  SCIP_PROB* prob, /**< transformed problem */
436  SCIP_RESULT* result /**< result of the pricing process */
437  )
438 {
439  int oldnvars;
440 
441  assert(pricer != NULL);
442  assert(pricer->active);
443  assert(set != NULL);
444  assert(prob != NULL);
445 
446  /* check, if pricer implemented a Farkas pricing algorithm */
447  if( pricer->pricerfarkas == NULL )
448  return SCIP_OKAY;
449 
450  SCIPsetDebugMsg(set, "executing Farkas pricing of variable pricer <%s>\n", pricer->name);
451 
452  oldnvars = prob->nvars;
453 
454  /* start timing */
455  SCIPclockStart(pricer->pricerclock, set);
456 
457  /* call external method */
458  SCIP_CALL( pricer->pricerfarkas(set->scip, pricer, result) );
459 
460  /* stop timing */
461  SCIPclockStop(pricer->pricerclock, set);
462 
463  /* evaluate result */
464  pricer->ncalls++;
465  pricer->nvarsfound += prob->nvars - oldnvars;
466 
467  return SCIP_OKAY;
468 }
469 
470 /** depending on the LP's solution status, calls reduced cost or Farkas pricing method of variable pricer */
472  SCIP_PRICER* pricer, /**< variable pricer */
473  SCIP_SET* set, /**< global SCIP settings */
474  SCIP_PROB* prob, /**< transformed problem */
475  SCIP_LP* lp, /**< LP data */
476  SCIP_PRICESTORE* pricestore, /**< pricing storage */
477  SCIP_Real* lowerbound, /**< local lower bound computed by the pricer */
478  SCIP_Bool* stopearly, /**< should pricing be stopped, although new variables were added? */
479  SCIP_RESULT* result /**< result of the pricing process */
480  )
481 {
482  assert(pricer != NULL);
483  assert(lowerbound != NULL);
484  assert(stopearly != NULL);
485  assert(result != NULL);
486 
487  /* set lowerbound, stopearly, and result pointer */
488  *lowerbound = - SCIPsetInfinity(set);
489  *stopearly = FALSE;
490  *result = SCIP_SUCCESS;
491 
492  /* check if pricer should be delayed */
493  if( pricer->delay && SCIPpricestoreGetNVars(pricestore) > 0 )
494  return SCIP_OKAY;
495 
497  {
498  SCIP_CALL( SCIPpricerFarkas(pricer, set, prob, result) );
499  }
500  else
501  {
502  *result = SCIP_DIDNOTRUN;
503  SCIP_CALL( SCIPpricerRedcost(pricer, set, prob, lowerbound, stopearly, result) );
504  }
505 
506  return SCIP_OKAY;
507 }
508 
509 /** gets user data of variable pricer */
511  SCIP_PRICER* pricer /**< variable pricer */
512  )
513 {
514  assert(pricer != NULL);
515 
516  return pricer->pricerdata;
517 }
518 
519 /** sets user data of variable pricer; user has to free old data in advance! */
521  SCIP_PRICER* pricer, /**< variable pricer */
522  SCIP_PRICERDATA* pricerdata /**< new variable pricer user data */
523  )
524 {
525  assert(pricer != NULL);
526 
527  pricer->pricerdata = pricerdata;
528 }
529 
530 /** sets copy callback of pricer */
532  SCIP_PRICER* pricer, /**< variable pricer */
533  SCIP_DECL_PRICERCOPY ((*pricercopy)) /**< copy callback of pricer */
534  )
535 {
536  assert(pricer != NULL);
537 
538  pricer->pricercopy = pricercopy;
539 }
540 
541 /** sets destructor callback of pricer */
543  SCIP_PRICER* pricer, /**< pricer */
544  SCIP_DECL_PRICERFREE ((*pricerfree)) /**< destructor of pricer */
545  )
546 {
547  assert(pricer != NULL);
548 
549  pricer->pricerfree = pricerfree;
550 }
551 
552 /** sets initialization callback of pricer */
554  SCIP_PRICER* pricer, /**< pricer */
555  SCIP_DECL_PRICERINIT ((*pricerinit)) /**< initialize pricer */
556  )
557 {
558  assert(pricer != NULL);
559 
560  pricer->pricerinit = pricerinit;
561 }
562 
563 /** sets deinitialization callback of pricer */
565  SCIP_PRICER* pricer, /**< pricer */
566  SCIP_DECL_PRICEREXIT ((*pricerexit)) /**< deinitialize pricer */
567  )
568 {
569  assert(pricer != NULL);
570 
571  pricer->pricerexit = pricerexit;
572 }
573 
574 /** sets solving process initialization callback of pricer */
576  SCIP_PRICER* pricer, /**< pricer */
577  SCIP_DECL_PRICERINITSOL ((*pricerinitsol))/**< solving process initialization callback of pricer */
578  )
579 {
580  assert(pricer != NULL);
581 
582  pricer->pricerinitsol = pricerinitsol;
583 }
584 
585 /** sets solving process deinitialization callback of pricer */
587  SCIP_PRICER* pricer, /**< pricer */
588  SCIP_DECL_PRICEREXITSOL ((*pricerexitsol))/**< solving process deinitialization callback of pricer */
589  )
590 {
591  assert(pricer != NULL);
592 
593  pricer->pricerexitsol = pricerexitsol;
594 }
595 
596 /** gets name of variable pricer */
597 const char* SCIPpricerGetName(
598  SCIP_PRICER* pricer /**< variable pricer */
599  )
600 {
601  assert(pricer != NULL);
602 
603  return pricer->name;
604 }
605 
606 /** gets description of variable pricer */
607 const char* SCIPpricerGetDesc(
608  SCIP_PRICER* pricer /**< variable pricer */
609  )
610 {
611  assert(pricer != NULL);
612 
613  return pricer->desc;
614 }
615 
616 /** gets priority of variable pricer */
618  SCIP_PRICER* pricer /**< variable pricer */
619  )
620 {
621  assert(pricer != NULL);
622 
623  return pricer->priority;
624 }
625 
626 /** sets priority of variable pricer */
628  SCIP_PRICER* pricer, /**< variable pricer */
629  SCIP_SET* set, /**< global SCIP settings */
630  int priority /**< new priority of the variable pricer */
631  )
632 {
633  assert(pricer != NULL);
634  assert(set != NULL);
635 
636  pricer->priority = priority;
637  set->pricerssorted = FALSE;
638 }
639 
640 /** gets the number of times, the pricer was called and tried to find a variable with negative reduced costs */
642  SCIP_PRICER* pricer /**< variable pricer */
643  )
644 {
645  assert(pricer != NULL);
646 
647  return pricer->ncalls;
648 }
649 
650 /** gets the number of variables with negative reduced costs found by this pricer */
652  SCIP_PRICER* pricer /**< variable pricer */
653  )
654 {
655  assert(pricer != NULL);
656 
657  return pricer->nvarsfound;
658 }
659 
660 /** gets time in seconds used in this pricer for setting up for next stages */
662  SCIP_PRICER* pricer /**< variable pricer */
663  )
664 {
665  assert(pricer != NULL);
666 
667  return SCIPclockGetTime(pricer->setuptime);
668 }
669 
670 /** gets time in seconds used in this pricer */
672  SCIP_PRICER* pricer /**< variable pricer */
673  )
674 {
675  assert(pricer != NULL);
676 
677  return SCIPclockGetTime(pricer->pricerclock);
678 }
679 
680 /** enables or disables all clocks of \p pricer, depending on the value of the flag */
682  SCIP_PRICER* pricer, /**< the pricer for which all clocks should be enabled or disabled */
683  SCIP_Bool enable /**< should the clocks of the pricer be enabled? */
684  )
685 {
686  assert(pricer != NULL);
687 
688  SCIPclockEnableOrDisable(pricer->setuptime, enable);
689  SCIPclockEnableOrDisable(pricer->pricerclock, enable);
690 }
691 
692 /** returns whether the given pricer is in use in the current problem */
694  SCIP_PRICER* pricer /**< variable pricer */
695  )
696 {
697  assert(pricer != NULL);
698 
699  return pricer->active;
700 }
701 
702 /** returns whether the pricer should be delayed until no other pricer finds a new variable */
704  SCIP_PRICER* pricer /**< variable pricer */
705  )
706 {
707  assert(pricer != NULL);
708 
709  return pricer->delay;
710 }
711 
712 /** is variable pricer initialized? */
714  SCIP_PRICER* pricer /**< variable pricer */
715  )
716 {
717  assert(pricer != NULL);
718 
719  return pricer->initialized;
720 }
721 
722 
enum SCIP_Result SCIP_RESULT
Definition: type_result.h:61
void SCIPpricerEnableOrDisableClocks(SCIP_PRICER *pricer, SCIP_Bool enable)
Definition: pricer.c:681
SCIP_RETCODE SCIPsetPricerPriority(SCIP *scip, SCIP_PRICER *pricer, int priority)
Definition: scip_pricer.c:359
SCIP_RETCODE SCIPpricerInit(SCIP_PRICER *pricer, SCIP_SET *set)
Definition: pricer.c:234
SCIP_RETCODE SCIPpricerDeactivate(SCIP_PRICER *pricer, SCIP_SET *set)
Definition: pricer.c:373
void SCIPpricerSetInit(SCIP_PRICER *pricer, SCIP_DECL_PRICERINIT((*pricerinit)))
Definition: pricer.c:553
void SCIPpricerSetData(SCIP_PRICER *pricer, SCIP_PRICERDATA *pricerdata)
Definition: pricer.c:520
void SCIPpricerSetExitsol(SCIP_PRICER *pricer, SCIP_DECL_PRICEREXITSOL((*pricerexitsol)))
Definition: pricer.c:586
const char * SCIPpricerGetName(SCIP_PRICER *pricer)
Definition: pricer.c:597
#define BMSfreeMemoryArrayNull(ptr)
Definition: memory.h:150
int SCIPpricestoreGetNVars(SCIP_PRICESTORE *pricestore)
Definition: pricestore.c:609
SCIP_PARAMDATA * SCIPparamGetData(SCIP_PARAM *param)
Definition: paramset.c:679
#define SCIP_MAXSTRLEN
Definition: def.h:302
internal methods for clocks and timing issues
struct SCIP_ParamData SCIP_PARAMDATA
Definition: type_paramset.h:87
static SCIP_DECL_PARAMCHGD(paramChgdPricerPriority)
Definition: pricer.c:73
#define SCIP_CALL_FINALLY(x, y)
Definition: def.h:435
SCIP_Real SCIPpricerGetTime(SCIP_PRICER *pricer)
Definition: pricer.c:671
SCIP_Real SCIPsetInfinity(SCIP_SET *set)
Definition: set.c:6080
#define SCIP_DECL_PRICEREXIT(x)
Definition: type_pricer.h:79
SCIP_Bool SCIPpricerIsActive(SCIP_PRICER *pricer)
Definition: pricer.c:693
void SCIPclockStop(SCIP_CLOCK *clck, SCIP_SET *set)
Definition: clock.c:360
#define FALSE
Definition: def.h:96
SCIP_RETCODE SCIPpricerInitsol(SCIP_PRICER *pricer, SCIP_SET *set)
Definition: pricer.c:305
void SCIPclockStart(SCIP_CLOCK *clck, SCIP_SET *set)
Definition: clock.c:290
int SCIPsnprintf(char *t, int len, const char *s,...)
Definition: misc.c:10764
#define TRUE
Definition: def.h:95
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:63
SCIP_RETCODE SCIPpricerRedcost(SCIP_PRICER *pricer, SCIP_SET *set, SCIP_PROB *prob, SCIP_Real *lowerbound, SCIP_Bool *stopearly, SCIP_RESULT *result)
Definition: pricer.c:392
void SCIPpricerSetFree(SCIP_PRICER *pricer, SCIP_DECL_PRICERFREE((*pricerfree)))
Definition: pricer.c:542
SCIP_PRICERDATA * SCIPpricerGetData(SCIP_PRICER *pricer)
Definition: pricer.c:510
static GRAPHNODE ** active
#define SCIP_DECL_PRICEREXITSOL(x)
Definition: type_pricer.h:101
internal methods for handling parameter settings
void SCIPclockEnableOrDisable(SCIP_CLOCK *clck, SCIP_Bool enable)
Definition: clock.c:260
#define BMSfreeMemory(ptr)
Definition: memory.h:147
#define SCIP_DECL_PRICERCOPY(x)
Definition: type_pricer.h:55
SCIP_Bool delay
Definition: struct_pricer.h:64
SCIP_RETCODE SCIPpricerCopyInclude(SCIP_PRICER *pricer, SCIP_SET *set, SCIP_Bool *valid)
Definition: pricer.c:87
SCIP_LPSOLSTAT SCIPlpGetSolstat(SCIP_LP *lp)
Definition: lp.c:13106
internal methods for LP management
Definition: heur_padm.c:132
void SCIPpricerSetPriority(SCIP_PRICER *pricer, SCIP_SET *set, int priority)
Definition: pricer.c:627
SCIP_RETCODE SCIPpricerExit(SCIP_PRICER *pricer, SCIP_SET *set)
Definition: pricer.c:274
int SCIPpricerGetPriority(SCIP_PRICER *pricer)
Definition: pricer.c:617
void SCIPpricerSetCopy(SCIP_PRICER *pricer, SCIP_DECL_PRICERCOPY((*pricercopy)))
Definition: pricer.c:531
internal methods for storing and manipulating the main problem
#define SCIPerrorMessage
Definition: pub_message.h:64
void SCIPclockReset(SCIP_CLOCK *clck)
Definition: clock.c:209
SCIP_CLOCK * setuptime
Definition: struct_pricer.h:59
SCIP_RETCODE SCIPpricerFree(SCIP_PRICER **pricer, SCIP_SET *set)
Definition: pricer.c:207
SCIP_Real SCIPclockGetTime(SCIP_CLOCK *clck)
Definition: clock.c:438
SCIP_DECL_SORTPTRCOMP(SCIPpricerComp)
Definition: pricer.c:54
static SCIP_RETCODE doPricerCreate(SCIP_PRICER **pricer, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, BMS_BLKMEM *blkmem, const char *name, const char *desc, int priority, SCIP_Bool delay, SCIP_DECL_PRICERCOPY((*pricercopy)), SCIP_DECL_PRICERFREE((*pricerfree)), SCIP_DECL_PRICERINIT((*pricerinit)), SCIP_DECL_PRICEREXIT((*pricerexit)), SCIP_DECL_PRICERINITSOL((*pricerinitsol)), SCIP_DECL_PRICEREXITSOL((*pricerexitsol)), SCIP_DECL_PRICERREDCOST((*pricerredcost)), SCIP_DECL_PRICERFARKAS((*pricerfarkas)), SCIP_PRICERDATA *pricerdata)
Definition: pricer.c:108
#define NULL
Definition: lpi_spx1.cpp:164
SCIP_DECL_PRICERINIT(ObjPricerVRP::scip_init)
Definition: pricer_vrp.cpp:83
internal methods for variable pricers
internal methods for global SCIP settings
#define SCIP_CALL(x)
Definition: def.h:393
SCIP_CLOCK * pricerclock
Definition: struct_pricer.h:60
internal methods for storing priced variables
SCIP_RETCODE SCIPsetAddIntParam(SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, BMS_BLKMEM *blkmem, const char *name, const char *desc, int *valueptr, SCIP_Bool isadvanced, int defaultvalue, int minvalue, int maxvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: set.c:3029
SCIP_PRICERDATA * pricerdata
Definition: struct_pricer.h:58
SCIP_DECL_PRICERFARKAS(ObjPricerVRP::scip_farkas)
Definition: pricer_vrp.cpp:246
#define BMSduplicateMemoryArray(ptr, source, num)
Definition: memory.h:145
SCIP_RETCODE SCIPclockCreate(SCIP_CLOCK **clck, SCIP_CLOCKTYPE clocktype)
Definition: clock.c:170
SCIP_RETCODE SCIPpricerFarkas(SCIP_PRICER *pricer, SCIP_SET *set, SCIP_PROB *prob, SCIP_RESULT *result)
Definition: pricer.c:432
SCIP_Bool initialized
Definition: struct_pricer.h:67
SCIP_DECL_PRICERREDCOST(ObjPricerVRP::scip_redcost)
Definition: pricer_vrp.cpp:225
public data structures and miscellaneous methods
SCIP_RETCODE SCIPpricerCreate(SCIP_PRICER **pricer, SCIP_SET *set, SCIP_MESSAGEHDLR *messagehdlr, BMS_BLKMEM *blkmem, const char *name, const char *desc, int priority, SCIP_Bool delay, SCIP_DECL_PRICERCOPY((*pricercopy)), SCIP_DECL_PRICERFREE((*pricerfree)), SCIP_DECL_PRICERINIT((*pricerinit)), SCIP_DECL_PRICEREXIT((*pricerexit)), SCIP_DECL_PRICERINITSOL((*pricerinitsol)), SCIP_DECL_PRICEREXITSOL((*pricerexitsol)), SCIP_DECL_PRICERREDCOST((*pricerredcost)), SCIP_DECL_PRICERFARKAS((*pricerfarkas)), SCIP_PRICERDATA *pricerdata)
Definition: pricer.c:173
#define SCIP_Bool
Definition: def.h:93
#define SCIP_DECL_PRICERINITSOL(x)
Definition: type_pricer.h:90
static const char * paramname[]
Definition: lpi_msk.c:5040
void SCIPclockFree(SCIP_CLOCK **clck)
Definition: clock.c:185
SCIP_RETCODE SCIPpricerExitsol(SCIP_PRICER *pricer, SCIP_SET *set)
Definition: pricer.c:329
#define SCIPsetDebugMsg
Definition: set.h:1770
void SCIPpricerSetInitsol(SCIP_PRICER *pricer, SCIP_DECL_PRICERINITSOL((*pricerinitsol)))
Definition: pricer.c:575
SCIP_RETCODE SCIPpricerActivate(SCIP_PRICER *pricer, SCIP_SET *set)
Definition: pricer.c:353
#define BMSclearMemory(ptr)
Definition: memory.h:131
SCIP_Bool SCIPpricerIsDelayed(SCIP_PRICER *pricer)
Definition: pricer.c:703
int SCIPparamGetInt(SCIP_PARAM *param)
Definition: paramset.c:734
SCIP_Bool active
Definition: struct_pricer.h:66
SCIP_Bool SCIPpricerIsInitialized(SCIP_PRICER *pricer)
Definition: pricer.c:713
public methods for message output
int SCIPpricerGetNCalls(SCIP_PRICER *pricer)
Definition: pricer.c:641
#define SCIP_Real
Definition: def.h:186
const char * SCIPpricerGetDesc(SCIP_PRICER *pricer)
Definition: pricer.c:607
SCIP_Real SCIPpricerGetSetupTime(SCIP_PRICER *pricer)
Definition: pricer.c:661
#define BMSallocMemory(ptr)
Definition: memory.h:120
data structures for variable pricers
int SCIPpricerGetNVarsFound(SCIP_PRICER *pricer)
Definition: pricer.c:651
struct SCIP_PricerData SCIP_PRICERDATA
Definition: type_pricer.h:45
#define SCIP_DECL_PRICERFREE(x)
Definition: type_pricer.h:63
common defines and data types used in all packages of SCIP
void SCIPpricerSetExit(SCIP_PRICER *pricer, SCIP_DECL_PRICEREXIT((*pricerexit)))
Definition: pricer.c:564
SCIP_RETCODE SCIPpricerExec(SCIP_PRICER *pricer, SCIP_SET *set, SCIP_PROB *prob, SCIP_LP *lp, SCIP_PRICESTORE *pricestore, SCIP_Real *lowerbound, SCIP_Bool *stopearly, SCIP_RESULT *result)
Definition: pricer.c:471
struct BMS_BlkMem BMS_BLKMEM
Definition: memory.h:439
#define SCIP_ALLOC(x)
Definition: def.h:404
SCIP callable library.