source: trunk/Cbc/src/CbcObject.cpp

Last change on this file was 2467, checked in by unxusr, 10 months ago

spaces after angles

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.6 KB
Line 
1// $Id: CbcObject.cpp 2467 2019-01-03 21:26:29Z glebb $
2// Copyright (C) 2002, International Business Machines
3// Corporation and others.  All Rights Reserved.
4// This code is licensed under the terms of the Eclipse Public License (EPL).
5
6// Edwin 11/12/2009 carved from CbcBranchBase
7
8#if defined(_MSC_VER)
9// Turn off compiler warning about long names
10#pragma warning(disable : 4786)
11#endif
12#include <cassert>
13#include <cstdlib>
14#include <cmath>
15#include <cfloat>
16
17#include "OsiSolverInterface.hpp"
18#include "OsiSolverBranch.hpp"
19#include "OsiChooseVariable.hpp"
20#include "CbcModel.hpp"
21#include "CbcMessage.hpp"
22#include "CbcBranchBase.hpp"
23
24// Default Constructor
25CbcObject::CbcObject()
26  : OsiObject()
27  , model_(NULL)
28  , id_(-1)
29  , position_(-1)
30  , preferredWay_(0)
31{
32}
33
34// Constructor from model
35CbcObject::CbcObject(CbcModel *model)
36  : OsiObject()
37  , model_(model)
38  , id_(-1)
39  , position_(-1)
40  , preferredWay_(0)
41{
42}
43
44// Destructor
45CbcObject::~CbcObject()
46{
47}
48
49// Copy constructor
50CbcObject::CbcObject(const CbcObject &rhs)
51  : OsiObject(rhs)
52{
53  model_ = rhs.model_;
54  id_ = rhs.id_;
55  position_ = rhs.position_;
56  preferredWay_ = rhs.preferredWay_;
57}
58
59// Assignment operator
60CbcObject &
61CbcObject::operator=(const CbcObject &rhs)
62{
63  if (this != &rhs) {
64    OsiObject::operator=(rhs);
65    model_ = rhs.model_;
66    id_ = rhs.id_;
67    position_ = rhs.position_;
68    preferredWay_ = rhs.preferredWay_;
69  }
70  return *this;
71}
72
73/* Returns floor and ceiling i.e. closest valid points
74 */
75void CbcObject::floorCeiling(double &floorValue, double &ceilingValue, double value,
76  double tolerance) const
77{
78  if (fabs(floor(value + 0.5) - value) > tolerance) {
79    floorValue = floor(value);
80  } else {
81    floorValue = floor(value + 0.5);
82  }
83  ceilingValue = floorValue + 1.0;
84}
85/* For the variable(s) referenced by the object,
86      look at the current solution and set bounds to match the solution.
87      Returns measure of how much it had to move solution to make feasible
88*/
89double
90CbcObject::feasibleRegion(OsiSolverInterface * /*solver*/) const
91{
92  //assert (solver==model_->solver());
93  CbcObject *fudge = const_cast< CbcObject * >(this);
94  fudge->feasibleRegion();
95  return 0.0;
96}
97
98/* For the variable(s) referenced by the object,
99      look at the current solution and set bounds to match the solution.
100      Returns measure of how much it had to move solution to make feasible
101*/
102double
103CbcObject::feasibleRegion(OsiSolverInterface * /*solver*/,
104  const OsiBranchingInformation * /*info*/) const
105{
106  //assert (solver==model_->solver());
107  CbcObject *fudge = const_cast< CbcObject * >(this);
108  fudge->feasibleRegion();
109  return 0.0;
110}
111/* Create a branching object and indicate which way to branch first.
112
113      The branching object has to know how to create branches (fix
114      variables, etc.)
115*/
116OsiBranchingObject *
117CbcObject::createOsiBranch(OsiSolverInterface *solver,
118  const OsiBranchingInformation *info,
119  int way) const
120{
121  //assert (solver==model_->solver());
122  CbcObject *fudge = const_cast< CbcObject * >(this);
123  return fudge->createBranch(solver, info, way);
124}
125/* Create an OsiSolverBranch object
126
127This returns NULL if branch not represented by bound changes
128*/
129OsiSolverBranch *
130CbcObject::solverBranch() const
131{
132  return NULL;
133}
134/* Pass in information on branch just done and create CbcObjectUpdateData instance.
135   If object does not need data then backward pointer will be NULL.
136   Assumes can get information from solver */
137CbcObjectUpdateData
138CbcObject::createUpdateInformation(const OsiSolverInterface * /*solver*/,
139  const CbcNode * /*node*/,
140  const CbcBranchingObject * /*branchingObject*/)
141{
142  return CbcObjectUpdateData();
143}
144
145/* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
146*/
Note: See TracBrowser for help on using the repository browser.