Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9872


Ignore:
Timestamp:
08/09/13 16:32:42 (11 years ago)
Author:
gkronber
Message:

#2026 removed unused files

Location:
branches/HeuristicLab.Problems.GPDL
Files:
3 deleted
5 edited
1 moved

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL.Views/3.4/Resources/LawnMower.txt

    r9847 r9872  
    102102int[] ints = Enumerable.Range(-100, 201).ToArray();
    103103>>
    104 INIT <<
    105 >>
    106104
    107105NONTERMINALS
  • branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL/3.4/GPDef.atg

    r9846 r9872  
    150150                                                                                         myTNode.Ident = identStr;
    151151                                                                                         myTNode.FormalParameters = src;
    152                                                                                          myTNode.FieldDefinitions = SourceReader.ExtractFormalParameters(src);
     152                                                                                         myTNode.FieldDefinitions = Util.ExtractFormalParameters(src);
    153153                                                                                  .)
    154154  [ "CONSTRAINTS" ConstraintDef<out constraints>
  • branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL/3.4/HeuristicLab.Problems.GPDL-3.4.csproj

    r9724 r9872  
    192192    <Compile Include="AST.cs" />
    193193    <Compile Include="Grammar.cs" />
    194     <Compile Include="InterpreterBuilder.cs" />
    195     <Compile Include="MethodBuilder.cs" />
    196194    <Compile Include="Parser.cs" />
    197195    <Compile Include="ProblemGenerator.cs" />
    198196    <Compile Include="Scanner.cs" />
    199     <Compile Include="SourceReader.cs" />
    200     <Compile Include="SymbolBuilder.cs" />
     197    <Compile Include="Util.cs" />
    201198    <None Include="GPDef.atg" />
    202199    <None Include="HeuristicLab.snk" />
  • branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL/3.4/Parser.cs

    r9846 r9872  
    218218    myTNode.Ident = identStr;
    219219    myTNode.FormalParameters = src;
    220     myTNode.FieldDefinitions = SourceReader.ExtractFormalParameters(src);
     220    myTNode.FieldDefinitions = Util.ExtractFormalParameters(src);
    221221   
    222222    if (la.kind == 15) {
  • branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL/3.4/ProblemGenerator.cs

    r9846 r9872  
    5353";
    5454
    55   private string mainClassTemplate = @"
    56 namespace ?PROBLEMNAME? {
    57   public sealed class ?IDENT?Main {
    58     public ?IDENT?Main() {
    59       Initialize();
    60     }   
    61     public void Initialize() {
    62       var problem = new ?IDENT?Problem();
    63       var wh = new AutoResetEvent(false);
    64       var ga = new OffspringSelectionGeneticAlgorithm();
    65       ga.Engine = new SequentialEngine();
    66       ga.Problem = problem;
    67       ga.PopulationSize.Value = 1000;
    68       ga.MaximumGenerations.Value = 100;
    69       ga.ComparisonFactorLowerBound.Value = 0;
    70       ga.ComparisonFactorUpperBound.Value = 0;
    71       ga.MutationProbability.Value = 0.15;
    72       ga.Mutator = ga.MutatorParameter.ValidValues.OfType<MultiSymbolicExpressionTreeManipulator>().First();
    73       var ts = ga.SelectorParameter.ValidValues.OfType<GenderSpecificSelector>().First();
    74       ga.Selector = ts;
    75       ga.Prepare();
    76       ga.ExceptionOccurred += (sender, args) => {
    77         Console.WriteLine(args.Value);
    78         wh.Set();
    79       };
    80       ga.Stopped += (sender, args) => {
    81          Console.WriteLine(""Finished"");
    82          Console.WriteLine(""Evaluated solutions: "" + ((IntValue)(ga.Results[""EvaluatedSolutions""]).Value).Value);
    83          Console.WriteLine(""Best quality: "" + ((DoubleValue)(ga.Results[""BestQuality""]).Value).Value);
    84          wh.Set();
    85       };
    86       ga.Crossover = ga.CrossoverParameter.ValidValues.First();
    87       ga.Start();   
    88       while(!wh.WaitOne(500)) {
    89          if(ga.Results.ContainsKey(""BestQuality"")) {
    90            int evalSolutions = ((IntValue)(ga.Results[""EvaluatedSolutions""]).Value).Value;
    91            double quality = ((DoubleValue)(ga.Results[""BestQuality""]).Value).Value;
    92            Console.WriteLine(""{0}\t{1} "", evalSolutions, quality);
    93          }
    94       };
    95     }
    96   }
    97 }";
    98 
    9955  private string problemClassTemplate = @"
    10056namespace ?PROBLEMNAME? {
     
    207163
    208164    ?CONSTRAINTSSOURCE?
    209 
    210165  }
    211166}";
     
    408363    GenerateEvaluator(definition);
    409364    GenerateProblem(definition);
    410     GenerateMain(definition);
    411365
    412366    problemSourceCode.Replace("?PROBLEMNAME?", definition.Name);
    413367
     368    // write to a file for debugging
    414369    using (var stream = new StreamWriter(definition.Name + ".cs")) {
    415370      stream.WriteLine(problemSourceCode.ToString());
    416371    }
    417372
     373    // compile generated source
    418374    using (var csc = new CSharpCodeProvider(new Dictionary<string, string>() { { "CompilerVersion", "v4.0" } })) {
    419375      var parameters = new CompilerParameters(new[] { "mscorlib.dll", "System.Core.dll", "System.dll", "System.Drawing.dll" }, Path.ChangeExtension(Path.GetRandomFileName(), ".dll"), true);
     
    442398
    443399      CompilerResults results = csc.CompileAssemblyFromSource(parameters, problemSourceCode.ToString());
    444       results.Errors.Cast<CompilerError>().ToList().ForEach(error => Console.WriteLine(error.Line + " " + error.ErrorText));
    445 
     400      results.Errors.Cast<CompilerError>()
     401        .ToList()
     402        .ForEach(error => Console.WriteLine(error.Line + " " + error.ErrorText));
     403
     404      // load the assembly, and create an instance from the generate problem class
    446405      var asm = results.CompiledAssembly;
    447406      AppDomain.CurrentDomain.Load(asm.GetName());
     
    460419    problemSourceCode.AppendLine(evaluatorClassCode).AppendLine();
    461420  }
    462 
    463   private void GenerateMain(GPDefNode definition) {
    464     var mainClassCode =
    465       mainClassTemplate
    466         .Replace("?IDENT?", definition.Name);
    467 
    468     problemSourceCode.AppendLine(mainClassCode).AppendLine();
    469   }
    470 
    471421
    472422  private void GenerateProblem(GPDefNode definition) {
     
    511461    string formalParameter = definition.NonTerminals.Single(nt => nt.Ident == g.RootSymbol).FormalParameters;
    512462    var actualParameterEnumerable =
    513       SourceReader.ExtractFormalParameters(formalParameter).Select(e => e.RefOrOut + " " + e.Identifier);
     463      Util.ExtractFormalParameters(formalParameter).Select(e => e.RefOrOut + " " + e.Identifier);
    514464    string actualParameter = string.Empty;
    515465    if (actualParameterEnumerable.Any()) {
     
    524474    }
    525475    foreach (var s in definition.Terminals) {
    526       sb.AppendLine(GenerateTerminalInterpreterMethod(g, (TerminalNode)s));
    527     }
    528     return sb.ToString();
    529   }
    530 
    531   private string GenerateTerminalInterpreterMethod(Grammar g, TerminalNode s) {
     476      sb.AppendLine(GenerateTerminalInterpreterMethod((TerminalNode)s));
     477    }
     478    return sb.ToString();
     479  }
     480
     481  private string GenerateTerminalInterpreterMethod(TerminalNode s) {
    532482    var sb = new StringBuilder();
    533483    if (!s.FormalParameters.Any())
  • branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL/3.4/Util.cs

    r9858 r9872  
    2424using System.Text.RegularExpressions;
    2525
    26 public class SourceReader {
    27 
     26public class Util {
    2827  private static Regex formalParameterExpr = new Regex(@"\s*,?\s*((?<refOrOut>(out|ref))\s+)?(?<type>[_\w]*)\s+(?<id>[_\w]*)\s*");
    2928  public static IEnumerable<TerminalNode.FieldDefinition> ExtractFormalParameters(string formalParameterSrc) {
Note: See TracChangeset for help on using the changeset viewer.