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

For Yiming

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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  }
Note: See TracChangeset for help on using the changeset viewer.