source: trunk/Clp/src/ClpConstraint.cpp @ 1525

Last change on this file since 1525 was 1525, checked in by mjs, 10 years ago

Formatted .cpp, .hpp, .c, .h files with "astyle -A4 -p". This matches the formatting used in the grand CBC reorganization.

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