Changeset 192 for branches


Ignore:
Timestamp:
Aug 9, 2003 5:09:12 AM (16 years ago)
Author:
forrest
Message:

For Yiming

Location:
branches/pre
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/pre/ClpNonLinearCost.cpp

    r190 r192  
    578578    // get where in bound sequence
    579579    int iRange;
     580    int currentRange = whichRange_[iPivot];
    580581    double value = model_->solution(iPivot);
    581582    int start = start_[iPivot];
     
    595596    double & cost = model_->costAddress(iPivot);
    596597    whichRange_[iPivot]=iRange;
     598    if (iRange!=currentRange) {
     599      if (infeasible(iRange))
     600        numberInfeasibilities_++;
     601      if (infeasible(currentRange))
     602        numberInfeasibilities_--;
     603    }
    597604    lower = lower_[iRange];
    598605    upper = lower_[iRange+1];
     
    643650      double & cost = model_->costAddress(iPivot);
    644651      whichRange_[iPivot]=iRange;
     652      if (infeasible(iRange))
     653        numberInfeasibilities_++;
     654      if (infeasible(jRange))
     655        numberInfeasibilities_--;
    645656      lower = lower_[iRange];
    646657      upper = lower_[iRange+1];
     
    658669  // get where in bound sequence
    659670  int iRange;
     671  int currentRange = whichRange_[iPivot];
    660672  int start = start_[iPivot];
    661673  int end = start_[iPivot+1]-1;
     
    690702  assert(iRange<end);
    691703  whichRange_[iPivot]=iRange;
     704  if (iRange!=currentRange) {
     705    if (infeasible(iRange))
     706      numberInfeasibilities_++;
     707    if (infeasible(currentRange))
     708      numberInfeasibilities_--;
     709  }
    692710  double & lower = model_->lowerAddress(iPivot);
    693711  double & upper = model_->upperAddress(iPivot);
  • branches/pre/Test/MyMessageHandler.cpp

    r180 r192  
    1010
    1111#include "ClpSimplex.hpp"
     12#include "ClpNonLinearCost.hpp"
    1213#include "MyMessageHandler.hpp"
    1314#include "ClpMessage.hpp"
     
    9192{
    9293  if (currentSource()=="Clp") {
    93     if (currentMessage().externalNumber()==5) {
    94       // Are we feasible
    95       // We can pick up two ways - check same
    96       assert (model_->numberPrimalInfeasibilities()==
    97         intValue(1));
    98       if (!intValue(1)&&intValue(0)!=iterationNumber_) {
    99         iterationNumber_ = intValue(0);
     94    if (currentMessage().externalNumber()==102) {
     95      printf("There are %d primal infeasibilities\n",
     96             model_->nonLinearCost()->numberInfeasibilities());
     97      // Feasibility
     98      if (!model_->nonLinearCost()->numberInfeasibilities()) {
    10099        // Column solution
    101100        int numberColumns = model_->numberColumns();
    102101        const double * solution = model_->solutionRegion(1);
    103 
     102       
    104103        // Create vector to contain solution
    105104        StdVectorDouble feasibleExtremePoint;
    106 
     105       
     106        const double *objective = model_->objective();
     107        double objectiveValue = 0;
     108       
    107109        if (!model_->columnScale()) {
    108110          // No scaling
    109           for (int i=0;i<numberColumns;i++)
     111          for (int i=0;i<numberColumns;i++) {
    110112            feasibleExtremePoint.push_back(solution[i]);
     113            objectiveValue += solution[i]*objective[i];
     114          }
    111115        } else {
    112116          // scaled
    113117          const double * columnScale = model_->columnScale();
    114           for (int i=0;i<numberColumns;i++)
     118          for (int i=0;i<numberColumns;i++) {
    115119            feasibleExtremePoint.push_back(solution[i]*columnScale[i]);
     120            objectiveValue += solution[i]*objective[i]*columnScale[i];
     121          }
    116122        }
     123        std::cout << "Objective "<< objectiveValue << std::endl;
    117124        // Save solution
    118125        feasibleExtremePoints_.push_front(feasibleExtremePoint);
    119 
     126       
    120127        // Want maximum of 10 solutions, so if more then 10 get rid of oldest
    121128        int numExtremePointsSaved = feasibleExtremePoints_.size();
     
    127134
    128135      }
     136      return 0; // skip printing
    129137    }
    130138  }
  • branches/pre/Test/unitTest.cpp

    r186 r192  
    518518    CoinMpsIO m;
    519519    std::string fn = mpsDir+"exmip1";
     520    fn = "Test/subGams4";
    520521    m.readMps(fn.c_str(),"mps");
    521     ClpSimplex solution;
    522     solution.loadProblem(*m.getMatrixByCol(),m.getColLower(),m.getColUpper(),
     522    ClpSimplex model;
     523    model.loadProblem(*m.getMatrixByCol(),m.getColLower(),m.getColUpper(),
    523524                         m.getObjCoefficients(),
    524525                         m.getRowLower(),m.getRowUpper());
    525526    // Message handler
    526     MyMessageHandler messageHandler(&solution);
     527    MyMessageHandler messageHandler(&model);
    527528    std::cout<<"Testing derived message handler"<<std::endl;
    528     solution.passInMessageHandler(&messageHandler);
    529     solution.primal();
     529    model.passInMessageHandler(&messageHandler);
     530    model.messagesPointer()->setDetailMessage(1,102);
     531    model.setFactorizationFrequency(10);
     532    model.primal();
    530533
    531534    // Write saved solutions
    532     int nc = solution.getNumCols();
     535    int nc = model.getNumCols();
    533536    int s;
    534537    std::deque<StdVectorDouble> fep = messageHandler.getFeasibleExtremePoints();
     
    541544      }
    542545    }
    543     // solve again without scaling
     546    // Solve again without scaling
     547    // and maximize then minimize
    544548    messageHandler.clearFeasibleExtremePoints();
    545     solution.scaling(0);
    546     solution.allSlackBasis();
    547     solution.primal();
     549    model.scaling(0);
     550    model.setOptimizationDirection(-1);
     551    model.primal();
     552    model.setOptimizationDirection(1);
     553    model.primal();
    548554    fep = messageHandler.getFeasibleExtremePoints();
    549555    numSavedSolutions = fep.size();
Note: See TracChangeset for help on using the changeset viewer.