Ignore:
Timestamp:
Apr 28, 2008 11:41:02 AM (11 years ago)
Author:
forrest
Message:

changes to try and improve performance

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cbc/src/CbcBranchActual.hpp

    r912 r931  
    129129  /// Infeasibility - large is 0.5
    130130  virtual double infeasibility(int & preferredWay) const;
     131  /// Infeasibility - large is 0.5
     132  virtual double infeasibility(const OsiBranchingInformation * info,
     133                               int & preferredWay) const;
    131134
    132135  using CbcObject::feasibleRegion ;
     
    138141  virtual CbcBranchingObject * createBranch(int way) ;
    139142
     143
     144
     145  /** Pass in information on branch just done and create CbcObjectUpdateData instance.
     146      If object does not need data then backward pointer will be NULL.
     147      Assumes can get information from solver */
     148  virtual CbcObjectUpdateData createUpdateInformation(const OsiSolverInterface * solver,
     149                                                        const CbcNode * node,
     150                                                        const CbcBranchingObject * branchingObject);
     151  /// Update object by CbcObjectUpdateData
     152  virtual void updateInformation(const CbcObjectUpdateData & data) ;
    140153  using CbcObject::solverBranch ;
    141154  /** Create an OsiSolverBranch object
     
    160173  inline int sosType() const
    161174  {return sosType_;}
     175  /// Down number times
     176  inline int numberTimesDown() const
     177  { return numberTimesDown_;}
     178  /// Up number times
     179  inline int numberTimesUp() const
     180  { return numberTimesUp_;}
    162181
    163182  /** Array of weights */
     
    191210  /// Weights
    192211  double * weights_;
    193 
     212  /// Current pseudo-shadow price estimate down
     213  mutable double shadowEstimateDown_;
     214  /// Current pseudo-shadow price estimate up
     215  mutable double shadowEstimateUp_;
     216  /// Down pseudo ratio
     217  double downDynamicPseudoRatio_;
     218  /// Up pseudo ratio
     219  double upDynamicPseudoRatio_;
     220  /// Number of times we have gone down
     221  int numberTimesDown_;
     222  /// Number of times we have gone up
     223  int numberTimesUp_;
    194224  /// Number of members
    195225  int numberMembers_;
    196226  /// SOS type
    197    int sosType_;
     227  int sosType_;
    198228  /// Whether integer valued
    199229  bool integerValued_;
     
    449479  */
    450480  virtual double branch();
     481  /** Update bounds in solver as in 'branch' and update given bounds.
     482      branchState is -1 for 'down' +1 for 'up' */
     483  virtual void fix(OsiSolverInterface * solver,
     484                   double * lower, double * upper,
     485                   int branchState) const ;
    451486
    452487#if 0
     
    516551#ifdef FUNNY_BRANCHING
    517552  /** Which variable (top bit if upper bound changing)
    518       next bit if chnaging on down branch only */
     553      next bit if changing on down branch only */
    519554  int * variables_;
    520555  // New bound
     
    897932  /// Does next branch and updates state
    898933  virtual double branch();
     934  /** Update bounds in solver as in 'branch' and update given bounds.
     935      branchState is -1 for 'down' +1 for 'up' */
     936  virtual void fix(OsiSolverInterface * solver,
     937                   double * lower, double * upper,
     938                   int branchState) const ;
    899939
    900940  /** Reset every information so that the branching object appears to point to
     
    13801420};
    13811421
    1382 
     1422/** Define a catch all class.
     1423    This will create a list of subproblems
     1424*/
     1425
     1426
     1427class CbcGeneral : public CbcObject {
     1428
     1429public:
     1430
     1431  // Default Constructor
     1432  CbcGeneral ();
     1433
     1434  /** Useful constructor
     1435      Just needs to point to model.
     1436  */
     1437  CbcGeneral (CbcModel * model);
     1438 
     1439  // Copy constructor
     1440  CbcGeneral ( const CbcGeneral &);
     1441   
     1442  /// Clone
     1443  virtual CbcObject * clone() const=0;
     1444
     1445  // Assignment operator
     1446  CbcGeneral & operator=( const CbcGeneral& rhs);
     1447
     1448  // Destructor
     1449  ~CbcGeneral ();
     1450 
     1451  using CbcObject::infeasibility ;
     1452  /// Infeasibility - large is 0.5
     1453  virtual double infeasibility(int & preferredWay) const=0;
     1454
     1455  using CbcObject::feasibleRegion ;
     1456  /// This looks at solution and sets bounds to contain solution
     1457  virtual void feasibleRegion()=0;
     1458
     1459  using CbcObject::createBranch ;
     1460  /// Creates a branching object
     1461  virtual CbcBranchingObject * createBranch(int way)=0 ;
     1462
     1463  /// Redoes data when sequence numbers change
     1464  virtual void redoSequenceEtc(CbcModel * model, int numberColumns, const int * originalColumns)=0;
     1465
     1466protected:
     1467  /// data
     1468};
     1469#ifdef COIN_HAS_CLP
     1470
     1471/** Define a catch all class.
     1472    This will create a list of subproblems using partial evaluation
     1473*/
     1474#include "ClpSimplex.hpp"
     1475#include "ClpNode.hpp"
     1476
     1477class CbcGeneralDepth : public CbcGeneral {
     1478
     1479public:
     1480
     1481  // Default Constructor
     1482  CbcGeneralDepth ();
     1483
     1484  /** Useful constructor
     1485      Just needs to point to model.
     1486      Initial version does evaluation to depth N
     1487      This is stored in CbcModel but may be
     1488      better here
     1489  */
     1490  CbcGeneralDepth (CbcModel * model, int maximumDepth);
     1491 
     1492  // Copy constructor
     1493  CbcGeneralDepth ( const CbcGeneralDepth &);
     1494   
     1495  /// Clone
     1496  virtual CbcObject * clone() const;
     1497
     1498  // Assignment operator
     1499  CbcGeneralDepth & operator=( const CbcGeneralDepth& rhs);
     1500
     1501  // Destructor
     1502  ~CbcGeneralDepth ();
     1503 
     1504  using CbcObject::infeasibility ;
     1505  /// Infeasibility - large is 0.5
     1506  virtual double infeasibility(int & preferredWay) const;
     1507
     1508  using CbcObject::feasibleRegion ;
     1509  /// This looks at solution and sets bounds to contain solution
     1510  virtual void feasibleRegion();
     1511
     1512  using CbcObject::createBranch ;
     1513  /// Creates a branching object
     1514  virtual CbcBranchingObject * createBranch(int way) ;
     1515  /// Get maximum depth
     1516  inline int maximumDepth() const
     1517  {return maximumDepth_;}
     1518  /// Set maximum depth
     1519  inline void setMaximumDepth(int value)
     1520  {maximumDepth_ = value;}
     1521  /// Get which solution
     1522  inline int whichSolution() const
     1523  {return whichSolution_;}
     1524  /// Get ClpNode info
     1525  inline ClpNode * nodeInfo(int which)
     1526  { return nodeInfo_->nodeInfo_[which];}
     1527
     1528  /// Redoes data when sequence numbers change
     1529  virtual void redoSequenceEtc(CbcModel * model, int numberColumns, const int * originalColumns);
     1530
     1531protected:
     1532  /// data
     1533  /// Maximum depth
     1534  int maximumDepth_;
     1535  /// Which node has solution (or -1)
     1536  mutable int whichSolution_;
     1537  /// Number of valid nodes (including whichSolution_)
     1538  mutable int numberNodes_;
     1539  /// For solving nodes
     1540  mutable ClpNodeStuff * nodeInfo_;
     1541};
     1542
     1543/** Defines a general subproblem
     1544    Basis will be made more compact later
     1545*/
     1546class CoinWarmStartDiff;
     1547class CbcSubProblem {
     1548
     1549public:
     1550
     1551  /// Default constructor
     1552  CbcSubProblem ();
     1553
     1554  /// Constructor from model
     1555  CbcSubProblem (const OsiSolverInterface * solver,
     1556                 const double * lowerBefore,
     1557                 const double * upperBefore,
     1558                 const unsigned char * status);
     1559
     1560  /// Copy constructor
     1561  CbcSubProblem ( const CbcSubProblem &);
     1562   
     1563  /// Assignment operator
     1564  CbcSubProblem & operator= (const CbcSubProblem& rhs);
     1565
     1566  /// Destructor
     1567  virtual ~CbcSubProblem ();
     1568
     1569  /// Apply subproblem
     1570  void apply(OsiSolverInterface * model);
     1571
     1572public:
     1573  /// Value of objective
     1574  double objectiveValue_;
     1575  /// Sum of infeasibilities
     1576  double sumInfeasibilities_;
     1577  /** Which variable (top bit if upper bound changing)
     1578      next bit if changing on down branch only */
     1579  int * variables_;
     1580  /// New bound
     1581  double * newBounds_;
     1582  /// Status as diff
     1583  CoinWarmStartDiff * statusDifference_;
     1584  /// Number of Extra bound changes
     1585  int numberChangedBounds_;
     1586  /// Number of infeasibilities
     1587  int numberInfeasibilities_;
     1588};
     1589
     1590/** Branching object for general objects
     1591
     1592 */
     1593class CbcNode;
     1594class CbcGeneralBranchingObject : public CbcBranchingObject {
     1595
     1596public:
     1597
     1598  // Default Constructor
     1599  CbcGeneralBranchingObject ();
     1600
     1601  // Useful constructor
     1602  CbcGeneralBranchingObject (CbcModel * model);
     1603 
     1604  // Copy constructor
     1605  CbcGeneralBranchingObject ( const CbcGeneralBranchingObject &);
     1606   
     1607  // Assignment operator
     1608  CbcGeneralBranchingObject & operator=( const CbcGeneralBranchingObject& rhs);
     1609
     1610  /// Clone
     1611  virtual CbcBranchingObject * clone() const;
     1612
     1613  // Destructor
     1614  virtual ~CbcGeneralBranchingObject ();
     1615 
     1616  using CbcBranchingObject::branch ;
     1617  /// Does next branch and updates state
     1618  virtual double branch();
     1619  /** Double checks in case node can change its mind!
     1620      Can change objective etc */
     1621  virtual void checkIsCutoff(double cutoff);
     1622
     1623  using CbcBranchingObject::print ;
     1624  /** \brief Print something about branch - only if log level high
     1625  */
     1626  virtual void print();
     1627  /// Fill in current objective etc
     1628  void state(double & objectiveValue,double & sumInfeasibilities,
     1629             int & numberUnsatisfied,int which) const;
     1630  /// Set CbcNode
     1631  inline void setNode(CbcNode * node)
     1632  { node_ = node;}
     1633  /** Return the type (an integer identifier) of \c this */
     1634  virtual int type() const { return 108; }
     1635
     1636  /** Compare the original object of \c this with the original object of \c
     1637      brObj. Assumes that there is an ordering of the original objects.
     1638      This method should be invoked only if \c this and brObj are of the same
     1639      type.
     1640      Return negative/0/positive depending on whether \c this is
     1641      smaller/same/larger than the argument.
     1642  */
     1643  virtual int compareOriginalObject(const CbcBranchingObject* brObj) const;
     1644
     1645  /** Compare the \c this with \c brObj. \c this and \c brObj must be os the
     1646      same type and must have the same original object, but they may have
     1647      different feasible regions.
     1648      Return the appropriate CbcRangeCompare value (first argument being the
     1649      sub/superset if that's the case). In case of overlap (and if \c
     1650      replaceIfOverlap is true) replace the current branching object with one
     1651      whose feasible region is the overlap.
     1652   */
     1653  virtual CbcRangeCompare compareBranchingObject
     1654  (const CbcBranchingObject* brObj, const bool replaceIfOverlap = false);
     1655
     1656public:
     1657  /// data
     1658  // Sub problems
     1659  CbcSubProblem * subProblems_;
     1660  /// Node
     1661  CbcNode * node_;
     1662  /// Number of subproblems
     1663  int numberSubProblems_;
     1664  /// Number of rows
     1665  int numberRows_;
     1666};
    13831667#endif
     1668#endif
Note: See TracChangeset for help on using the changeset viewer.