source: branches/BSP/trunk/Clp/src/ClpConstraint.cpp @ 1071

Last change on this file since 1071 was 1035, checked in by forrest, 13 years ago

forgot to add ClpConstraint?

File size: 2.1 KB
Line 
1// Copyright (C) 2007, International Business Machines
2// Corporation and others.  All Rights Reserved.
3
4#include "CoinPragma.hpp"
5#include "ClpSimplex.hpp"
6#include "ClpConstraint.hpp"
7
8//#############################################################################
9// Constructors / Destructor / Assignment
10//#############################################################################
11
12//-------------------------------------------------------------------
13// Default Constructor
14//-------------------------------------------------------------------
15ClpConstraint::ClpConstraint () :
16  lastGradient_(NULL),
17  functionValue_(0.0),
18  offset_(0.0),
19  type_(-1),
20  rowNumber_(-1)
21{
22
23}
24
25//-------------------------------------------------------------------
26// Copy constructor
27//-------------------------------------------------------------------
28ClpConstraint::ClpConstraint (const ClpConstraint & source) :
29  lastGradient_(NULL),
30  functionValue_(source.functionValue_),
31  offset_(source.offset_),
32  type_(source.type_),
33  rowNumber_(source.rowNumber_)
34{ 
35
36}
37
38//-------------------------------------------------------------------
39// Destructor
40//-------------------------------------------------------------------
41ClpConstraint::~ClpConstraint ()
42{
43  delete [] lastGradient_;
44
45}
46
47//----------------------------------------------------------------
48// Assignment operator
49//-------------------------------------------------------------------
50ClpConstraint &
51ClpConstraint::operator=(const ClpConstraint& rhs)
52{
53  if (this != &rhs) {
54    functionValue_ = rhs.functionValue_;
55    offset_ = rhs.offset_;
56    type_ = rhs.type_;
57    rowNumber_= rhs.rowNumber_;
58    delete [] lastGradient_;
59    lastGradient_ = NULL;
60  }
61  return *this;
62}
63// Constraint function value
64double 
65ClpConstraint::functionValue (const ClpSimplex * model,
66                              const double * solution,
67                              bool useScaling,
68                              bool refresh) const 
69{
70  double offset;
71  double value;
72  int n = model->numberColumns();
73  double * grad = new double [n];
74  gradient(model,solution,grad,value,offset,useScaling,refresh);
75  delete [] grad;
76  return value;
77}
78
Note: See TracBrowser for help on using the repository browser.