📄 control.h
字号:
#ifndef CONTROL_H
#define CONTROL_H
/*
This is VRPSD's control class. All metaheuristics
implementations should use it for their command line options and
output.
*/
#include <string>
#include <map>
#include <iostream>
#include <fstream>
using namespace std;
#include "Timer.h"
class Control {
protected:
map< string, string > parameters;
Timer timer;
int nrTry, maxTry;
double bestCost;
double bestTime;
double currentCost;
int seed;
double timeLimit;
int useProxy;
int capacity;
bool flagCapacity;
bool flagMatrix;
int iterations;
ostream *os;
istream *is;
public:
Control( int, char** ); // construct a control object, given a set of command line options
Control();
~Control();
int nrCost, nrDeltaCost;
int nrLen, nrDeltaLen;
void incrementIterations() {iterations++;} // increment the counter of iterations
int getIterations() { return iterations; } // get the int contents of iterations counter
bool parameterExists( string ); // check whether a certain parameter is given at the command line
int getIntParameter( string ); // get the integer contents of a parameter
double getDoubleParameter( string ); // get the double contents of a parameter
string getStringParameter( string ); // get the string contents of a parameter
int getSeed() { return seed; } // get the seed for the random number generator
void resetTime(); // reset the timer
double getTime(); // get the timer's time
bool timeLeft() { return ( getTime() < timeLimit ); }; // check whether our run has time left
void beginTry(); // begin a run
void endTry(); // end a run
void setCurrentCost( double );
// tell control the current cost of your solution, and counters.
istream& getInputStream() { return *is; } // get the input stream for constructing problems
ostream& getOutputStream() { return *os; } // get the output stream used for writing output data
int getNumberOfTries() { return maxTry; } // get the max number of tries
bool usingProxy();
int getCapacity();
bool getFlagMatrix(){return flagMatrix;}
bool capacityExists();
bool triesLeft() { return ( nrTry < maxTry ); } // check whether more tries need to be run
double getTimeLimit() { return timeLimit; } // get the time limit of one run
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -