source: releases/1.8.0/Clp/src/ClpConstraint.hpp @ 2257

Last change on this file since 2257 was 1055, checked in by forrest, 13 years ago

out };

File size: 3.1 KB
Line 
1// Copyright (C) 2007, International Business Machines
2// Corporation and others.  All Rights Reserved.
3#ifndef ClpConstraint_H
4#define ClpConstraint_H
5
6
7//#############################################################################
8class ClpSimplex;
9class ClpModel;
10
11/** Constraint Abstract Base Class
12
13Abstract Base Class for describing a constraint or objective function
14
15*/
16class ClpConstraint  {
17 
18public:
19 
20  ///@name Stuff
21  //@{
22 
23  /** Fills gradient.  If Linear then solution may be NULL,
24      also returns true value of function and offset so we can use x not deltaX in constraint
25      If refresh is false then uses last solution
26      Uses model for scaling
27      Returns non-zero if gradient undefined at current solution
28  */
29  virtual int gradient(const ClpSimplex * model,
30                       const double * solution,
31                       double * gradient,
32                       double & functionValue ,
33                       double & offset,
34                       bool useScaling=false,
35                       bool refresh=true) const =0;
36  /// Constraint function value
37  virtual double functionValue (const ClpSimplex * model,
38                        const double * solution,
39                        bool useScaling=false,
40                        bool refresh=true) const ;
41  /// Resize constraint
42  virtual void resize(int newNumberColumns) = 0; 
43  /// Delete columns in  constraint
44  virtual void deleteSome(int numberToDelete, const int * which) = 0; 
45  /// Scale constraint
46  virtual void reallyScale(const double * columnScale) =0;
47  /** Given a zeroed array sets nonlinear columns to 1.
48      Returns number of nonlinear columns
49   */
50  virtual int markNonlinear(char * which) const = 0;
51  /** Given a zeroed array sets possible nonzero coefficients to 1.
52      Returns number of nonzeros
53   */
54  virtual int markNonzero(char * which) const = 0;
55  //@}
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  { return type_;}
82  /// Row number (-1 is objective)
83  inline int rowNumber() const
84  {return rowNumber_;}
85 
86  /// Number of possible coefficients in gradient
87  virtual int numberCoefficients() const = 0;
88 
89  /// Stored constraint function value
90  inline double functionValue () const
91  { return functionValue_;}
92
93  /// Constraint offset
94  inline double offset () const
95  { return offset_;}
96  /// Say we have new primal solution - so may need to recompute
97  virtual void newXValues() {}
98  //@}
99
100  //---------------------------------------------------------------------------
101 
102protected:
103  ///@name Protected member data
104  //@{
105  /// Gradient at last evaluation
106  mutable double * lastGradient_;
107  /// Value of non-linear part of constraint
108  mutable double functionValue_;
109  /// Value of offset for constraint
110  mutable double offset_;
111  /// Type of constraint - linear is 1
112  int type_;
113  /// Row number (-1 is objective)
114  int rowNumber_;
115  //@}
116};
117
118#endif
Note: See TracBrowser for help on using the repository browser.