source: trunk/CbcBranchLotsize.cpp @ 72

Last change on this file since 72 was 72, checked in by forrest, 17 years ago

debug for lotsize and when_ for heuristic

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 20.1 KB
Line 
1// Copyright (C) 2002, International Business Machines
2// Corporation and others.  All Rights Reserved.
3#if defined(_MSC_VER)
4// Turn off compiler warning about long names
5#  pragma warning(disable:4786)
6#endif
7#include <cassert>
8#include <cmath>
9#include <cfloat>
10
11#include "OsiSolverInterface.hpp"
12#include "CbcModel.hpp"
13#include "CbcMessage.hpp"
14#include "CbcBranchLotsize.hpp"
15#include "CoinSort.hpp"
16#include "CoinError.hpp"
17/*
18  CBC_PRINT 1 just does sanity checks - no printing
19            2
20*/
21//#define CBC_PRINT 1
22// First/last variable to print info on
23#if CBC_PRINT
24// preset does all - change to x,x to just do x
25static int firstPrint=0;
26static int lastPrint=1000000;
27static CbcModel * saveModel=NULL;
28#endif
29// Just for debug (CBC_PRINT defined in CbcBranchLotsize.cpp)
30void 
31CbcLotsize::printLotsize(double value,bool condition,int type) const
32{
33#if CBC_PRINT
34  if (columnNumber_>=firstPrint&&columnNumber_<=lastPrint) {
35    int printIt = CBC_PRINT-1;
36    // Get details
37    OsiSolverInterface * solver = saveModel->solver();
38    double currentLower = solver->getColLower()[columnNumber_];
39    double currentUpper = solver->getColUpper()[columnNumber_];
40    int i;
41    // See if in a valid range (with two tolerances)
42    bool inRange=false;
43    bool inRange2=false;
44    double integerTolerance = 
45      model_->getDblParam(CbcModel::CbcIntegerTolerance);
46    // increase if type 2
47    if (type==2) {
48      integerTolerance *= 100.0;
49      type=0;
50      printIt=2; // always print
51    }
52    // bounds should match some bound
53    int rangeL=-1;
54    int rangeU=-1;
55    if (rangeType_==1) {
56      for (i=0;i<numberRanges_;i++) {
57        if (fabs(currentLower-bound_[i])<1.0e-12)
58          rangeL=i;
59        if (fabs(currentUpper-bound_[i])<1.0e-12)
60          rangeU=i;
61        if (fabs(value-bound_[i])<integerTolerance)
62          inRange=true;
63        if (fabs(value-bound_[i])<1.0e8)
64          inRange2=true;
65      }
66    } else {
67      for (i=0;i<numberRanges_;i++) {
68        if (fabs(currentLower-bound_[2*i])<1.0e-12)
69          rangeL=i;
70        if (fabs(currentUpper-bound_[2*i+1])<1.0e-12)
71          rangeU=i;
72        if (value>bound_[2*i]-integerTolerance&&
73            value<bound_[2*i+1]+integerTolerance)
74          inRange=true;
75        if (value>bound_[2*i]-integerTolerance&&
76            value<bound_[2*i+1]+integerTolerance)
77          inRange=true;
78      }
79    }
80    assert (rangeL>=0&&rangeU>=0);
81    bool abortIt=false;
82    switch (type) {
83      // returning from findRange (fall through to just check)
84    case 0:
85      if (printIt) {
86        printf("findRange returns %s for column %d and value %g",
87               condition ? "true" : "false",columnNumber_,value);
88        if (printIt>1)
89          printf(" LP bounds %g, %g",currentLower,currentUpper);
90        printf("\n");
91      }
92      // Should match
93    case 1:
94      if (inRange!=condition) {
95        printIt=2;
96        abortIt=true;
97      }
98      break;
99      //
100    case 2:
101      break;
102      //
103    case 3:
104      break;
105      //
106    case 4:
107      break;
108    }
109  }
110#endif
111}
112/** Default Constructor
113
114*/
115CbcLotsize::CbcLotsize ()
116  : CbcObject(),
117    columnNumber_(-1),
118    rangeType_(0),
119    numberRanges_(0),
120    largestGap_(0),
121    bound_(NULL),
122    range_(0)
123{
124}
125
126/** Useful constructor
127
128  Loads actual upper & lower bounds for the specified variable.
129*/
130CbcLotsize::CbcLotsize (CbcModel * model, 
131                                    int iColumn, int numberPoints,
132                        const double * points, bool range)
133  : CbcObject(model)
134{
135#if CBC_PRINT
136  if (!saveModel)
137    saveModel=model;
138#endif
139  assert (numberPoints>0);
140  columnNumber_ = iColumn ;
141  // and set id so can be used for branching
142  id_=iColumn;
143  // sort ranges
144  int * sort = new int[numberPoints];
145  double * weight = new double [numberPoints];
146  int i;
147  if (range) {
148    rangeType_=2;
149  } else {
150    rangeType_=1;
151  }
152  for (i=0;i<numberPoints;i++) {
153    sort[i]=i;
154    weight[i]=points[i*rangeType_];
155  }
156  CoinSort_2(weight,weight+numberPoints,sort);
157  numberRanges_=1;
158  largestGap_=0;
159  if (rangeType_==1) {
160    bound_ = new double[numberPoints+1];
161    bound_[0]=weight[0];
162    for (i=1;i<numberPoints;i++) {
163      if (weight[i]!=weight[i-1]) 
164        bound_[numberRanges_++]=weight[i];
165    }
166    // and for safety
167    bound_[numberRanges_]=bound_[numberRanges_-1];
168    for (i=1;i<numberRanges_;i++) {
169      largestGap_ = CoinMax(largestGap_,bound_[i]-bound_[i-1]);
170    }
171  } else {
172    bound_ = new double[2*numberPoints+2];
173    bound_[0]=points[sort[0]*2];
174    bound_[1]=points[sort[0]*2+1];
175    double lo=bound_[0];
176    double hi=bound_[1];
177    assert (hi>=lo);
178    for (i=1;i<numberPoints;i++) {
179      double thisLo =points[sort[i]*2];
180      double thisHi =points[sort[i]*2+1];
181      assert (thisHi>=thisLo);
182      if (thisLo>hi) {
183        bound_[2*numberRanges_]=thisLo;
184        bound_[2*numberRanges_+1]=thisHi;
185        numberRanges_++;
186        lo=thisLo;
187        hi=thisHi;
188      } else {
189        //overlap
190        hi=CoinMax(hi,thisHi);
191        bound_[2*numberRanges_-1]=hi;
192      }
193    }
194    // and for safety
195    bound_[2*numberRanges_]=bound_[2*numberRanges_-2];
196    bound_[2*numberRanges_+1]=bound_[2*numberRanges_-1];
197    for (i=1;i<numberRanges_;i++) {
198      largestGap_ = CoinMax(largestGap_,bound_[2*i]-bound_[2*i-1]);
199    }
200  }
201  delete [] sort;
202  delete [] weight;
203  range_=0;
204}
205
206// Copy constructor
207CbcLotsize::CbcLotsize ( const CbcLotsize & rhs)
208  :CbcObject(rhs)
209
210{
211  columnNumber_ = rhs.columnNumber_;
212  rangeType_ = rhs.rangeType_;
213  numberRanges_ = rhs.numberRanges_;
214  range_ = rhs.range_;
215  largestGap_ = rhs.largestGap_;
216  if (numberRanges_) {
217    assert (rangeType_>0&&rangeType_<3);
218    bound_= new double [(numberRanges_+1)*rangeType_];
219    memcpy(bound_,rhs.bound_,(numberRanges_+1)*rangeType_*sizeof(double));
220  } else {
221    bound_=NULL;
222  }
223}
224
225// Clone
226CbcObject *
227CbcLotsize::clone() const
228{
229  return new CbcLotsize(*this);
230}
231
232// Assignment operator
233CbcLotsize & 
234CbcLotsize::operator=( const CbcLotsize& rhs)
235{
236  if (this!=&rhs) {
237    CbcObject::operator=(rhs);
238    columnNumber_ = rhs.columnNumber_;
239    rangeType_ = rhs.rangeType_;
240    numberRanges_ = rhs.numberRanges_;
241    largestGap_ = rhs.largestGap_;
242    delete [] bound_;
243    range_ = rhs.range_;
244    if (numberRanges_) {
245      assert (rangeType_>0&&rangeType_<3);
246      bound_= new double [(numberRanges_+1)*rangeType_];
247      memcpy(bound_,rhs.bound_,(numberRanges_+1)*rangeType_*sizeof(double));
248    } else {
249      bound_=NULL;
250    }
251  }
252  return *this;
253}
254
255// Destructor
256CbcLotsize::~CbcLotsize ()
257{
258  delete [] bound_;
259}
260/* Finds range of interest so value is feasible in range range_ or infeasible
261   between hi[range_] and lo[range_+1].  Returns true if feasible.
262*/
263bool 
264CbcLotsize::findRange(double value) const
265{
266  assert (range_>=0&&range_<numberRanges_+1);
267  double integerTolerance = 
268    model_->getDblParam(CbcModel::CbcIntegerTolerance);
269  int iLo;
270  int iHi;
271  double infeasibility=0.0;
272  if (rangeType_==1) {
273    if (value<bound_[range_]-integerTolerance) {
274      iLo=0;
275      iHi=range_-1;
276    } else if (value<bound_[range_]+integerTolerance) {
277#if CBC_PRINT
278      printLotsize(value,true,0);
279#endif
280      return true;
281    } else if (value<bound_[range_+1]-integerTolerance) {
282#ifdef CBC_PRINT
283      printLotsize(value,false,0);
284#endif
285      return false;
286    } else {
287      iLo=range_+1;
288      iHi=numberRanges_-1;
289    }
290    // check lo and hi
291    bool found=false;
292    if (value>bound_[iLo]-integerTolerance&&value<bound_[iLo+1]+integerTolerance) {
293      range_=iLo;
294      found=true;
295    } else if (value>bound_[iHi]-integerTolerance&&value<bound_[iHi+1]+integerTolerance) {
296      range_=iHi;
297      found=true;
298    } else {
299      range_ = (iLo+iHi)>>1;
300    }
301    //points
302    while (!found) {
303      if (value<bound_[range_]) {
304        if (value>=bound_[range_-1]) {
305          // found
306          range_--;
307          break;
308        } else {
309          iHi = range_;
310        }
311      } else {
312        if (value<bound_[range_+1]) {
313          // found
314          break;
315        } else {
316          iLo = range_;
317        }
318      }
319      range_ = (iLo+iHi)>>1;
320    }
321    if (value-bound_[range_]<=bound_[range_+1]-value) {
322      infeasibility = value-bound_[range_];
323    } else {
324      infeasibility = bound_[range_+1]-value;
325      if (infeasibility<integerTolerance)
326        range_++;
327    }
328#ifdef CBC_PRINT
329    printLotsize(value,(infeasibility<integerTolerance),0);
330#endif
331    return (infeasibility<integerTolerance);
332  } else {
333    // ranges
334    if (value<bound_[2*range_]-integerTolerance) {
335      iLo=0;
336      iHi=range_-1;
337    } else if (value<bound_[2*range_+1]+integerTolerance) {
338#ifdef CBC_PRINT
339      printLotsize(value,true,0);
340#endif
341      return true;
342    } else if (value<bound_[2*range_+2]-integerTolerance) {
343#ifdef CBC_PRINT
344      printLotsize(value,false,0);
345#endif
346      return false;
347    } else {
348      iLo=range_+1;
349      iHi=numberRanges_-1;
350    }
351    // check lo and hi
352    bool found=false;
353    if (value>bound_[2*iLo]-integerTolerance&&value<bound_[2*iLo+2]-integerTolerance) {
354      range_=iLo;
355      found=true;
356    } else if (value>=bound_[2*iHi]-integerTolerance) {
357      range_=iHi;
358      found=true;
359    } else {
360      range_ = (iLo+iHi)>>1;
361    }
362    //points
363    while (!found) {
364      if (value<bound_[2*range_]) {
365        if (value>=bound_[2*range_-2]) {
366          // found
367          range_--;
368          break;
369        } else {
370          iHi = range_;
371        }
372      } else {
373        if (value<bound_[2*range_+2]) {
374          // found
375          break;
376        } else {
377          iLo = range_;
378        }
379      }
380      range_ = (iLo+iHi)>>1;
381    }
382    if (value>=bound_[2*range_]-integerTolerance&&value<=bound_[2*range_+1]+integerTolerance)
383      infeasibility=0.0;
384    else if (value-bound_[2*range_+1]<bound_[2*range_+2]-value) {
385      infeasibility = value-bound_[2*range_+1];
386    } else {
387      infeasibility = bound_[2*range_+2]-value;
388    }
389#ifdef CBC_PRINT
390    printLotsize(value,(infeasibility<integerTolerance),0);
391#endif
392    return (infeasibility<integerTolerance);
393  }
394}
395/* Returns floor and ceiling
396 */
397void 
398CbcLotsize::floorCeiling(double & floorLotsize, double & ceilingLotsize, double value,
399                         double tolerance) const
400{
401  bool feasible=findRange(value);
402  if (rangeType_==1) {
403    floorLotsize=bound_[range_];
404    ceilingLotsize=bound_[range_+1];
405    // may be able to adjust
406    if (feasible&&fabs(value-floorLotsize)>fabs(value-ceilingLotsize)) {
407      floorLotsize=bound_[range_+1];
408      ceilingLotsize=bound_[range_+2];
409    }
410  } else {
411    // ranges
412    assert (value>=bound_[2*range_+1]);
413    floorLotsize=bound_[2*range_+1];
414    ceilingLotsize=bound_[2*range_+2];
415  }
416}
417
418// Infeasibility - large is 0.5
419double 
420CbcLotsize::infeasibility(int & preferredWay) const
421{
422  OsiSolverInterface * solver = model_->solver();
423  const double * solution = model_->currentSolution();
424  const double * lower = solver->getColLower();
425  const double * upper = solver->getColUpper();
426  double value = solution[columnNumber_];
427  value = CoinMax(value, lower[columnNumber_]);
428  value = CoinMin(value, upper[columnNumber_]);
429  /*printf("%d %g %g %g %g\n",columnNumber_,value,lower[columnNumber_],
430    solution[columnNumber_],upper[columnNumber_]);*/
431  assert (value>=bound_[0]&&value<=bound_[rangeType_*numberRanges_-1]);
432  double integerTolerance = 
433    model_->getDblParam(CbcModel::CbcIntegerTolerance);
434  double infeasibility=0.0;
435  bool feasible = findRange(value);
436  if (!feasible) {
437    if (rangeType_==1) {
438      if (value-bound_[range_]<bound_[range_+1]-value) {
439        preferredWay=-1;
440        infeasibility = value-bound_[range_];
441      } else {
442        preferredWay=1;
443        infeasibility = bound_[range_+1]-value;
444      }
445    } else {
446      // ranges
447      if (value-bound_[2*range_+1]<bound_[2*range_+2]-value) {
448        preferredWay=-1;
449        infeasibility = value-bound_[2*range_+1];
450      } else {
451        preferredWay=1;
452        infeasibility = bound_[2*range_+2]-value;
453      }
454    }
455  } else {
456    // always satisfied
457    preferredWay=-1;
458  }
459  if (infeasibility<integerTolerance)
460    infeasibility=0.0;
461  else
462    infeasibility /= largestGap_;
463#ifdef CBC_PRINT
464    printLotsize(value,infeasibility,1);
465#endif
466  return infeasibility;
467}
468// This looks at solution and sets bounds to contain solution
469/** More precisely: it first forces the variable within the existing
470    bounds, and then tightens the bounds to make sure the variable is feasible
471*/
472void 
473CbcLotsize::feasibleRegion()
474{
475  OsiSolverInterface * solver = model_->solver();
476  const double * lower = solver->getColLower();
477  const double * upper = solver->getColUpper();
478  const double * solution = model_->currentSolution();
479  double value = solution[columnNumber_];
480  value = CoinMax(value, lower[columnNumber_]);
481  value = CoinMin(value, upper[columnNumber_]);
482  findRange(value);
483  double nearest;
484  if (rangeType_==1) {
485    nearest = bound_[range_];
486    solver->setColLower(columnNumber_,nearest);
487    solver->setColUpper(columnNumber_,nearest);
488  } else {
489    // ranges
490    solver->setColLower(columnNumber_,bound_[2*range_]);
491    solver->setColUpper(columnNumber_,bound_[2*range_+1]);
492    if (value>bound_[2*range_+1]) 
493      nearest=bound_[2*range_+1];
494    else if (value<bound_[2*range_]) 
495      nearest = bound_[2*range_];
496    else
497      nearest = value;
498  }
499  double integerTolerance = 
500    model_->getDblParam(CbcModel::CbcIntegerTolerance);
501#ifdef CBC_PRINT
502  // print details
503  printLotsize(value,true,2);
504#endif
505  // Scaling may have moved it a bit
506  assert (fabs(value-nearest)<=100.0*integerTolerance);
507}
508
509// Creates a branching object
510CbcBranchingObject * 
511CbcLotsize::createBranch(int way) const
512{
513  OsiSolverInterface * solver = model_->solver();
514  const double * solution = model_->currentSolution();
515  const double * lower = solver->getColLower();
516  const double * upper = solver->getColUpper();
517  double value = solution[columnNumber_];
518  value = CoinMax(value, lower[columnNumber_]);
519  value = CoinMin(value, upper[columnNumber_]);
520  bool feasible = findRange(value);
521  assert (!feasible);
522  return new CbcLotsizeBranchingObject(model_,columnNumber_,way,
523                                             value,this);
524}
525
526
527/* Given valid solution (i.e. satisfied) and reduced costs etc
528   returns a branching object which would give a new feasible
529   point in direction reduced cost says would be cheaper.
530   If no feasible point returns null
531*/
532CbcBranchingObject * 
533CbcLotsize::preferredNewFeasible() const
534{
535  OsiSolverInterface * solver = model_->solver();
536  double value = model_->currentSolution()[columnNumber_];
537
538  bool feasible = findRange(value);
539  assert (feasible);
540  double dj = solver->getObjSense()*solver->getReducedCost()[columnNumber_];
541  CbcLotsizeBranchingObject * object = NULL;
542  double lo,up;
543  if (dj>=0.0) {
544    // can we go down
545    if (range_) {
546      // yes
547      if (rangeType_==1) {
548        lo = bound_[range_-1];
549        up = bound_[range_-1];
550      } else {
551        lo = bound_[2*range_-2];
552        up = bound_[2*range_-1];
553      }
554      object = new CbcLotsizeBranchingObject(model_,columnNumber_,-1,
555                                             lo,up);
556    }
557  } else {
558    // can we go up
559    if (range_<numberRanges_-1) {
560      // yes
561      if (rangeType_==1) {
562        lo = bound_[range_+1];
563        up = bound_[range_+1];
564      } else {
565        lo = bound_[2*range_+2];
566        up = bound_[2*range_+3];
567      }
568      object = new CbcLotsizeBranchingObject(model_,columnNumber_,-1,
569                                             lo,up);
570    }
571  }
572  return object;
573}
574 
575/* Given valid solution (i.e. satisfied) and reduced costs etc
576   returns a branching object which would give a new feasible
577   point in direction opposite to one reduced cost says would be cheaper.
578   If no feasible point returns null
579*/
580CbcBranchingObject * 
581CbcLotsize::notPreferredNewFeasible() const 
582{
583  OsiSolverInterface * solver = model_->solver();
584  double value = model_->currentSolution()[columnNumber_];
585
586  double nearest = floor(value+0.5);
587  double integerTolerance = 
588    model_->getDblParam(CbcModel::CbcIntegerTolerance);
589  assert (fabs(value-nearest)<=integerTolerance);
590  double dj = solver->getObjSense()*solver->getReducedCost()[columnNumber_];
591  CbcLotsizeBranchingObject * object = NULL;
592  double lo,up;
593  if (dj<=0.0) {
594    // can we go down
595    if (range_) {
596      // yes
597      if (rangeType_==1) {
598        lo = bound_[range_-1];
599        up = bound_[range_-1];
600      } else {
601        lo = bound_[2*range_-2];
602        up = bound_[2*range_-1];
603      }
604      object = new CbcLotsizeBranchingObject(model_,columnNumber_,-1,
605                                             lo,up);
606    }
607  } else {
608    // can we go up
609    if (range_<numberRanges_-1) {
610      // yes
611      if (rangeType_==1) {
612        lo = bound_[range_+1];
613        up = bound_[range_+1];
614      } else {
615        lo = bound_[2*range_+2];
616        up = bound_[2*range_+3];
617      }
618      object = new CbcLotsizeBranchingObject(model_,columnNumber_,-1,
619                                             lo,up);
620    }
621  }
622  return object;
623}
624 
625/*
626  Bounds may be tightened, so it may be good to be able to refresh the local
627  copy of the original bounds.
628 */
629void 
630CbcLotsize::resetBounds()
631{
632  //printf("resetBounds needs coding for CbcLotSize\n");
633}
634
635
636// Default Constructor
637CbcLotsizeBranchingObject::CbcLotsizeBranchingObject()
638  :CbcBranchingObject()
639{
640  down_[0] = 0.0;
641  down_[1] = 0.0;
642  up_[0] = 0.0;
643  up_[1] = 0.0;
644}
645
646// Useful constructor
647CbcLotsizeBranchingObject::CbcLotsizeBranchingObject (CbcModel * model, 
648                                                      int variable, int way , double value,
649                                                      const CbcLotsize * lotsize)
650  :CbcBranchingObject(model,variable,way,value)
651{
652  int iColumn = lotsize->modelSequence();
653  assert (variable==iColumn);
654  down_[0] = model_->solver()->getColLower()[iColumn];
655  double integerTolerance = 
656    model_->getDblParam(CbcModel::CbcIntegerTolerance);
657  lotsize->floorCeiling(down_[1],up_[0],value,integerTolerance);
658  up_[1] = model->getColUpper()[iColumn];
659}
660// Useful constructor for fixing
661CbcLotsizeBranchingObject::CbcLotsizeBranchingObject (CbcModel * model, 
662                                                      int variable, int way,
663                                                      double lowerValue, 
664                                                      double upperValue)
665  :CbcBranchingObject(model,variable,way,lowerValue)
666{
667  numberBranchesLeft_=1;
668  down_[0] = lowerValue;
669  down_[1] = upperValue;
670  up_[0] = lowerValue;
671  up_[1] = upperValue;
672}
673 
674
675// Copy constructor
676CbcLotsizeBranchingObject::CbcLotsizeBranchingObject ( const CbcLotsizeBranchingObject & rhs) :CbcBranchingObject(rhs)
677{
678  down_[0] = rhs.down_[0];
679  down_[1] = rhs.down_[1];
680  up_[0] = rhs.up_[0];
681  up_[1] = rhs.up_[1];
682}
683
684// Assignment operator
685CbcLotsizeBranchingObject & 
686CbcLotsizeBranchingObject::operator=( const CbcLotsizeBranchingObject& rhs)
687{
688  if (this != &rhs) {
689    CbcBranchingObject::operator=(rhs);
690    down_[0] = rhs.down_[0];
691    down_[1] = rhs.down_[1];
692    up_[0] = rhs.up_[0];
693    up_[1] = rhs.up_[1];
694  }
695  return *this;
696}
697CbcBranchingObject * 
698CbcLotsizeBranchingObject::clone() const
699{ 
700  return (new CbcLotsizeBranchingObject(*this));
701}
702
703
704// Destructor
705CbcLotsizeBranchingObject::~CbcLotsizeBranchingObject ()
706{
707}
708
709/*
710  Perform a branch by adjusting the bounds of the specified variable. Note
711  that each arm of the branch advances the object to the next arm by
712  advancing the value of way_.
713
714  Providing new values for the variable's lower and upper bounds for each
715  branching direction gives a little bit of additional flexibility and will
716  be easily extensible to multi-way branching.
717*/
718double
719CbcLotsizeBranchingObject::branch(bool normalBranch)
720{
721  if (model_->messageHandler()->logLevel()>2&&normalBranch)
722    print(normalBranch);
723  numberBranchesLeft_--;
724  int iColumn = variable_;
725  if (way_<0) {
726#ifdef CBC_DEBUG
727  { double olb,oub ;
728    olb = model_->solver()->getColLower()[iColumn] ;
729    oub = model_->solver()->getColUpper()[iColumn] ;
730    printf("branching down on var %d: [%g,%g] => [%g,%g]\n",
731           iColumn,olb,oub,down_[0],down_[1]) ; }
732#endif
733    model_->solver()->setColLower(iColumn,down_[0]);
734    model_->solver()->setColUpper(iColumn,down_[1]);
735    way_=1;
736  } else {
737#ifdef CBC_DEBUG
738  { double olb,oub ;
739    olb = model_->solver()->getColLower()[iColumn] ;
740    oub = model_->solver()->getColUpper()[iColumn] ;
741    printf("branching up on var %d: [%g,%g] => [%g,%g]\n",
742           iColumn,olb,oub,up_[0],up_[1]) ; }
743#endif
744    model_->solver()->setColLower(iColumn,up_[0]);
745    model_->solver()->setColUpper(iColumn,up_[1]);
746    way_=-1;      // Swap direction
747  }
748  return 0.0;
749}
750// Print
751void
752CbcLotsizeBranchingObject::print(bool normalBranch)
753{
754  int iColumn = variable_;
755  if (way_<0) {
756  { double olb,oub ;
757    olb = model_->solver()->getColLower()[iColumn] ;
758    oub = model_->solver()->getColUpper()[iColumn] ;
759    printf("branching down on var %d: [%g,%g] => [%g,%g]\n",
760           iColumn,olb,oub,down_[0],down_[1]) ; }
761  } else {
762  { double olb,oub ;
763    olb = model_->solver()->getColLower()[iColumn] ;
764    oub = model_->solver()->getColUpper()[iColumn] ;
765    printf("branching up on var %d: [%g,%g] => [%g,%g]\n",
766           iColumn,olb,oub,up_[0],up_[1]) ; }
767  }
768}
Note: See TracBrowser for help on using the repository browser.