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

Last change on this file since 2385 was 2385, checked in by unxusr, 3 months ago

formatting

  • Property svn:keywords set to Id
File size: 2.2 KB
Line 
1/* $Id: ClpConstraint.cpp 2385 2019-01-06 19:43:06Z unxusr $ */
2// Copyright (C) 2007, 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#include "CoinPragma.hpp"
7#include "ClpSimplex.hpp"
8#include "ClpConstraint.hpp"
9
10//#############################################################################
11// Constructors / Destructor / Assignment
12//#############################################################################
13
14//-------------------------------------------------------------------
15// Default Constructor
16//-------------------------------------------------------------------
17ClpConstraint::ClpConstraint()
18  : lastGradient_(NULL)
19  , functionValue_(0.0)
20  , offset_(0.0)
21  , type_(-1)
22  , rowNumber_(-1)
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// Destructor
40//-------------------------------------------------------------------
41ClpConstraint::~ClpConstraint()
42{
43  delete[] lastGradient_;
44}
45
46//----------------------------------------------------------------
47// Assignment operator
48//-------------------------------------------------------------------
49ClpConstraint &
50ClpConstraint::operator=(const ClpConstraint &rhs)
51{
52  if (this != &rhs) {
53    functionValue_ = rhs.functionValue_;
54    offset_ = rhs.offset_;
55    type_ = rhs.type_;
56    rowNumber_ = rhs.rowNumber_;
57    delete[] lastGradient_;
58    lastGradient_ = NULL;
59  }
60  return *this;
61}
62// Constraint function value
63double
64ClpConstraint::functionValue(const ClpSimplex *model,
65  const double *solution,
66  bool useScaling,
67  bool refresh) const
68{
69  double offset;
70  double value;
71  int n = model->numberColumns();
72  double *grad = new double[n];
73  gradient(model, solution, grad, value, offset, useScaling, refresh);
74  delete[] grad;
75  return value;
76}
77
78/* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
79*/
Note: See TracBrowser for help on using the repository browser.