Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

SbbSimpleInteger Class Reference

Define a single integer class. More...

#include <SbbBranchActual.hpp>

Inheritance diagram for SbbSimpleInteger:

SbbObject List of all members.

Public Member Functions

 SbbSimpleInteger ()
 SbbSimpleInteger (SbbModel *model, int sequence, int iColumn)
 SbbSimpleInteger (const SbbSimpleInteger &)
virtual SbbObjectclone () const
 Clone.

SbbSimpleIntegeroperator= (const SbbSimpleInteger &rhs)
virtual double infeasibility (int &preferredWay, double &otherWay) const
 Infeasibility - large is 0.5.

virtual void feasibleRegion ()
virtual SbbBranchingObjectcreateBranch (int way) const
 Creates a branching object.

virtual SbbBranchingObjectpreferredNewFeasible () const
 Given a valid solution (with reduced costs, etc.), return a branching object which would give a new feasible point in the good direction.

virtual SbbBranchingObjectnotPreferredNewFeasible () const
 Given a valid solution (with reduced costs, etc.), return a branching object which would give a new feasible point in a bad direction.

virtual void resetBounds ()
int sequence () const
 Sequence number.

int modelSequence () const
 Model column number.

double originalLowerBound () const
 Original bounds.

double originalUpperBound () const

Private Attributes

int sequence_
 data Sequence

int columnNumber_
 Column number in model.

double originalLower_
 Original lower bound.

double originalUpper_
 Original upper bound.


Detailed Description

Define a single integer class.

Definition at line 89 of file SbbBranchActual.hpp.


Constructor & Destructor Documentation

SbbSimpleInteger::SbbSimpleInteger  ) 
 

Default Constructor

Equivalent to an unspecified binary variable.

Definition at line 300 of file SbbBranchActual.cpp.

Referenced by clone().

00301   : SbbObject(),
00302     sequence_(-1),
00303     columnNumber_(-1),
00304     originalLower_(0.0),
00305     originalUpper_(1.0)
00306 {
00307 }

SbbSimpleInteger::SbbSimpleInteger SbbModel model,
int  sequence,
int  iColumn
 

Useful constructor

Loads actual upper & lower bounds for the specified variable.

Definition at line 313 of file SbbBranchActual.cpp.

References columnNumber_, OsiSolverInterface::getColLower(), OsiSolverInterface::getColUpper(), originalLower_, originalUpper_, sequence_, and SbbModel::solver().

00315   : SbbObject(model)
00316 {
00317   sequence_ = sequence ;
00318   columnNumber_ = iColumn ;
00319   originalLower_ = model_->solver()->getColLower()[columnNumber_] ;
00320   originalUpper_ = model_->solver()->getColUpper()[columnNumber_] ;
00321 }


Member Function Documentation

void SbbSimpleInteger::feasibleRegion  )  [virtual]
 

Set bounds to contain the current solution.

More precisely, for the variable associated with this object, take the value given in the current solution, force it within the current bounds if required, then set the bounds to fix the variable at the integer nearest the solution value.

Implements SbbObject.

Definition at line 390 of file SbbBranchActual.cpp.

References columnNumber_, SbbModel::currentSolution(), OsiSolverInterface::getColLower(), OsiSolverInterface::getColUpper(), SbbModel::getDblParam(), OsiSolverInterface::setColLower(), OsiSolverInterface::setColUpper(), and SbbModel::solver().

00391 {
00392   OsiSolverInterface * solver = model_->solver();
00393   const double * lower = solver->getColLower();
00394   const double * upper = solver->getColUpper();
00395   const double * solution = model_->currentSolution();
00396   double value = solution[columnNumber_];
00397   value = max(value, lower[columnNumber_]);
00398   value = min(value, upper[columnNumber_]);
00399 
00400   double nearest = floor(value+0.5);
00401   double integerTolerance = 
00402     model_->getDblParam(SbbModel::SbbIntegerTolerance);
00403   // Scaling may have moved it a bit
00404   assert (fabs(value-nearest)<=100.0*integerTolerance);
00405   solver->setColLower(columnNumber_,nearest);
00406   solver->setColUpper(columnNumber_,nearest);
00407 }

SbbBranchingObject * SbbSimpleInteger::notPreferredNewFeasible  )  const [virtual]
 

