source: trunk/Clp/src/ClpQuadraticObjective.hpp @ 2470

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

formatting

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.7 KB
Line 
1/* $Id: ClpQuadraticObjective.hpp 2385 2019-01-06 19:43:06Z stefan $ */
2// Copyright (C) 2003, 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 ClpQuadraticObjective_H
7#define ClpQuadraticObjective_H
8
9#include "ClpObjective.hpp"
10#include "CoinPackedMatrix.hpp"
11
12//#############################################################################
13
14/** Quadratic Objective Class
15
16*/
17
18class ClpQuadraticObjective : public ClpObjective {
19
20public:
21  ///@name Stuff
22  //@{
23
24  /** Returns gradient.  If Quadratic then solution may be NULL,
25         also returns an offset (to be added to current one)
26         If refresh is false then uses last solution
27         Uses model for scaling
28         includeLinear 0 - no, 1 as is, 2 as feasible
29     */
30  virtual double *gradient(const ClpSimplex *model,
31    const double *solution, double &offset, bool refresh,
32    int includeLinear = 2);
33  /// Resize objective
34  /** Returns reduced gradient.Returns an offset (to be added to current one).
35     */
36  virtual double reducedGradient(ClpSimplex *model, double *region,
37    bool useFeasibleCosts);
38  /** Returns step length which gives minimum of objective for
39         solution + theta * change vector up to maximum theta.
40
41         arrays are numberColumns+numberRows
42         Also sets current objective, predicted and at maximumTheta
43     */
44  virtual double stepLength(ClpSimplex *model,
45    const double *solution,
46    const double *change,
47    double maximumTheta,
48    double &currentObj,
49    double &predictedObj,
50    double &thetaObj);
51  /// Return objective value (without any ClpModel offset) (model may be NULL)
52  virtual double objectiveValue(const ClpSimplex *model, const double *solution) const;
53  virtual void resize(int newNumberColumns);
54  /// Delete columns in  objective
55  virtual void deleteSome(int numberToDelete, const int *which);
56  /// Scale objective
57  virtual void reallyScale(const double *columnScale);
58  /** Given a zeroed array sets nonlinear columns to 1.
59         Returns number of nonlinear columns
60      */
61  virtual int markNonlinear(char *which);
62
63  //@}
64
65  ///@name Constructors and destructors
66  //@{
67  /// Default Constructor
68  ClpQuadraticObjective();
69
70  /// Constructor from objective
71  ClpQuadraticObjective(const double *linearObjective, int numberColumns,
72    const CoinBigIndex *start,
73    const int *column, const double *element,
74    int numberExtendedColumns_ = -1);
75
76  /** Copy constructor .
77         If type is -1 then make sure half symmetric,
78         if +1 then make sure full
79     */
80  ClpQuadraticObjective(const ClpQuadraticObjective &rhs, int type = 0);
81  /** Subset constructor.  Duplicates are allowed
82         and order is as given.
83     */
84  ClpQuadraticObjective(const ClpQuadraticObjective &rhs, int numberColumns,
85    const int *whichColumns);
86
87  /// Assignment operator
88  ClpQuadraticObjective &operator=(const ClpQuadraticObjective &rhs);
89
90  /// Destructor
91  virtual ~ClpQuadraticObjective();
92
93  /// Clone
94  virtual ClpObjective *clone() const;
95  /** Subset clone.  Duplicates are allowed
96         and order is as given.
97     */
98  virtual ClpObjective *subsetClone(int numberColumns,
99    const int *whichColumns) const;
100
101  /** Load up quadratic objective.  This is stored as a CoinPackedMatrix */
102  void loadQuadraticObjective(const int numberColumns,
103    const CoinBigIndex *start,
104    const int *column, const double *element,
105    int numberExtendedColumns = -1);
106  void loadQuadraticObjective(const CoinPackedMatrix &matrix);
107  /// Get rid of quadratic objective
108  void deleteQuadraticObjective();
109  //@}
110  ///@name Gets and sets
111  //@{
112  /// Quadratic objective
113  inline CoinPackedMatrix *quadraticObjective() const
114  {
115    return quadraticObjective_;
116  }
117  /// Linear objective
118  inline double *linearObjective() const
119  {
120    return objective_;
121  }
122  /// Length of linear objective which could be bigger
123  inline int numberExtendedColumns() const
124  {
125    return numberExtendedColumns_;
126  }
127  /// Number of columns in quadratic objective
128  inline int numberColumns() const
129  {
130    return numberColumns_;
131  }
132  /// If a full or half matrix
133  inline bool fullMatrix() const
134  {
135    return fullMatrix_;
136  }
137  //@}
138
139  //---------------------------------------------------------------------------
140
141private:
142  ///@name Private member data
143  /// Quadratic objective
144  CoinPackedMatrix *quadraticObjective_;
145  /// Objective
146  double *objective_;
147  /// Gradient
148  double *gradient_;
149  /// Useful to have number of columns about
150  int numberColumns_;
151  /// Also length of linear objective which could be bigger
152  int numberExtendedColumns_;
153  /// True if full symmetric matrix, false if half
154  bool fullMatrix_;
155  //@}
156};
157
158#endif
159
160/* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
161*/
Note: See TracBrowser for help on using the repository browser.