- Timestamp:
- Aug 9, 2003 5:09:12 AM (16 years ago)
- Location:
- branches/pre
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/pre/ClpNonLinearCost.cpp
r190 r192 578 578 // get where in bound sequence 579 579 int iRange; 580 int currentRange = whichRange_[iPivot]; 580 581 double value = model_->solution(iPivot); 581 582 int start = start_[iPivot]; … … 595 596 double & cost = model_->costAddress(iPivot); 596 597 whichRange_[iPivot]=iRange; 598 if (iRange!=currentRange) { 599 if (infeasible(iRange)) 600 numberInfeasibilities_++; 601 if (infeasible(currentRange)) 602 numberInfeasibilities_--; 603 } 597 604 lower = lower_[iRange]; 598 605 upper = lower_[iRange+1]; … … 643 650 double & cost = model_->costAddress(iPivot); 644 651 whichRange_[iPivot]=iRange; 652 if (infeasible(iRange)) 653 numberInfeasibilities_++; 654 if (infeasible(jRange)) 655 numberInfeasibilities_--; 645 656 lower = lower_[iRange]; 646 657 upper = lower_[iRange+1]; … … 658 669 // get where in bound sequence 659 670 int iRange; 671 int currentRange = whichRange_[iPivot]; 660 672 int start = start_[iPivot]; 661 673 int end = start_[iPivot+1]-1; … … 690 702 assert(iRange<end); 691 703 whichRange_[iPivot]=iRange; 704 if (iRange!=currentRange) { 705 if (infeasible(iRange)) 706 numberInfeasibilities_++; 707 if (infeasible(currentRange)) 708 numberInfeasibilities_--; 709 } 692 710 double & lower = model_->lowerAddress(iPivot); 693 711 double & upper = model_->upperAddress(iPivot); -
branches/pre/Test/MyMessageHandler.cpp
r180 r192 10 10 11 11 #include "ClpSimplex.hpp" 12 #include "ClpNonLinearCost.hpp" 12 13 #include "MyMessageHandler.hpp" 13 14 #include "ClpMessage.hpp" … … 91 92 { 92 93 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()) { 100 99 // Column solution 101 100 int numberColumns = model_->numberColumns(); 102 101 const double * solution = model_->solutionRegion(1); 103 102 104 103 // Create vector to contain solution 105 104 StdVectorDouble feasibleExtremePoint; 106 105 106 const double *objective = model_->objective(); 107 double objectiveValue = 0; 108 107 109 if (!model_->columnScale()) { 108 110 // No scaling 109 for (int i=0;i<numberColumns;i++) 111 for (int i=0;i<numberColumns;i++) { 110 112 feasibleExtremePoint.push_back(solution[i]); 113 objectiveValue += solution[i]*objective[i]; 114 } 111 115 } else { 112 116 // scaled 113 117 const double * columnScale = model_->columnScale(); 114 for (int i=0;i<numberColumns;i++) 118 for (int i=0;i<numberColumns;i++) { 115 119 feasibleExtremePoint.push_back(solution[i]*columnScale[i]); 120 objectiveValue += solution[i]*objective[i]*columnScale[i]; 121 } 116 122 } 123 std::cout << "Objective "<< objectiveValue << std::endl; 117 124 // Save solution 118 125 feasibleExtremePoints_.push_front(feasibleExtremePoint); 119 126 120 127 // Want maximum of 10 solutions, so if more then 10 get rid of oldest 121 128 int numExtremePointsSaved = feasibleExtremePoints_.size(); … … 127 134 128 135 } 136 return 0; // skip printing 129 137 } 130 138 } -
branches/pre/Test/unitTest.cpp
r186 r192 518 518 CoinMpsIO m; 519 519 std::string fn = mpsDir+"exmip1"; 520 fn = "Test/subGams4"; 520 521 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(), 523 524 m.getObjCoefficients(), 524 525 m.getRowLower(),m.getRowUpper()); 525 526 // Message handler 526 MyMessageHandler messageHandler(& solution);527 MyMessageHandler messageHandler(&model); 527 528 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(); 530 533 531 534 // Write saved solutions 532 int nc = solution.getNumCols();535 int nc = model.getNumCols(); 533 536 int s; 534 537 std::deque<StdVectorDouble> fep = messageHandler.getFeasibleExtremePoints(); … … 541 544 } 542 545 } 543 // solve again without scaling 546 // Solve again without scaling 547 // and maximize then minimize 544 548 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(); 548 554 fep = messageHandler.getFeasibleExtremePoints(); 549 555 numSavedSolutions = fep.size();
Note: See TracChangeset
for help on using the changeset viewer.