public Configuration(string datafilepath, string logfilepath, string solutionfilepath, int randomseed, int numberofruns, AlgorithmTypes algorithmtype) { this.datafilepath = datafilepath; this.logfilepath = logfilepath; this.solutionfilepath = solutionfilepath; this.randomseed = randomseed; this.numberofruns = numberofruns; this.algorithmtype = algorithmtype; }
public Configuration() { this.datafilepath = ""; this.logfilepath = ""; this.solutionfilepath = ""; this.randomseed = 0; this.numberofruns = 1; this.algorithmtype = AlgorithmTypes.RANDOM; }
public Configuration(string datafilepath, string logfilepath, string solutionfilepath, int randomseed, int numberofruns, AlgorithmTypes algorithmtype, double penaltycoefficient) { this.datafilepath = datafilepath; this.logfilepath = logfilepath; this.solutionfilepath = solutionfilepath; this.randomseed = randomseed; this.numberofruns = numberofruns; this.algorithmtype = algorithmtype; this.penaltycoefficient = penaltycoefficient; }
public bool loadFromFile(string path) { StreamReader infile; try { infile = new StreamReader(path); } catch(Exception e) { Console.WriteLine("Load ConfigFile Exception: " + e.Message); return false; } this.datafilepath = infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]; string algortype = infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]; Console.WriteLine(algortype); if(algortype.ToUpper() == "RANDOM") { this.algorithmtype = AlgorithmTypes.RANDOM; this.randomseed = Convert.ToInt32(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]); this.numberofruns = Convert.ToInt32(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]); this.penaltycoefficient = Convert.ToDouble(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]); this.logfilepath = infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]; this.solutionfilepath = infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]; } else if(algortype.ToUpper() == "MULAMBDA") { this.algorithmtype = AlgorithmTypes.MULAMBDA; this.randomseed = Convert.ToInt32(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]); this.numberofruns = Convert.ToInt32(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]); this.populationsize = Convert.ToInt32(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]); this.numberofchildren = Convert.ToInt32(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]); this.usencrossover = Convert.ToBoolean(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]); this.useuniformcrossover = Convert.ToBoolean(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]); this.numberofcrossoverpoints = Convert.ToInt32(infile.ReadLine().Split(new string[] { ": "}, StringSplitOptions.None)[1]); this.usektournamentforparent = Convert.ToBoolean(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]); this.usefitnessproportionforparent = Convert.ToBoolean(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]); this.parenttournamentsize = Convert.ToInt32(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]); this.bitstoflip = Convert.ToInt32(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]); this.usektournamentforsurvivor = Convert.ToBoolean(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]); this.usetruncationforsurvivor = Convert.ToBoolean(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]); this.survivortournamentsize = Convert.ToInt32(infile.ReadLine().Split(new string[] { ": "}, StringSplitOptions.None)[1]); this.terminationconvergence = Convert.ToInt32(infile.ReadLine().Split(new string[] { ": "}, StringSplitOptions.None)[1]); this.penaltycoefficient = Convert.ToDouble(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]); this.numberofevals = Convert.ToInt32(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]); this.logfilepath = infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]; this.solutionfilepath = infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]; } else { throw new Exception("Invalid algorithm type: " + algortype); } return true; }
public AlgorithmAttribute(AlgorithmTypes algorithmtype) { AlgorithmType = algorithmtype; }
public bool loadFromFile(string path) { StreamReader infile; try { infile = new StreamReader(path); } catch(Exception e) { Console.WriteLine("Load ConfigFile Exception: " + e.Message); return false; } this.datafilepath = infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]; string algortype = infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]; if(algortype.ToUpper() == "RANDOM") this.algorithmtype = AlgorithmTypes.RANDOM; else { throw new Exception("Invalid algorithm type: " + algortype); } this.randomseed = Convert.ToInt32(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]); this.numberofruns = Convert.ToInt32(infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]); this.logfilepath = infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]; this.solutionfilepath = infile.ReadLine().Split(new string[] { ": " }, StringSplitOptions.None)[1]; return true; }