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

Last change on this file since 1502 was 1502, checked in by forrest, 10 years ago

moving sandbox stuff to trunk

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 5.2 KB
Line 
1/* $Id: ClpQuadraticObjective.hpp 1502 2010-01-29 14:25:07Z forrest $ */
2// Copyright (C) 2003, International Business Machines
3// Corporation and others.  All Rights Reserved.
4#ifndef ClpQuadraticObjective_H
5#define ClpQuadraticObjective_H
6
7#include "ClpObjective.hpp"
8#include "CoinPackedMatrix.hpp"
9
10//#############################################################################
11
12/** Quadratic Objective Class
13
14*/
15
16class ClpQuadraticObjective : public ClpObjective {
17
18public:
19
20    ///@name Stuff
21    //@{
22
23    /** Returns gradient.  If Quadratic then solution may be NULL,
24        also returns an offset (to be added to current one)
25        If refresh is false then uses last solution
26        Uses model for scaling
27        includeLinear 0 - no, 1 as is, 2 as feasible
28    */
29    virtual double * gradient(const ClpSimplex * model,
30                              const double * solution, double & offset, bool refresh,
31                              int includeLinear = 2);
32    /// Resize objective
33    /** Returns reduced gradient.Returns an offset (to be added to current one).
34    */
35    virtual double reducedGradient(ClpSimplex * model, double * region,
36                                   bool useFeasibleCosts);
37    /** Returns step length which gives minimum of objective for
38        solution + theta * change vector up to maximum theta.
39
40        arrays are numberColumns+numberRows
41        Also sets current objective, predicted and at maximumTheta
42    */
43    virtual double stepLength(ClpSimplex * model,
44                              const double * solution,
45                              const double * change,
46                              double maximumTheta,
47                              double & currentObj,
48                              double & predictedObj,
49                              double & thetaObj);
50    /// Return objective value (without any ClpModel offset) (model may be NULL)
51    virtual double objectiveValue(const ClpSimplex * model, const double * solution) const ;
52    virtual void resize(int newNumberColumns) ;
53    /// Delete columns in  objective
54    virtual void deleteSome(int numberToDelete, const int * which) ;
55    /// Scale objective
56    virtual void reallyScale(const double * columnScale) ;
57    /** Given a zeroed array sets nonlinear columns to 1.
58        Returns number of nonlinear columns
59     */
60    virtual int markNonlinear(char * which);
61
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        return quadraticObjective_;
115    }
116    /// Linear objective
117    inline double * linearObjective() const     {
118        return objective_;
119    }
120    /// Length of linear objective which could be bigger
121    inline int numberExtendedColumns() const {
122        return numberExtendedColumns_;
123    }
124    /// Number of columns in quadratic objective
125    inline int numberColumns() const {
126        return numberColumns_;
127    }
128    /// If a full or half matrix
129    inline bool fullMatrix() const {
130        return fullMatrix_;
131    }
132    //@}
133
134    //---------------------------------------------------------------------------
135
136private:
137    ///@name Private member data
138    /// Quadratic objective
139    CoinPackedMatrix * quadraticObjective_;
140    /// Objective
141    double * objective_;
142    /// Gradient
143    double * gradient_;
144    /// Useful to have number of columns about
145    int numberColumns_;
146    /// Also length of linear objective which could be bigger
147    int numberExtendedColumns_;
148    /// True if full symmetric matrix, false if half
149    bool fullMatrix_;
150    //@}
151};
152
153#endif
Note: See TracBrowser for help on using the repository browser.