diff --git a/optimizer/Pilot/Pilot.h b/optimizer/Pilot/Pilot.h index 7c36730e3cff3f494b5b6d1d300c8df052a810fb..2663b4b9cd68e849393f57beee4cba8313752047 100644 --- a/optimizer/Pilot/Pilot.h +++ b/optimizer/Pilot/Pilot.h @@ -14,7 +14,6 @@ #include "Util/Types.h" #include "Util/CmdArguments.h" -#include "Util/InputFileParser.h" #include "Util/OptPilotException.h" #include "Pilot/Poller.h" @@ -71,7 +70,6 @@ * @see Worker * @see Optimizer * - * @tparam Input_t type of the input file parser * @tparam Opt_t type of the optimizer * @tparam Sim_t type of the simulation * @tparam SolPropagationGraph_t strategy to distribute solution between @@ -79,8 +77,7 @@ * @tparam Comm_t comm splitter strategy */ template < - class Input_t - , class Opt_t + class Opt_t , class Sim_t , class SolPropagationGraph_t , class Comm_t diff --git a/optimizer/Tests/CMakeLists.txt b/optimizer/Tests/CMakeLists.txt index 50ac3388845c0856544d57dca28a68bd56be8b87..dd790fa266d0e3349f86ec3bd66c9f788547cdeb 100644 --- a/optimizer/Tests/CMakeLists.txt +++ b/optimizer/Tests/CMakeLists.txt @@ -93,18 +93,8 @@ set (SDDSParserTest_SRC ${SDDSPARSER_SRC} ) -set (OpalInputFileParserTest_SRC - ${OPT_PILOT_SOURCE_DIR}/Expression/SumErrSq.cpp - ${OPT_PILOT_SOURCE_DIR}/Expression/FromFile.cpp - ${SDDSPARSER_SRC} - ${OPT_PILOT_SOURCE_DIR}/Util/CommentAnnotatedInputFileParser.cpp - ${OPT_PILOT_SOURCE_DIR}/Expression/Parser/expression.cpp - ${OPT_PILOT_SOURCE_DIR}/Expression/Parser/evaluator.cpp -) - set (PILOT_TESTS MPIHelperTest - OpalInputFileParserTest SDDSParserTest ManagedIDsTest IndividualTest diff --git a/optimizer/Tests/OpalInputFileParserTest.cpp b/optimizer/Tests/OpalInputFileParserTest.cpp deleted file mode 100644 index c3ce0474300820e725ec2ec4ed1e09ff88fb0ec8..0000000000000000000000000000000000000000 --- a/optimizer/Tests/OpalInputFileParserTest.cpp +++ /dev/null @@ -1,93 +0,0 @@ -#include "Util/OpalInputFileParser.h" -#include "Util/Types.h" -#include "gtest/gtest.h" - -#include "Expression/Parser/function.hpp" - -#include "boost/smart_ptr.hpp" -#include "boost/tuple/tuple.hpp" - -namespace { - - // The fixture for testing class Foo. - class InputFileParserTest : public ::testing::Test { - protected: - - InputFileParserTest() { - // You can do set-up work for each test here. - functionDictionary_t funcs; - opalp.reset(new OpalInputFileParser("resources/test.in", funcs)); - } - - virtual ~InputFileParserTest() { - // You can do clean-up work that doesn't throw exceptions here. - //delete opalp; - } - - // If the constructor and destructor are not enough for setting up - // and cleaning up each test, you can define the following methods: - - virtual void SetUp() { - // Code here will be called immediately after the constructor (right - // before each test). - opalp->doParse(); - } - - virtual void TearDown() { - // Code here will be called immediately after each test (right - // before the destructor). - } - - // Objects declared here can be used by all tests in the test case - boost::scoped_ptr<OpalInputFileParser> opalp; - }; - - TEST_F(InputFileParserTest, ProblemSize) { - - Expressions::Named_t obj, constr; - DVarContainer_t dvars; - opalp->getProblem(obj, constr, dvars); - - EXPECT_EQ(static_cast<size_t>(3), obj.size()); - EXPECT_EQ(static_cast<size_t>(1), constr.size()); - EXPECT_EQ(static_cast<size_t>(1), dvars.size()); - } - - TEST_F(InputFileParserTest, ParsedCorrectDesignVars) { - - Expressions::Named_t obj, constr; - DVarContainer_t dvars; - opalp->getProblem(obj, constr, dvars); - - DVarContainer_t::iterator itr; - for(itr = dvars.begin(); itr != dvars.end(); itr++) { - EXPECT_EQ("d1", itr->first); - EXPECT_EQ("KS", boost::get<VAR_NAME>(itr->second)); - EXPECT_EQ(0.0, boost::get<LOWER_BOUND>(itr->second)); - EXPECT_EQ(0.5, boost::get<UPPER_BOUND>(itr->second)); - } - } - - TEST_F(InputFileParserTest, ParsedCorrectExpressionObjectives) { - - Expressions::Named_t obj, constr; - DVarContainer_t dvars; - opalp->getProblem(obj, constr, dvars); - - std::vector<std::string> names; - names.push_back("obj1"); - names.push_back("ob3"); - names.push_back("o2"); - for(Expressions::SingleNamed_t expr : obj) { - std::string expected_name = names.back(); - EXPECT_EQ(expected_name, expr.first); - names.pop_back(); - } - } - -} - -int main(int argc, char **argv) { - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/optimizer/Tests/resources/test.in b/optimizer/Tests/resources/test.in deleted file mode 100644 index d5ba4a400864e9b19541c1d42f70b051f2ba52fe..0000000000000000000000000000000000000000 --- a/optimizer/Tests/resources/test.in +++ /dev/null @@ -1,86 +0,0 @@ -OPTION, ECHO=FALSE; -OPTION, TFS=FALSE; -OPTION, INFO=FALSE; -OPTION, PSDUMPFREQ=10000000; -OPTION, STATDUMPFREQ=10000000; - -TITLE, STRING="SwissFEL Injector, Gun Optimization (May 2011)"; - -REPARTFREQ = 500; -MINSTEPFORREBIN = 1000; - -QB = 1.66101e-10; -BFREQ = 2997.912; -BCURRENT = QB*BFREQ*1e6; - -USE_ET = 1; - -IF (USE_ET > 0) { - OPTION, AUTOPHASE=0; - FINSS_RGUN_dphi = 2.28136; //2.3603907853129149; // /180.0*PI; //2.22808 -} -else { - OPTION, AUTOPHASE=0; - FINSS_RGUN_dphi = 2.3603907853129149/180.0*PI; -} - -obj1: OBJECTIVE, EXPR="KS*KS"; - o2: OBJECTIVE, EXPR="sumErrSq("resources/measurement_test.dat", "rms_x", "statfile")"; - ob3: OBJECTIVE, EXPR="fromFile("resources/from_file.dat", "var")"; - d1: DVAR, VARIABLE="KS", LOWERBOUND="0.0", UPPERBOUND="0.5"; -c1: CONSTRAINT, EXPR="KS < 1.0"; - -objs: OBJECTIVES = (obj1, o2, ob3); -dvars: DVARS = (d1); -constrs: CONSTRAINTS = (c1); - -opt: OPTIMIZE, OBJECTIVES=objs, DVARS=dvars, CONSTRAINTS=constrs; - -// ----------------------------------------------------------------------------------------- -// RF-COMPONENTS -// ----------------------------------------------------------------------------------------- - -FINSS_RGUN: RFCAVITY, L = 0.25, VOLT = 112.5662, FMAPFN = "FINSS-RGUN.dat", - ELEMEDGE = 0.0, TYPE = "STANDING", FREQ = 2997.912, LAG = FINSS_RGUN_dphi; - -FIND1_MSOL10: SOLENOID, L = 0.26, KS = 0.0022, FMAPFN = "NEW_SINGLE_SOL_NOFRINGE_OPAL.dat", - ELEMEDGE = 0.3; - -// -------------------------------------------------------------------------------------------------------------- - -InjectorPhase3: Line = (FINSS_RGUN, FIND1_MSOL10); - -Dist1: DISTRIBUTION, DISTRIBUTION = "GUNGAUSSFLATTOPTH", - SIGMAX = 2*0.000275, SIGMAPX = 0.0, CORRX = 0.0, - SIGMAY = 2*0.000275, SIGMAPY = 0.0, CORRY = 0.0, - SIGMAT = 0.0, PT = 0.0, SIGMAPT = 0.0, CORRT = 0.0, - TRISE = 4.5e-12, TFALL = 4.5e-12, TPULSEFWHM = 6.4e-12, - EKIN = 0.63, NBIN = 20; - -Fs1: FIELDSOLVER, FSTYPE=FFT, MX=16, MY=16, MT=16, - PARFFTX=true, PARFFTY=true, PARFFTT=true, - BCFFTX=open, BCFFTY=open, BCFFTT=open, - BBOXINCR=1, GREENSF=INTEGRATED; - - -if (USE_ET > 0) { - - beam1: BEAM, PARTICLE=ELECTRON, pc=P0, NSLICE=100, BFREQ=BFREQ, BCURRENT=BCURRENT, CHARGE=-1; - SELECT, LINE = InjectorPhase3; - - TRACK, LINE=InjectorPhase3, BEAM=beam1, MAXSTEPS=1000000, DT=1e-13, ZSTOP=0.8; - RUN, METHOD = "PARALLEL-SLICE", BEAM = beam1, FIELDSOLVER = Fs1, DISTRIBUTION = Dist1; - ENDTRACK; - -} -else { - - beam1: BEAM, PARTICLE=ELECTRON, pc=P0, NPART=5000, BFREQ=BFREQ, BCURRENT=BCURRENT, CHARGE=-1; - SELECT, LINE = InjectorPhase3; - - TRACK, LINE=InjectorPhase3, BEAM=beam1, MAXSTEPS=1000000, DT=1e-13, ZSTOP=0.8; - RUN, METHOD = "PARALLEL-T", BEAM = beam1, FIELDSOLVER = Fs1, DISTRIBUTION = Dist1; - ENDTRACK; - -} -QUIT; diff --git a/optimizer/Util/CMakeLists.txt b/optimizer/Util/CMakeLists.txt index d408dc8fcb23cf8954270e351ce0b97954fa0af4..8a380cf4afd16a9242d204933483803620ad55a7 100644 --- a/optimizer/Util/CMakeLists.txt +++ b/optimizer/Util/CMakeLists.txt @@ -5,7 +5,6 @@ SET (_UTIL_SRCS PeakReader.cpp ProbeReader.cpp - CommentAnnotatedInputFileParser.cpp SDDSParser.cpp SDDSParser/array.cpp SDDSParser/associate.cpp diff --git a/optimizer/Util/CommentAnnotatedInputFileParser.cpp b/optimizer/Util/CommentAnnotatedInputFileParser.cpp deleted file mode 100644 index 229a795464126247373b8a3d2e456861da4da08d..0000000000000000000000000000000000000000 --- a/optimizer/Util/CommentAnnotatedInputFileParser.cpp +++ /dev/null @@ -1,206 +0,0 @@ -#include <fstream> -#include <iostream> -#include <sstream> - -#include "boost/algorithm/string.hpp" -#include "boost/tuple/tuple.hpp" - -#include "Expression/SumErrSq.h" -#include "Expression/FromFile.h" - -#include "CommentAnnotatedInputFileParser.h" -#include "Util/OptPilotException.h" - -typedef std::pair<std::string, DVar_t> namedDVar_t; - -CommentAnnotatedInputFileParser::CommentAnnotatedInputFileParser( - std::string filename, - std::string comment_symbol, - functionDictionary_t known_expr_funcs) - : InputFileParser(filename, known_expr_funcs) - , comment_symbol_(comment_symbol) -{} - -CommentAnnotatedInputFileParser::~CommentAnnotatedInputFileParser() -{} - -void CommentAnnotatedInputFileParser::getProblem(Expressions::Named_t &objectives, - Expressions::Named_t &constraints, - DVarContainer_t &dvars) { - - for(Expressions::SingleNamed_t obj : nobjectives_) { - if(objectives_.count(obj.first) > 0) - objectives.insert(Expressions::SingleNamed_t(obj.first, obj.second)); - } - - for(Expressions::SingleNamed_t constr : nconstraints_) { - if(constraints_.count(constr.first) > 0) - constraints.insert(Expressions::SingleNamed_t(constr.first, constr.second)); - } - - for(namedDVar_t dvar : ndvars_) { - if(dvars_.count(dvar.first) > 0) - dvars.insert(namedDVar_t(dvar.first, dvar.second)); - } -} - - -void CommentAnnotatedInputFileParser::doParse() { - - std::ifstream file; - file.open(filename_.c_str(), std::ios::in); - if(!file) - throw OptPilotException("CommentAnnotatedInputFileParser::doParse()", - "Unable to open file " + filename_); - - std::string stat_filename = filename_; - boost::trim_right_if(stat_filename, boost::is_any_of(".in")); - stat_filename = stat_filename.append(".stat"); - - while(file) { - - std::string line; - std::getline(file, line, '\n'); - - size_t fpos = line.find("OBJECTIVE,"); - if(fpos != std::string::npos) { - std::string name = getAttribute(line, "name"); - std::string expr = getAttribute(line, "EXPR"); - nobjectives_.insert( - Expressions::SingleNamed_t( - name, new Expressions::Expr_t(expr, known_expr_funcs_))); - } - - fpos = line.find("CONSTRAINT,"); - if(fpos != std::string::npos) { - std::string name = getAttribute(line, "name"); - std::string expr = getAttribute(line, "EXPR"); - nconstraints_.insert(Expressions::SingleNamed_t( - name, new Expressions::Expr_t(expr, known_expr_funcs_))); - } - - fpos = line.find("DVAR,"); - if(fpos != std::string::npos) { - std::string name = getAttribute(line, "name"); - std::string var = getAttribute(line, "VARIABLE"); - std::string lowerbound = getAttribute(line, "LOWERBOUND"); - std::string upperbound = getAttribute(line, "UPPERBOUND"); - - double lb,ub; - std::istringstream str2lb(lowerbound); - std::istringstream str2ub(upperbound); - str2lb >> lb; - str2ub >> ub; - - DVar_t tmp = boost::make_tuple( var, lb, ub ); - ndvars_.insert(namedDVar_t(name, tmp)); - } - - - fpos = line.find("OPTIMIZE,"); - if(fpos != std::string::npos) { - - //FIXME: ignored for now - //string optname_ = getAttribute(line, "name"); - //string listObjectives_ = getAttribute(line, "OBJECTIVES"); - //string listConstraints_ = getAttribute(line, "CONSTRAINTS"); - //string listDVars_ = getAttribute(line, "DVARS"); - } else { - - fpos = line.find("OBJECTIVES"); - if(fpos != std::string::npos) - objectives_ = getListAttribute(line); - - fpos = line.find("CONSTRAINTS"); - if(fpos != std::string::npos) - constraints_ = getListAttribute(line); - - fpos = line.find("DVARS"); - if(fpos != std::string::npos) - dvars_ = getListAttribute(line); - } - } -} - -std::set<std::string> CommentAnnotatedInputFileParser::getListAttribute( - std::string str) { - - size_t sstart = str.find("(") + 1; - size_t send = str.find(")"); - std::string args = str.substr(sstart, (send-sstart)); - - StringList_t attributes; - boost::split(attributes, args, boost::is_any_of(","), - boost::token_compress_on); - - std::set<std::string> ret; - for(std::string list_attribute_name : attributes) { - boost::trim(list_attribute_name); - ret.insert(list_attribute_name); - } - return ret; -} - -std::string CommentAnnotatedInputFileParser::getAttribute( - std::string str, std::string attribute) { - - // handle name attribute differently since it does not follow the default - // "name = value" attribute style - if(attribute.compare("name") == 0) { - - // get string on left side of colon - StringList_t res; - boost::split(res, str, boost::is_any_of(":"), - boost::token_compress_on); - std::string ret = res[0]; - - // remove comment symbols at the beginning of the line - if(comment_symbol_ == "") { - // trim left space - boost::trim_left(ret); - return ret; - } - - // get string on right side of comment - boost::split(res, ret, boost::is_any_of(comment_symbol_), - boost::token_compress_on); - return res[1]; - - } else { - - size_t fpos = str.find(attribute + "="); - if(fpos == std::string::npos) - throw OptPilotException("CommentAnnotatedInputFileParser::getAttribute", - "Attribute " + attribute + " not found!"); - - std::string ret = str.substr(fpos, std::string::npos); - - //XXX: since function arguments use the ',' delemitter we have to - // split by searching in reversed direction the last ',' from the next - // attribute. - size_t end = std::string::npos; - size_t next_attribute = ret.find('=', fpos+1); - if(next_attribute != std::string::npos) { - ret.erase(next_attribute, std::string::npos); - end = ret.rfind(","); - } else { - end = ret.rfind(";"); - if(end == std::string::npos) - throw OptPilotException("CommentAnnotatedInputFileParser::getAttribute", - "Attribute not properly terminated!"); - } - - StringList_t res; - ret.erase(end, std::string::npos); - boost::split(res, ret, boost::is_any_of("="), - boost::token_compress_on); - ret = res[1]; - - // strip quotes - boost::trim_left_if(ret, boost::is_any_of("\"")); - boost::trim_right_if(ret, boost::is_any_of("\"")); - - return ret; - } -} - diff --git a/optimizer/Util/CommentAnnotatedInputFileParser.h b/optimizer/Util/CommentAnnotatedInputFileParser.h deleted file mode 100644 index 6706234aa6280a4974c853b407652ab8a997a304..0000000000000000000000000000000000000000 --- a/optimizer/Util/CommentAnnotatedInputFileParser.h +++ /dev/null @@ -1,95 +0,0 @@ -#ifndef __COMMENT_ANNOTATED_INPUTFILE_PARSER_H__ -#define __COMMENT_ANNOTATED_INPUTFILE_PARSER_H__ - -#include <string> -#include <sstream> -#include <set> - -#include "Types.h" -#include "InputFileParser.h" - -/** - * \class CommentAnnotatedInputFileParser - * \brief Implements a parser for CommentAnnotated input files - * - * This class extracts the optimization problem (objectives, constraints, - * design variables) from an comment annotated input file. All statements are - * prefixed with a comment symbol, e.g. "\\": - * - * \verbatim - //d1: DVAR, ELEMENT="", VARIABLE="SIGX"; - //obj1: OBJECTIVE, EXPR="(energy*energy)"; - //objs: OBJECTIVES = (obj1); - //dvars: DVARS = (d1); - //constrs: CONSTRAINTS = (); - //opt: OPTIMIZE, OBJECTIVES=objs, DVARS=dvars, CONSTRAINTS=constrs; -\endverbatim - */ -class CommentAnnotatedInputFileParser : public InputFileParser { - -public: - CommentAnnotatedInputFileParser(std::string filename, - std::string comment_symbol, - functionDictionary_t known_expr_funcs); - virtual ~CommentAnnotatedInputFileParser(); - - /** - * Extracts optimizer information from CommentAnnotated input file. - */ - void doParse(); - - /** - * Access (for optimizer) to objectives constraints and design variables. - * @see Types.h for type definitions - * @param objectives container to store objectives - * @param constraints container to store constraints - * @param dvars container to store design variables - */ - void getProblem(Expressions::Named_t &objectives, - Expressions::Named_t &constraints, - DVarContainer_t &dvars); - -private: - - /// local container for objectives - Expressions::Named_t nobjectives_; - /// local container for constraints - Expressions::Named_t nconstraints_; - /// local container for design variables - DVarContainer_t ndvars_; - - /// name of the simulation/optimization - std::string optname_; - /// string representation of list of objectives - std::string listObjectives_; - /// string representation of list of constraints - std::string listConstraints_; - /// string representation of list of design variables - std::string listDVars_; - - /// set of names of all objectives - std::set<std::string> objectives_; - /// set of names of all constraints - std::set<std::string> constraints_; - /// set of names of all design variables - std::set<std::string> dvars_; - - std::string comment_symbol_; - - /** - * Get a specific attribute in string - * @param str string to be search - * @param attribute attribute to search - * @return string containing trimmed attribute (if any) - */ - std::string getAttribute(std::string str, std::string attribute); - - /** - * Get the list of all attributes - * @param str to get attributes from - * @return set of all attributes found in str - */ - std::set<std::string> getListAttribute(std::string str); -}; - -#endif diff --git a/optimizer/Util/InputFileParser.h b/optimizer/Util/InputFileParser.h deleted file mode 100644 index 91f6d34cd89593e64030328007718054e2e02bb5..0000000000000000000000000000000000000000 --- a/optimizer/Util/InputFileParser.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef __INPUTFILEPARSER_H__ -#define __INPUTFILEPARSER_H__ - -#include <string> -#include <vector> -#include <map> - -#include "Expression/Parser/function.hpp" - -/// general data structures for storing objectives, constraints and design variables -typedef std::vector<std::string> StringList_t; - -enum AttributeType_t {STRING, VALUE, EXPRESSION}; -typedef std::pair<AttributeType_t, std::string> Attribute_t; -typedef std::vector<Attribute_t> Attributes_t; -typedef std::map<std::string, Attributes_t> AttributeMap_t; -typedef std::map<std::string, AttributeMap_t> OptInfo_t; - -/** - * \class InputFileParser - * \brief Base class for all input file parsers - * - * Every input file parser must implement doParse and getProblem. - */ -class InputFileParser { - -public: - InputFileParser(std::string filename, - functionDictionary_t known_expr_funcs) - : filename_(filename) - , known_expr_funcs_(known_expr_funcs) - {} - - ~InputFileParser() {} - - /** - * Parse the input file and set objectives, constraints and design - * variables. - */ - virtual void doParse() = 0; - - /** - * Access (for optimizer) to objectives constraints and design variables - * if implementation is using a different representation. - * @see Types.h for type definitions - * @param objectives container to store objectives - * @param constraints container to store constraints - * @param dvars container to store design variables - */ - virtual void getProblem(Expressions::Named_t &objectives, - Expressions::Named_t &constraints, - DVarContainer_t &dvars) = 0; - -protected: - /// filename of the input file - std::string filename_; - functionDictionary_t known_expr_funcs_; -}; - -#endif diff --git a/optimizer/Util/OpalInputFileParser.h b/optimizer/Util/OpalInputFileParser.h deleted file mode 100644 index 7797985843482091e84d5c63f9d6bfb5ef7937e4..0000000000000000000000000000000000000000 --- a/optimizer/Util/OpalInputFileParser.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef __OPAL_INPUT_FILE_PARSER_H__ -#define __OPAL_INPUT_FILE_PARSER_H__ - -#include <string> -#include <sstream> -#include <set> - -#include "Util/Types.h" -#include "Util/CommentAnnotatedInputFileParser.h" - -/** - * \class OpalInputFileParser - * \brief Implements a parser for OPAL input files - * - * This class extracts the optimization problem (objectives, constraints, - * design variables) from an Opal input file. E.g., - * - * \verbatim - d1: DVAR, ELEMENT="", VARIABLE="SIGX"; - obj1: OBJECTIVE, EXPR="(energy*energy)"; - objs: OBJECTIVES = (obj1); - dvars: DVARS = (d1); - constrs: CONSTRAINTS = (); - opt: OPTIMIZE, OBJECTIVES=objs, DVARS=dvars, CONSTRAINTS=constrs; -\endverbatim - */ -class OpalInputFileParser : public CommentAnnotatedInputFileParser { - -public: - OpalInputFileParser(std::string filename, - functionDictionary_t known_expr_funcs) - : CommentAnnotatedInputFileParser(filename, "", known_expr_funcs) - {} - - ~OpalInputFileParser() - {} - -}; - -#endif diff --git a/optimizer/Util/PlainInputFileParser.h b/optimizer/Util/PlainInputFileParser.h deleted file mode 100644 index 21ee47feb9ad0eb73b792327f988243542b3406e..0000000000000000000000000000000000000000 --- a/optimizer/Util/PlainInputFileParser.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef __PLAIN_INPUTFILE_PARSER_H__ -#define __PLAIN_INPUTFILE_PARSER_H__ - -#include "Util/Types.h" -#include "Util/CommentAnnotatedInputFileParser.h" - -/** - * \class PlainInputFileParser - * \brief Implements a parser for plain input files - * - * This class extracts the optimization problem (objectives, constraints, - * design variables) from a plain input file, e.g., - * - * \verbatim - d1: DVAR, ELEMENT="", VARIABLE="SIGX"; - obj1: OBJECTIVE, EXPR="(energy*energy)"; - objs: OBJECTIVES = (obj1); - dvars: DVARS = (d1); - cons: CONSTRAINTS = (); - opt: OPTIMIZE, OBJECTIVES=objs, DVARS=dvars, CONSTRAINTS=cons; -\endverbatim - */ -class PlainInputFileParser : public CommentAnnotatedInputFileParser { - -public: - PlainInputFileParser(std::string filename, - functionDictionary_t known_expr_funcs) - : CommentAnnotatedInputFileParser(filename, "", known_expr_funcs) - {} - - ~PlainInputFileParser() - {} - -}; - -#endif diff --git a/src/Main.cpp b/src/Main.cpp index 77578ebedc0fde9b335b09734d4c850d7a80b908..11aa291895ec9f863bbdb22016306705464311c5 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -55,7 +55,6 @@ Inform *gmsg; #include "Optimizer/EA/BlendCrossover.h" #include "Optimizer/EA/IndependentBitMutation.h" -#include "Util/OpalInputFileParser.h" #include "Optimize/OpalSimulation.h" #include "Comm/CommSplitter.h" diff --git a/src/Optimize/OptimizeCmd.cpp b/src/Optimize/OptimizeCmd.cpp index 79a6e5cfaf63e39f19100433eef6b4fe25247782..c9cd5cca398cd69d296c79f7178a3444405d7be2 100644 --- a/src/Optimize/OptimizeCmd.cpp +++ b/src/Optimize/OptimizeCmd.cpp @@ -15,7 +15,6 @@ #include "Pilot/Pilot.h" #include "Util/OptPilotException.h" -#include "Util/OpalInputFileParser.h" #include "Optimizer/EA/FixedPisaNsga2.h" #include "Optimizer/EA/BlendCrossover.h" @@ -540,7 +539,6 @@ void OptimizeCmd::run(const CmdArguments_t& args, const Expressions::Named_t& objectives, const Expressions::Named_t& constraints) { - typedef OpalInputFileParser Input_t; typedef OpalSimulation Sim_t; typedef CommSplitter< ManyMasterSplit< NoCommTopology > > Comm_t; @@ -557,7 +555,7 @@ void OptimizeCmd::run(const CmdArguments_t& args, case CrossOver::Blend + Mutation::IndependentBit: { typedef FixedPisaNsga2< BlendCrossover, IndependentBitMutation > Opt_t; - typedef Pilot<Input_t, Opt_t, Sim_t, SolPropagationGraph_t, Comm_t> pilot_t; + typedef Pilot<Opt_t, Sim_t, SolPropagationGraph_t, Comm_t> pilot_t; boost::scoped_ptr<pilot_t> pi(new pilot_t(args, comm, funcs, dvars, @@ -568,7 +566,7 @@ void OptimizeCmd::run(const CmdArguments_t& args, case CrossOver::Blend + Mutation::OneBit: { typedef FixedPisaNsga2< BlendCrossover, OneBitMutation > Opt_t; - typedef Pilot<Input_t, Opt_t, Sim_t, SolPropagationGraph_t, Comm_t> pilot_t; + typedef Pilot<Opt_t, Sim_t, SolPropagationGraph_t, Comm_t> pilot_t; boost::scoped_ptr<pilot_t> pi(new pilot_t(args, comm, funcs, dvars, @@ -579,7 +577,7 @@ void OptimizeCmd::run(const CmdArguments_t& args, case CrossOver::NaiveOnePoint + Mutation::IndependentBit: { typedef FixedPisaNsga2< NaiveOnePointCrossover, IndependentBitMutation > Opt_t; - typedef Pilot<Input_t, Opt_t, Sim_t, SolPropagationGraph_t, Comm_t> pilot_t; + typedef Pilot<Opt_t, Sim_t, SolPropagationGraph_t, Comm_t> pilot_t; boost::scoped_ptr<pilot_t> pi(new pilot_t(args, comm, funcs, dvars, @@ -590,7 +588,7 @@ void OptimizeCmd::run(const CmdArguments_t& args, case CrossOver::NaiveOnePoint + Mutation::OneBit: { typedef FixedPisaNsga2< NaiveOnePointCrossover, OneBitMutation > Opt_t; - typedef Pilot<Input_t, Opt_t, Sim_t, SolPropagationGraph_t, Comm_t> pilot_t; + typedef Pilot<Opt_t, Sim_t, SolPropagationGraph_t, Comm_t> pilot_t; boost::scoped_ptr<pilot_t> pi(new pilot_t(args, comm, funcs, dvars, @@ -601,7 +599,7 @@ void OptimizeCmd::run(const CmdArguments_t& args, case CrossOver::NaiveUniform + Mutation::IndependentBit: { typedef FixedPisaNsga2< NaiveUniformCrossover, IndependentBitMutation > Opt_t; - typedef Pilot<Input_t, Opt_t, Sim_t, SolPropagationGraph_t, Comm_t> pilot_t; + typedef Pilot<Opt_t, Sim_t, SolPropagationGraph_t, Comm_t> pilot_t; boost::scoped_ptr<pilot_t> pi(new pilot_t(args, comm, funcs, dvars, @@ -612,7 +610,7 @@ void OptimizeCmd::run(const CmdArguments_t& args, case CrossOver::NaiveUniform + Mutation::OneBit: { typedef FixedPisaNsga2< NaiveUniformCrossover, OneBitMutation > Opt_t; - typedef Pilot<Input_t, Opt_t, Sim_t, SolPropagationGraph_t, Comm_t> pilot_t; + typedef Pilot<Opt_t, Sim_t, SolPropagationGraph_t, Comm_t> pilot_t; boost::scoped_ptr<pilot_t> pi(new pilot_t(args, comm, funcs, dvars, @@ -623,7 +621,7 @@ void OptimizeCmd::run(const CmdArguments_t& args, case CrossOver::SimulatedBinary + Mutation::IndependentBit: { typedef FixedPisaNsga2< SimulatedBinaryCrossover, IndependentBitMutation > Opt_t; - typedef Pilot<Input_t, Opt_t, Sim_t, SolPropagationGraph_t, Comm_t> pilot_t; + typedef Pilot<Opt_t, Sim_t, SolPropagationGraph_t, Comm_t> pilot_t; boost::scoped_ptr<pilot_t> pi(new pilot_t(args, comm, funcs, dvars, @@ -634,7 +632,7 @@ void OptimizeCmd::run(const CmdArguments_t& args, case CrossOver::SimulatedBinary + Mutation::OneBit: { typedef FixedPisaNsga2< SimulatedBinaryCrossover, OneBitMutation > Opt_t; - typedef Pilot<Input_t, Opt_t, Sim_t, SolPropagationGraph_t, Comm_t> pilot_t; + typedef Pilot<Opt_t, Sim_t, SolPropagationGraph_t, Comm_t> pilot_t; boost::scoped_ptr<pilot_t> pi(new pilot_t(args, comm, funcs, dvars, diff --git a/src/Sample/SampleCmd.cpp b/src/Sample/SampleCmd.cpp index 246f26732f9795c0254e094ed224995295aaf38a..fb80e339ea247b4102bd05b8ce858da31fa0b859 100644 --- a/src/Sample/SampleCmd.cpp +++ b/src/Sample/SampleCmd.cpp @@ -19,7 +19,6 @@ #include "Sample/SamplePilot.h" #include "Util/CmdArguments.h" #include "Util/OptPilotException.h" -#include "Util/OpalInputFileParser.h" #include "Comm/CommSplitter.h" #include "Comm/Topology/NoCommTopology.h" @@ -273,13 +272,12 @@ void SampleCmd::execute() { // Setup/Configuration ////////////////////////////////////////////////////////////////////////// - typedef OpalInputFileParser Input_t; typedef OpalSimulation Sim_t; typedef CommSplitter< ManyMasterSplit< NoCommTopology > > Comm_t; typedef SocialNetworkGraph< NoCommTopology > SolPropagationGraph_t; - typedef SamplePilot<Input_t, Sampler, Sim_t, SolPropagationGraph_t, Comm_t> pilot_t; + typedef SamplePilot<Sampler, Sim_t, SolPropagationGraph_t, Comm_t> pilot_t; ////////////////////////////////////////////////////////////////////////// diff --git a/src/Sample/SamplePilot.h b/src/Sample/SamplePilot.h index c8bf8c19890277c729f67feaedbc30b705c62a92..19fb8dffe1963d7b5441acba9d4bae230542359a 100644 --- a/src/Sample/SamplePilot.h +++ b/src/Sample/SamplePilot.h @@ -5,9 +5,6 @@ #include "Sample/SampleWorker.h" #include "Expression/Parser/function.hpp" - - - /** * \class SamplePilot * \brief The sample Pilot (Master): Coordinates requests by sampler @@ -21,7 +18,6 @@ * @see SampleWorker * @see Sampler * - * @tparam Input_t type of the input file parser * @tparam Opt_t type of the sampler * @tparam Sim_t type of the simulation * @tparam SolPropagationGraph_t strategy to distribute solution between @@ -29,14 +25,12 @@ * @tparam Comm_t comm splitter strategy */ template < - class Input_t - , class Opt_t + class Opt_t , class Sim_t , class SolPropagationGraph_t , class Comm_t > -class SamplePilot : protected Pilot<Input_t, - Opt_t, +class SamplePilot : protected Pilot<Opt_t, Sim_t, SolPropagationGraph_t, Comm_t> @@ -53,8 +47,7 @@ public: >& sampleMethods, const std::vector<std::string> &storeobjstr, const std::vector<std::string> &filesToKeep) - : Pilot<Input_t, - Opt_t, + : Pilot<Opt_t, Sim_t, SolPropagationGraph_t, Comm_t>(args,