Osi 0.108.12
Loading...
Searching...
No Matches
OsiBranchingObject.hpp File Reference
#include <cassert>
#include <string>
#include <vector>
#include "CoinError.hpp"
#include "CoinTypes.hpp"
Include dependency graph for OsiBranchingObject.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  OsiObject2
 Define a class to add a bit of complexity to OsiObject This assumes 2 way branching. More...
class  OsiBranchingObject
 Abstract branching object base class. More...
class  OsiBranchingInformation
class  OsiTwoWayBranchingObject
 This just adds two-wayness to a branching object. More...
class  OsiSimpleInteger
 Define a single integer class. More...
class  OsiIntegerBranchingObject
 Simple branching object for an integer variable. More...
class  OsiSOS
 Define Special Ordered Sets of type 1 and 2. More...
class  OsiSOSBranchingObject
 Branching object for Special ordered sets. More...
class  OsiLotsize
 Lotsize class. More...
class  OsiLotsizeBranchingObject
 Lotsize branching object. More...

Functions

double infeasibility (const OsiSolverInterface *solver, int &whichWay) const
 Abstract base class for `objects'.
virtual double infeasibility (const OsiBranchingInformation *info, int &whichWay) const =0
virtual double checkInfeasibility (const OsiBranchingInformation *info) const
virtual double feasibleRegion (OsiSolverInterface *solver) const
 For the variable(s) referenced by the object, look at the current solution and set bounds to match the solution.
virtual double feasibleRegion (OsiSolverInterface *solver, const OsiBranchingInformation *info) const =0
 For the variable(s) referenced by the object, look at the current solution and set bounds to match the solution.
virtual OsiBranchingObjectcreateBranch (OsiSolverInterface *, const OsiBranchingInformation *, int) const
 Create a branching object and indicate which way to branch first.
virtual bool canDoHeuristics () const
 Return true if object can take part in normal heuristics.
virtual bool canMoveToNearest () const
 Return true if object can take part in move to nearest heuristic.
virtual int columnNumber () const
 Column number if single column object -1 otherwise, Used by heuristics.
int priority () const
 Return Priority - note 1 is highest priority.
void setPriority (int priority)
 Set priority.
virtual bool boundBranch () const
 Return true if branch should only bound variables.
virtual bool canHandleShadowPrices () const
 Return true if knows how to deal with Pseudo Shadow Prices.
int numberWays () const
 Return maximum number of ways branch may have.
void setNumberWays (int numberWays)
 Set maximum number of ways branch may have.
void setWhichWay (int way)
 Return preferred way to branch.
int whichWay () const
 Return current preferred way to branch.
virtual int preferredWay () const
 Get pre-emptive preferred way of branching - -1 off, 0 down, 1 up (for 2-way).
double infeasibility () const
 Return infeasibility.
virtual double upEstimate () const
 Return "up" estimate (default 1.0e-5).
virtual double downEstimate () const
 Return "down" estimate (default 1.0e-5).
virtual void resetBounds (const OsiSolverInterface *)
 Reset variable bounds to their original values.
virtual void resetSequenceEtc (int, const int *)
 Change column numbers after preprocessing.
virtual void updateBefore (const OsiObject *)
 Updates stuff like pseudocosts before threads.
virtual void updateAfter (const OsiObject *, const OsiObject *)
 Updates stuff like pseudocosts after threads finished.

Variables

double infeasibility_
 data
short whichWay_
 Computed preferred way to branch.
short numberWays_
 Maximum number of ways on branch.
int priority_
 Priority.

Function Documentation

◆ infeasibility() [1/3]

double infeasibility ( const OsiSolverInterface * solver,
int & whichWay ) const

Abstract base class for `objects'.

The branching model used in Osi is based on the idea of an object. In the abstract, an object is something that has a feasible region, can be evaluated for infeasibility, can be branched on (i.e., there's some constructive action to be taken to move toward feasibility), and allows comparison of the effect of branching.

This class (OsiObject) is the base class for an object. To round out the branching model, the class OsiBranchingObject describes how to perform a branch, and the class OsiBranchDecision describes how to compare two OsiBranchingObjects.

To create a new type of object you need to provide three methods: infeasibility(), feasibleRegion(), and createBranch(), described below.

This base class is primarily virtual to allow for any form of structure. Any form of discontinuity is allowed.

As there is an overhead in getting information from solvers and because other useful information is available there is also an OsiBranchingInformation class which can contain pointers to information. If used it must at minimum contain pointers to current value of objective, maximum allowed objective and pointers to arrays for bounds and solution and direction of optimization. Also integer and primal tolerance.

Classes which inherit might have other information such as depth, number of solutions, pseudo-shadow prices etc etc. May be easier just to throw in here - as I keep doing */ class OsiObject {

public: / Default Constructor OsiObject();

/ Copy constructor OsiObject(const OsiObject &);

/ Assignment operator OsiObject &operator=(const OsiObject &rhs);

/ Clone virtual OsiObject *clone() const = 0;

/ Destructor virtual ~OsiObject();

/** Infeasibility of the object

This is some measure of the infeasibility of the object. 0.0 indicates that the object is satisfied.

The preferred branching direction is returned in whichWay, where for normal two-way branching 0 is down, 1 is up

This is used to prepare for strong branching but should also think of case when no strong branching

The object may also compute an estimate of cost of going "up" or "down". This will probably be based on pseudo-cost ideas

This should also set mutable infeasibility_ and whichWay_ This is for instant re-use for speed

Default for this just calls infeasibility with OsiBranchingInformation NOTE - Convention says that an infeasibility of COIN_DBL_MAX means object has worked out it can't be satisfied!

◆ infeasibility() [2/3]

virtual double infeasibility ( const OsiBranchingInformation * info,
int & whichWay ) const
pure virtual

◆ checkInfeasibility()

virtual double checkInfeasibility ( const OsiBranchingInformation * info) const
virtual

◆ feasibleRegion() [1/2]

virtual double feasibleRegion ( OsiSolverInterface * solver) const
virtual

For the variable(s) referenced by the object, look at the current solution and set bounds to match the solution.

Returns measure of how much it had to move solution to make feasible

◆ feasibleRegion() [2/2]

virtual double feasibleRegion ( OsiSolverInterface * solver,
const OsiBranchingInformation * info ) const
pure virtual

For the variable(s) referenced by the object, look at the current solution and set bounds to match the solution.

Returns measure of how much it had to move solution to make feasible Faster version

◆ createBranch()

virtual OsiBranchingObject * createBranch ( OsiSolverInterface * ,
const OsiBranchingInformation * ,
int  ) const
virtual

Create a branching object and indicate which way to branch first.

The branching object has to know how to create branches (fix variables, etc.)

Definition at line 118 of file OsiBranchingObject.hpp.

◆ canDoHeuristics()

virtual bool canDoHeuristics ( ) const
virtual

Return true if object can take part in normal heuristics.

Definition at line 128 of file OsiBranchingObject.hpp.

◆ canMoveToNearest()

virtual bool canMoveToNearest ( ) const
virtual

Return true if object can take part in move to nearest heuristic.

Definition at line 134 of file OsiBranchingObject.hpp.

◆ columnNumber()

virtual int columnNumber ( ) const
virtual

Column number if single column object -1 otherwise, Used by heuristics.

◆ priority()

int priority ( ) const
inline

Return Priority - note 1 is highest priority.

Definition at line 143 of file OsiBranchingObject.hpp.

◆ setPriority()

void setPriority ( int priority)
inline

Set priority.

Definition at line 148 of file OsiBranchingObject.hpp.

◆ boundBranch()

virtual bool boundBranch ( ) const
virtual

Return true if branch should only bound variables.

Definition at line 154 of file OsiBranchingObject.hpp.

◆ canHandleShadowPrices()

virtual bool canHandleShadowPrices ( ) const
virtual

Return true if knows how to deal with Pseudo Shadow Prices.

Definition at line 159 of file OsiBranchingObject.hpp.

◆ numberWays()

int numberWays ( ) const
inline

Return maximum number of ways branch may have.

Definition at line 164 of file OsiBranchingObject.hpp.

◆ setNumberWays()

void setNumberWays ( int numberWays)
inline

Set maximum number of ways branch may have.

Definition at line 169 of file OsiBranchingObject.hpp.

◆ setWhichWay()

void setWhichWay ( int way)
inline

Return preferred way to branch.

If two then way=0 means down and 1 means up, otherwise way points to preferred branch

Definition at line 177 of file OsiBranchingObject.hpp.

◆ whichWay()

int whichWay ( ) const
inline

Return current preferred way to branch.

If two then way=0 means down and 1 means up, otherwise way points to preferred branch

Definition at line 185 of file OsiBranchingObject.hpp.

◆ preferredWay()

virtual int preferredWay ( ) const
virtual

Get pre-emptive preferred way of branching - -1 off, 0 down, 1 up (for 2-way).

Definition at line 190 of file OsiBranchingObject.hpp.

◆ infeasibility() [3/3]

double infeasibility ( ) const
inline

Return infeasibility.

Definition at line 195 of file OsiBranchingObject.hpp.

◆ upEstimate()

virtual double upEstimate ( ) const
virtual

Return "up" estimate (default 1.0e-5).

◆ downEstimate()

virtual double downEstimate ( ) const
virtual

Return "down" estimate (default 1.0e-5).

◆ resetBounds()

virtual void resetBounds ( const OsiSolverInterface * )
virtual

Reset variable bounds to their original values.

Bounds may be tightened, so it may be good to be able to reset them to their original values.

Definition at line 207 of file OsiBranchingObject.hpp.

◆ resetSequenceEtc()

virtual void resetSequenceEtc ( int ,
const int *  )
virtual

Change column numbers after preprocessing.

Definition at line 210 of file OsiBranchingObject.hpp.

◆ updateBefore()

virtual void updateBefore ( const OsiObject * )
virtual

Updates stuff like pseudocosts before threads.

Definition at line 212 of file OsiBranchingObject.hpp.

◆ updateAfter()

virtual void updateAfter ( const OsiObject * ,
const OsiObject *  )
virtual

Updates stuff like pseudocosts after threads finished.

Definition at line 214 of file OsiBranchingObject.hpp.

Variable Documentation

◆ infeasibility_

double infeasibility_
mutableprotected

data

Computed infeasibility

Definition at line 220 of file OsiBranchingObject.hpp.

◆ whichWay_

short whichWay_
mutableprotected

Computed preferred way to branch.

Definition at line 222 of file OsiBranchingObject.hpp.

◆ numberWays_

short numberWays_
protected

Maximum number of ways on branch.

Definition at line 224 of file OsiBranchingObject.hpp.

◆ priority_

int priority_
protected

Priority.

Definition at line 226 of file OsiBranchingObject.hpp.