Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

ClpNonLinearCost.hpp

00001 // Copyright (C) 2002, International Business Machines
00002 // Corporation and others.  All Rights Reserved.
00003 #ifndef ClpNonLinearCost_H
00004 #define ClpNonLinearCost_H
00005 
00006 
00007 #include "CoinPragma.hpp"
00008 
00009 class ClpSimplex;
00010 class CoinIndexedVector;
00011 
00030 class ClpNonLinearCost  {
00031   
00032 public:
00033   
00034 public:
00035 
00038 
00039   ClpNonLinearCost();
00044   ClpNonLinearCost(ClpSimplex * model);
00050   ClpNonLinearCost(ClpSimplex * model,const int * starts,
00051                    const double * lower, const double * cost);
00053   ~ClpNonLinearCost();
00054   // Copy
00055   ClpNonLinearCost(const ClpNonLinearCost&);
00056   // Assignment
00057   ClpNonLinearCost& operator=(const ClpNonLinearCost&);
00059      
00060 
00067   void checkInfeasibilities(double oldTolerance=0.0);
00071   void checkInfeasibilities(int numberInArray, const int * index);
00078   void checkChanged(int numberInArray, CoinIndexedVector * update);
00085   void goThru(int numberInArray, double multiplier,
00086               const int * index, const double * work,
00087               double * rhs);
00090   void goBack(int numberInArray, const int * index, 
00091               double * rhs);
00097   void goBackAll(const CoinIndexedVector * update);
00099   void zapCosts();
00103   double setOne(int sequence, double solutionValue);
00107   int setOneOutgoing(int sequence, double &solutionValue);
00109   double nearest(int sequence, double solutionValue);
00113   inline double changeInCost(int sequence, double alpha) const
00114   {
00115     int iRange = whichRange_[sequence]+offset_[sequence];
00116     if (alpha>0.0)
00117       return cost_[iRange]-cost_[iRange-1];
00118     else
00119       return cost_[iRange]-cost_[iRange+1];
00120   }
00121   inline double changeUpInCost(int sequence) const
00122   {
00123     int iRange = whichRange_[sequence]+offset_[sequence];
00124     if (iRange+1!=start_[sequence+1]&&!infeasible(iRange+1))
00125       return cost_[iRange]-cost_[iRange+1];
00126     else
00127       return -1.0e100;
00128   }
00129   inline double changeDownInCost(int sequence) const
00130   {
00131     int iRange = whichRange_[sequence]+offset_[sequence];
00132     if (iRange!=start_[sequence]&&!infeasible(iRange-1))
00133       return cost_[iRange]-cost_[iRange-1];
00134     else
00135       return 1.0e100;
00136   }
00138   inline double changeInCost(int sequence, double alpha, double &rhs)
00139   {
00140     int iRange = whichRange_[sequence]+offset_[sequence];
00141     if (alpha>0.0) {
00142       assert(iRange-1>=start_[sequence]);
00143       offset_[sequence]--;
00144       rhs += lower_[iRange]-lower_[iRange-1];
00145       return alpha*(cost_[iRange]-cost_[iRange-1]);
00146     } else {
00147       assert(iRange+1<start_[sequence+1]-1);
00148       offset_[sequence]++;
00149       rhs += lower_[iRange+2]-lower_[iRange+1];
00150       return alpha*(cost_[iRange]-cost_[iRange+1]);
00151     }
00152   }
00154   inline double lower(int sequence) const
00155   { return lower_[whichRange_[sequence]+offset_[sequence]];};
00157   inline double upper(int sequence) const
00158   { return lower_[whichRange_[sequence]+offset_[sequence]+1];};
00160   inline double cost(int sequence) const
00161   { return cost_[whichRange_[sequence]+offset_[sequence]];};
00163 
00164 
00167 
00168   inline int numberInfeasibilities() const
00169   {return numberInfeasibilities_;};
00171   inline double changeInCost() const
00172   {return changeCost_;};
00174   inline double feasibleCost() const
00175   {return feasibleCost_;};
00177   double feasibleReportCost() const;
00179   inline double sumInfeasibilities() const
00180   {return sumInfeasibilities_;};
00182   inline double largestInfeasibility() const
00183   {return largestInfeasibility_;};
00185   inline double averageTheta() const
00186   {return averageTheta_;};
00187   inline void setAverageTheta(double value)
00188   {averageTheta_=value;};
00189   inline void setChangeInCost(double value) 
00190   {changeCost_ = value;};
00192   inline bool lookBothWays() const
00193   { return bothWays_;};
00195 
00196   inline bool infeasible(int i) const {
00197     return ((infeasible_[i>>5]>>(i&31))&1)!=0;
00198   }
00199   inline void setInfeasible(int i,bool trueFalse) {
00200     unsigned int & value = infeasible_[i>>5];
00201     int bit = i&31;
00202     if (trueFalse)
00203       value |= (1<<bit);
00204     else
00205       value &= ~(1<<bit);
00206   }
00208     
00209 private:
00212 
00213   double changeCost_;
00215   double feasibleCost_;
00217   double largestInfeasibility_;
00219   double sumInfeasibilities_;
00221   double averageTheta_;
00223   int numberRows_;
00225   int numberColumns_;
00227   int * start_;
00229   int * whichRange_;
00231   int * offset_;
00235   double * lower_;
00237   double * cost_;
00239   ClpSimplex * model_;
00240   // Array to say which regions are infeasible
00241   unsigned int * infeasible_;
00243   int numberInfeasibilities_;
00245   bool convex_;
00247   bool bothWays_;
00249 };
00250 
00251 #endif

Generated on Wed Dec 3 14:37:28 2003 for CLP by doxygen 1.3.5