Changeset 193


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

For Yiming

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/ClpNonLinearCost.cpp

    r170 r193  
    593593    // get where in bound sequence
    594594    int iRange;
     595    int currentRange = whichRange_[iPivot];
    595596    double value = model_->solution(iPivot);
    596597    int start = start_[iPivot];
     
    610611    double & cost = model_->costAddress(iPivot);
    611612    whichRange_[iPivot]=iRange;
     613    if (iRange!=currentRange) {
     614      if (infeasible(iRange))
     615        numberInfeasibilities_++;
     616      if (infeasible(currentRange))
     617        numberInfeasibilities_--;
     618    }
    612619    lower = lower_[iRange];
    613620    upper = lower_[iRange+1];
     
    658665      double & cost = model_->costAddress(iPivot);
    659666      whichRange_[iPivot]=iRange;
     667      if (infeasible(iRange))
     668        numberInfeasibilities_++;
     669      if (infeasible(jRange))
     670        numberInfeasibilities_--;
    660671      lower = lower_[iRange];
    661672      upper = lower_[iRange+1];
     
    673684  // get where in bound sequence
    674685  int iRange;
     686  int currentRange = whichRange_[iPivot];
    675687  int start = start_[iPivot];
    676688  int end = start_[iPivot+1]-1;
     
    700712  assert(iRange<end);
    701713  whichRange_[iPivot]=iRange;
     714  if (iRange!=currentRange) {
     715    if (infeasible(iRange))
     716      numberInfeasibilities_++;
     717    if (infeasible(currentRange))
     718      numberInfeasibilities_--;
     719  }
    702720  double & lower = model_->lowerAddress(iPivot);
    703721  double & upper = model_->upperAddress(iPivot);
  • trunk/Test/MyMessageHandler.cpp

    r176 r193  
    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();
    122129        if ( numExtremePointsSaved>=10 ) {
    123130          feasibleExtremePoints_.pop_back();
    124           assert( feasibleExtremePoints_.size() == numExtremePointsSaved-1 );
     131          assert( feasibleExtremePoints_.size() ==
     132                  (unsigned int) numExtremePointsSaved-1 );
    125133        };
    126134
    127135      }
     136      return 0; // skip printing
    128137    }
    129138  }
  • trunk/Test/unitTest.cpp

    r175 r193  
    539539    std::string fn = mpsDir+"exmip1";
    540540    m.readMps(fn.c_str(),"mps");
    541     ClpSimplex solution;
    542     solution.loadProblem(*m.getMatrixByCol(),m.getColLower(),m.getColUpper(),
     541    ClpSimplex model;
     542    model.loadProblem(*m.getMatrixByCol(),m.getColLower(),m.getColUpper(),
    543543                         m.getObjCoefficients(),
    544544                         m.getRowLower(),m.getRowUpper());
    545545    // Message handler
    546     MyMessageHandler messageHandler(&solution);
     546    MyMessageHandler messageHandler(&model);
    547547    std::cout<<"Testing derived message handler"<<std::endl;
    548     solution.passInMessageHandler(&messageHandler);
    549     solution.primal();
     548    model.passInMessageHandler(&messageHandler);
     549    // We will be using message 102 so make it more active
     550    model.messagesPointer()->setDetailMessage(1,102);
     551    model.primal();
    550552
    551553    // Write saved solutions
    552     int nc = solution.getNumCols();
     554    int nc = model.getNumCols();
    553555    int s;
    554556    std::deque<StdVectorDouble> fep = messageHandler.getFeasibleExtremePoints();
     
    561563      }
    562564    }
    563     // solve again without scaling
     565    // Solve again without scaling
     566    // and maximize then minimize
    564567    messageHandler.clearFeasibleExtremePoints();
    565     solution.scaling(0);
    566     solution.allSlackBasis();
    567     solution.primal();
     568    model.scaling(0);
     569    model.setOptimizationDirection(-1);
     570    model.primal();
     571    model.setOptimizationDirection(1);
     572    model.primal();
    568573    fep = messageHandler.getFeasibleExtremePoints();
    569574    numSavedSolutions = fep.size();
Note: See TracChangeset for help on using the changeset viewer.