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

/home/coinadmin/Update/COIN/Clp/include/ClpNonLinearCost.hpp

Go to the documentation of this file.
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);
00106   void setOne(int sequence, double solutionValue, double lowerValue, double upperValue,
00107               double costValue=0.0);
00111   int setOneOutgoing(int sequence, double &solutionValue);
00113   double nearest(int sequence, double solutionValue);
00117   inline double changeInCost(int sequence, double alpha) const
00118   {
00119     int iRange = whichRange_[sequence]+offset_[sequence];
00120     if (alpha>0.0)
00121       return cost_[iRange]-cost_[iRange-1];
00122     else
00123       return cost_[iRange]-cost_[iRange+1];
00124   }
00125   inline double changeUpInCost(int sequence) const
00126   {
00127     int iRange = whichRange_[sequence]+offset_[sequence];
00128     if (iRange+1!=start_[sequence+1]&&!infeasible(iRange+1))
00129       return cost_[iRange]-cost_[iRange+1];
00130     else
00131       return -1.0e100;
00132   }
00133   inline double changeDownInCost(int sequence) const
00134   {
00135     int iRange = whichRange_[sequence]+offset_[sequence];
00136     if (iRange!=start_[sequence]&&!infeasible(iRange-1))
00137       return cost_[iRange]-cost_[iRange-1];
00138     else
00139       return 1.0e100;
00140   }
00142   inline double changeInCost(int sequence, double alpha, double &rhs)
00143   {
00144     int iRange = whichRange_[sequence]+offset_[sequence];
00145     if (alpha>0.0) {
00146       assert(iRange-1>=start_[sequence]);
00147       offset_[sequence]--;
00148       rhs += lower_[iRange]-lower_[iRange-1];
00149       return alpha*(cost_[iRange]-cost_[iRange-1]);
00150     } else {
00151       assert(iRange+1<start_[sequence+1]-1);
00152       offset_[sequence]++;
00153       rhs += lower_[iRange+2]-lower_[iRange+1];
00154       return alpha*(cost_[iRange]-cost_[iRange+1]);
00155     }
00156   }
00158   inline double lower(int sequence) const
00159   { return lower_[whichRange_[sequence]+offset_[sequence]];};
00161   inline double upper(int sequence) const
00162   { return lower_[whichRange_[sequence]+offset_[sequence]+1];};
00164   inline double cost(int sequence) const
00165   { return cost_[whichRange_[sequence]+offset_[sequence]];};
00167 
00168 
00171 
00172   inline int numberInfeasibilities() const
00173   {return numberInfeasibilities_;};
00175   inline double changeInCost() const
00176   {return changeCost_;};
00178   inline double feasibleCost() const
00179   {return feasibleCost_;};
00181   double feasibleReportCost() const;
00183   inline double sumInfeasibilities() const
00184   {return sumInfeasibilities_;};
00186   inline double largestInfeasibility() const
00187   {return largestInfeasibility_;};
00189   inline double averageTheta() const
00190   {return averageTheta_;};
00191   inline void setAverageTheta(double value)
00192   {averageTheta_=value;};
00193   inline void setChangeInCost(double value) 
00194   {changeCost_ = value;};
00196   inline bool lookBothWays() const
00197   { return bothWays_;};
00199 
00200   inline bool infeasible(int i) const {
00201     return ((infeasible_[i>>5]>>(i&31))&1)!=0;
00202   }
00203   inline void setInfeasible(int i,bool trueFalse) {
00204     unsigned int & value = infeasible_[i>>5];
00205     int bit = i&31;
00206     if (trueFalse)
00207       value |= (1<<bit);
00208     else
00209       value &= ~(1<<bit);
00210   }
00212     
00213 private:
00216 
00217   double changeCost_;
00219   double feasibleCost_;
00221   double largestInfeasibility_;
00223   double sumInfeasibilities_;
00225   double averageTheta_;
00227   int numberRows_;
00229   int numberColumns_;
00231   int * start_;
00233   int * whichRange_;
00235   int * offset_;
00239   double * lower_;
00241   double * cost_;
00243   ClpSimplex * model_;
00244   // Array to say which regions are infeasible
00245   unsigned int * infeasible_;
00247   int numberInfeasibilities_;
00249   bool convex_;
00251   bool bothWays_;
00253 };
00254 
00255 #endif

Generated on Fri Aug 6 02:01:32 2004 by doxygen1.3-rc2