source: trunk/Clp/src/ClpConstraint.hpp

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

formatting

  • Property svn:keywords set to Id
File size: 3.2 KB
Line 
1/* $Id: ClpConstraint.hpp 2385 2019-01-06 19:43:06Z tkr $ */
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#ifndef ClpConstraint_H
7#define ClpConstraint_H
8
9//#############################################################################
10class ClpSimplex;
11class ClpModel;
12
13/** Constraint Abstract Base Class
14
15Abstract Base Class for describing a constraint or objective function
16
17*/
18class ClpConstraint {
19
20public:
21  ///@name Stuff
22  //@{
23
24  /** Fills gradient.  If Linear then solution may be NULL,
25         also returns true value of function and offset so we can use x not deltaX in constraint
26         If refresh is false then uses last solution
27         Uses model for scaling
28         Returns non-zero if gradient undefined at current solution
29     */
30  virtual int gradient(const ClpSimplex *model,
31    const double *solution,
32    double *gradient,
33    double &functionValue,
34    double &offset,
35    bool useScaling = false,
36    bool refresh = true) const = 0;
37  /// Constraint function value
38  virtual double functionValue(const ClpSimplex *model,
39    const double *solution,
40    bool useScaling = false,
41    bool refresh = true) const;
42  /// Resize constraint
43  virtual void resize(int newNumberColumns) = 0;
44  /// Delete columns in  constraint
45  virtual void deleteSome(int numberToDelete, const int *which) = 0;
46  /// Scale constraint
47  virtual void reallyScale(const double *columnScale) = 0;
48  /** Given a zeroed array sets nonlinear columns to 1.
49         Returns number of nonlinear columns
50      */
51  virtual int markNonlinear(char *which) const = 0;
52  /** Given a zeroed array sets possible nonzero coefficients to 1.
53         Returns number of nonzeros
54      */
55  virtual int markNonzero(char *which) const = 0;
56  //@}
57
58  ///@name Constructors and destructors
59  //@{
60  /// Default Constructor
61  ClpConstraint();
62
63  /// Copy constructor
64  ClpConstraint(const ClpConstraint &);
65
66  /// Assignment operator
67  ClpConstraint &operator=(const ClpConstraint &rhs);
68
69  /// Destructor
70  virtual ~ClpConstraint();
71
72  /// Clone
73  virtual ClpConstraint *clone() const = 0;
74
75  //@}
76
77  ///@name Other
78  //@{
79  /// Returns type, 0 linear, 1 nonlinear
80  inline int type()
81  {
82    return type_;
83  }
84  /// Row number (-1 is objective)
85  inline int rowNumber() const
86  {
87    return rowNumber_;
88  }
89
90  /// Number of possible coefficients in gradient
91  virtual int numberCoefficients() const = 0;
92
93  /// Stored constraint function value
94  inline double functionValue() const
95  {
96    return functionValue_;
97  }
98
99  /// Constraint offset
100  inline double offset() const
101  {
102    return offset_;
103  }
104  /// Say we have new primal solution - so may need to recompute
105  virtual void newXValues() {}
106  //@}
107
108  //---------------------------------------------------------------------------
109
110protected:
111  ///@name Protected member data
112  //@{
113  /// Gradient at last evaluation
114  mutable double *lastGradient_;
115  /// Value of non-linear part of constraint
116  mutable double functionValue_;
117  /// Value of offset for constraint
118  mutable double offset_;
119  /// Type of constraint - linear is 1
120  int type_;
121  /// Row number (-1 is objective)
122  int rowNumber_;
123  //@}
124};
125
126#endif
127
128/* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
129*/
Note: See TracBrowser for help on using the repository browser.