⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fairsa.cpp

📁 随机需求VRP(VRPSD)
💻 CPP
字号:
#include "Problem.h"
#include "Solution.h"
#include "fairSAControl.h"
#include "Random.h"
#include "farthestInsertion.h"
#include "SAorOpt.h"


#include <fstream.h>
#include <iostream.h>
#include <math.h>
using namespace std;

int main( int argc, char** argv ) {

  //Create a control object from the command line arguments.
  fairSAControl control( argc, argv );

  //Create a Random object.
  Random* rnd =  new Random((unsigned) control.getSeed());;

  //Initialize the problem instance, using input file stream and input data given by control.
  Problem *problem = new Problem( control );


  //Run a number of tries, control knows how many tries there should be done
  while( control.triesLeft() ) {
    //Tell control we are starting a new try.
    control.beginTry();    
    
    //Initialize starting solution.
    Solution currentSolution(rnd, control, problem );
    //    currentSolution.initializeRandomSolution();

    farthestInsertion(currentSolution);
    //for(int i=0; i<problem->numberOfCustomers; i++) currentSolution[i] = i;
    //currentSolution.printOn(cout);//////////////
    
    control.setCurrentCost( currentSolution.computeExpectedCost());
    //    currentSolution.printOn(cout); /////////
    //    cout << "expectedCostFarthestInsertion = " << currentSolution.expectedCost << endl;//////
    
    
    //orOpt local search may improve currentSolution.
    SAorOpt(rnd,control, currentSolution);
    
    //cout << "expectedCostAfterOrOpt = " 
    //cout << currentSolution.expectedCost << endl;//////////
    control.endTry();
    currentSolution.printOn(control.getOutputStream());
  }
  
  /*  //Initialize thresholds vector.
      vector<int> thresholds(problem->numberOfCustomers, -1);
      currentSolution.computeExpectedCostAndThresholds(thresholds);
      currentSolution.printOn(cout, thresholds);  
  */
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -