- Timestamp:
- 05/12/15 20:40:11 (10 years ago)
- Location:
- branches/HeuristicLab.Problems.GrammaticalOptimization-gkr
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Problems.GrammaticalOptimization-gkr/HeuristicLab.Problems.GrammaticalOptimization/Grammar.cs
r12294 r12391 175 175 } 176 176 177 public Sequence CompleteSentenceRandomly( Random random, Sequence phrase, int maxLen) {177 public Sequence CompleteSentenceRandomly(System.Random random, Sequence phrase, int maxLen) { 178 178 if (phrase.Length > maxLen) throw new ArgumentException(); 179 179 if (MinPhraseLength(phrase) > maxLen) throw new ArgumentException(); -
branches/HeuristicLab.Problems.GrammaticalOptimization-gkr/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization.csproj
r12290 r12391 46 46 <HintPath>..\HeuristicLab\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.dll</HintPath> 47 47 </Reference> 48 <Reference Include="HeuristicLab.Random-3.3"> 49 <HintPath>..\..\..\..\..\Program Files\HeuristicLab 3.3\HeuristicLab.Random-3.3.dll</HintPath> 50 </Reference> 48 51 <Reference Include="System" /> 49 52 <Reference Include="System.Core" /> -
branches/HeuristicLab.Problems.GrammaticalOptimization-gkr/HeuristicLab.Problems.GrammaticalOptimization/Interfaces/IGrammar.cs
r11848 r12391 20 20 int MinPhraseLength(Sequence phrase); 21 21 int MaxPhraseLength(Sequence phrase); 22 Sequence CompleteSentenceRandomly( Random random, Sequence phrase, int maxLen);22 Sequence CompleteSentenceRandomly(System.Random random, Sequence phrase, int maxLen); 23 23 24 24 bool IsTerminal(char symbol); -
branches/HeuristicLab.Problems.GrammaticalOptimization-gkr/HeuristicLab.Problems.GrammaticalOptimization/Problems/FindPhrasesProblem.cs
r12290 r12391 29 29 private readonly double decoyReward; 30 30 private readonly bool phrasesAsSets; 31 private readonly int alphabetSize; 32 private readonly int numOptimalPhrases; 33 private readonly int numDecoyPhrases; 31 34 private readonly SortedSet<string> optimalPhrases; 32 35 private readonly SortedSet<string> decoyPhrases; 33 public string Name { get { return "FindPhrases"; } }36 public string Name { get { return string.Format("FindPhrases({0},{1},{2},{3},{4},{5},{6},{7})", alphabetSize, numPhrases, phraseLen, numOptimalPhrases, numDecoyPhrases, correctReward, decoyReward, phrasesAsSets); } } 34 37 35 public FindPhrasesProblem( Random rand, int alphabetSize, int numPhrases, int phraseLen, int numOptimalPhrases, int numDecoyPhrases = 1,38 public FindPhrasesProblem(System.Random rand, int alphabetSize, int numPhrases, int phraseLen, int numOptimalPhrases, int numDecoyPhrases = 1, 36 39 double correctReward = 1.0, double decoyReward = 0.0, bool phrasesAsSets = false) { 37 40 if (alphabetSize <= 0 || alphabetSize > 26) throw new ArgumentException(); … … 47 50 this.decoyReward = decoyReward; 48 51 this.phrasesAsSets = phrasesAsSets; 52 this.alphabetSize = alphabetSize; 53 this.numOptimalPhrases = numOptimalPhrases; 54 this.numDecoyPhrases = numDecoyPhrases; 49 55 50 56 var sentenceSymbol = 'S'; -
branches/HeuristicLab.Problems.GrammaticalOptimization-gkr/HeuristicLab.Problems.GrammaticalOptimization/Problems/RoyalPairProblem.cs
r12290 r12391 5 5 using System.Text; 6 6 using System.Text.RegularExpressions; 7 using HeuristicLab.Common; 7 8 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 9 using HeuristicLab.Random; 8 10 9 11 namespace HeuristicLab.Problems.GrammaticalOptimization { … … 13 15 private readonly IGrammar grammar; 14 16 private readonly int numTerminals; 15 public string Name { get { return "RoyalPair"; } }17 public string Name { get { return string.Format("RoyalPair({0})", numTerminals); } } 16 18 17 19 public RoyalPairProblem(int numTerminals = 2) { … … 19 21 20 22 var sentenceSymbol = 'S'; 21 var terminalSymbols = Enumerable.Range(0, numTerminals).Select(off => (char)((byte)'a' + off)).ToArray(); 23 var terminalSymbols = Enumerable.Range(0, numTerminals).Select(off => (char)((byte)'a' + off)).ToList(); 24 terminalSymbols.ShuffleInPlace(new MersenneTwister(31415)); 25 22 26 var nonTerminalSymbols = new char[] { sentenceSymbol }; 23 27 -
branches/HeuristicLab.Problems.GrammaticalOptimization-gkr/HeuristicLab.Problems.GrammaticalOptimization/Problems/RoyalPhraseSequenceProblem.cs
r12290 r12391 33 33 private readonly SortedSet<string>[] optimalPhrasesForPos; 34 34 public string Name { get { return "RoyalPhraseSequence"; } } 35 public RoyalPhraseSequenceProblem( Random rand, int alphabetSize, int sequenceLen, int phraseLen = 1, int numCorrectPhrases = 1, double correctReward = 1.0, double incorrectReward = 0.0, bool phrasesAsSets = false) {35 public RoyalPhraseSequenceProblem(System.Random rand, int alphabetSize, int sequenceLen, int phraseLen = 1, int numCorrectPhrases = 1, double correctReward = 1.0, double incorrectReward = 0.0, bool phrasesAsSets = false) { 36 36 if (alphabetSize <= 0 || alphabetSize > 26) throw new ArgumentException(); 37 37 if (sequenceLen <= 0) throw new ArgumentException(); -
branches/HeuristicLab.Problems.GrammaticalOptimization-gkr/HeuristicLab.Problems.GrammaticalOptimization/Problems/RoyalSequenceProblem.cs
r12099 r12391 24 24 private readonly SortedSet<char>[] optimalSymbolsForPos; 25 25 public string Name { get { return "RoyalSequence"; } } 26 public RoyalSequenceProblem( Random rand, int alphabetSize, int sequenceLen, int k = 1, double correctReward = 1.0, double incorrectReward = 0.0) {26 public RoyalSequenceProblem(System.Random rand, int alphabetSize, int sequenceLen, int k = 1, double correctReward = 1.0, double incorrectReward = 0.0) { 27 27 if (alphabetSize <= 0 || alphabetSize > 26) throw new ArgumentException(); 28 28 if (sequenceLen <= 0) throw new ArgumentException(); -
branches/HeuristicLab.Problems.GrammaticalOptimization-gkr/HeuristicLab.Problems.GrammaticalOptimization/Problems/SymbolicRegressionPoly10Problem.cs
r12298 r12391 73 73 private void GenerateData() { 74 74 // generate data with fixed seed to make sure that data is always the same 75 var rand = new Random(31415);75 var rand = new System.Random(31415); 76 76 for (int i = 0; i < N; i++) { 77 77 x[i] = new double[10]; -
branches/HeuristicLab.Problems.GrammaticalOptimization-gkr/Test/RunMctsExperiments.cs
r12390 r12391 180 180 }; 181 181 182 var maxSizes = new int[] { 10, 20, 30, 40, 50 };183 int nReps = 30; 184 int maxIterations = 10000;182 var maxSizes = new int[] { /*10, 20, 30, 40,*/ 25, 50 }; 183 int nReps = 30; 184 int maxIterations = 20000; 185 185 foreach (var instanceFactory in instanceFactories) { 186 186 foreach (var policyFactory in policyFactories) { … … 307 307 var solver = new SequentialSearch(problem, maxSize, new Random(randSeed), 0, 308 308 new GenericGrammarPolicy(problem, policy, false)); 309 var problemName = problem. GetType().Name;309 var problemName = problem.Name; 310 310 RunSolver(solver, problemName, policy.ToString(), maxIters, maxSize); 311 311 }
Note: See TracChangeset
for help on using the changeset viewer.