Given a valid solution (with reduced costs, etc.), return a branching object which would give a new feasible point in a bad direction.

As for preferredNewFeasible(), but the preferred branching object will force movement in a direction that degrades the objective.

Reimplemented from SbbObject.

Definition at line 470 of file SbbBranchActual.cpp.

References columnNumber_, SbbModel::currentSolution(), SbbModel::getDblParam(), OsiSolverInterface::getObjSense(), OsiSolverInterface::getReducedCost(), originalLower_, originalUpper_, sequence_, and SbbModel::solver().

00471 {
00472   OsiSolverInterface * solver = model_->solver();
00473   double value = model_->currentSolution()[columnNumber_];
00474 
00475   double nearest = floor(value+0.5);
00476   double integerTolerance = 
00477     model_->getDblParam(SbbModel::SbbIntegerTolerance);
00478   assert (fabs(value-nearest)<=integerTolerance);
00479   double dj = solver->getObjSense()*solver->getReducedCost()[columnNumber_];
00480   SbbIntegerBranchingObject * object = NULL;
00481   if (dj<=0.0) {
00482     // can we go down
00483     if (nearest>originalLower_+0.5) {
00484       // yes
00485       object = new SbbIntegerBranchingObject(model_,sequence_,-1,
00486                                              nearest-1.0,nearest-1.0);
00487     }
00488   } else {
00489     // can we go up
00490     if (nearest<originalUpper_-0.5) {
00491       // yes
00492       object = new SbbIntegerBranchingObject(model_,sequence_,-1,
00493                                              nearest+1.0,nearest+1.0);
00494     }
00495   }
00496   return object;
00497 }

SbbBranchingObject * SbbSimpleInteger::preferredNewFeasible  )  const [virtual]
 

Given a valid solution (with reduced costs, etc.), return a branching object which would give a new feasible point in the good direction.

The preferred branching object will force the variable to be +/-1 from its current value, depending on the reduced cost and objective sense. If movement in the direction which improves the objective is impossible due to bounds on the variable, the branching object will move in the other direction. If no movement is possible, the method returns NULL.

Only the bounds on this variable are considered when determining if the new point is feasible.

Reimplemented from SbbObject.

Definition at line 435 of file SbbBranchActual.cpp.

References columnNumber_, SbbModel::currentSolution(), SbbModel::getDblParam(), OsiSolverInterface::getObjSense(), OsiSolverInterface::getReducedCost(), originalLower_, originalUpper_, sequence_, and SbbModel::solver().

00436 {
00437   OsiSolverInterface * solver = model_->solver();
00438   double value = model_->currentSolution()[columnNumber_];
00439 
00440   double nearest = floor(value+0.5);
00441   double integerTolerance = 
00442     model_->getDblParam(SbbModel::SbbIntegerTolerance);
00443   assert (fabs(value-nearest)<=integerTolerance);
00444   double dj = solver->getObjSense()*solver->getReducedCost()[columnNumber_];
00445   SbbIntegerBranchingObject * object = NULL;
00446   if (dj>=0.0) {
00447     // can we go down
00448     if (nearest>originalLower_+0.5) {
00449       // yes
00450       object = new SbbIntegerBranchingObject(model_,sequence_,-1,
00451                                              nearest-1.0,nearest-1.0);
00452     }
00453   } else {
00454     // can we go up
00455     if (nearest<originalUpper_-0.5) {
00456       // yes
00457       object = new SbbIntegerBranchingObject(model_,sequence_,-1,
00458                                              nearest+1.0,nearest+1.0);
00459     }
00460   }
00461   return object;
00462 }

void SbbSimpleInteger::resetBounds  )  [virtual]
 

Reset original upper and lower bound values from the solver.

Handy for updating bounds held in this object after bounds held in the solver have been tightened.

Reimplemented from SbbObject.

Definition at line 504 of file SbbBranchActual.cpp.

References columnNumber_, OsiSolverInterface::getColLower(), OsiSolverInterface::getColUpper(), originalLower_, originalUpper_, and SbbModel::solver().


The documentation for this class was generated from the following files:
Generated on Wed Dec 3 14:36:26 2003 for Sbb by doxygen 1.3.5