Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9846


Ignore:
Timestamp:
08/05/13 11:37:13 (11 years ago)
Author:
gkronber
Message:

#2026 added lawn mower problem. create a OSGA for solving the compiled problem directly

Location:
branches/HeuristicLab.Problems.GPDL
Files:
1 added
11 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL.Views/3.4/GpdlEditor.cs

    r9843 r9846  
    2424using System.Linq;
    2525using System.Text;
     26using HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm;
    2627using HeuristicLab.MainForm.WindowsForms;
     28using HeuristicLab.Optimization;
    2729using HeuristicLab.Problems.Instances;
    2830using HeuristicLab.Problems.Instances.Views;
     
    4648        Parser parser = new Parser(scanner);
    4749        parser.Parse();
    48         MainForm.MainFormManager.MainForm.ShowContent(parser.problem);
     50
     51        // generate an OSGA to solve the problem
     52        var osga = new OffspringSelectionGeneticAlgorithm();
     53        osga.Problem = parser.problem;
     54        osga.Engine = new SequentialEngine.SequentialEngine();
     55        osga.PopulationSize.Value = 500;
     56        osga.MutationProbability.Value = 0.15;
     57        osga.ComparisonFactorUpperBound.Value = 1.0;
     58        osga.ComparisonFactorLowerBound.Value = 1.0;
     59        osga.MutatorParameter.Value =
     60          osga.MutatorParameter.ValidValues.First(o => o.Name.Contains("MultiSymbolicExpressionTreeManipulator"));
     61        osga.SelectorParameter.Value =
     62          osga.SelectorParameter.ValidValues.First(o => o.Name.Contains("GenderSpecific"));
     63        osga.MaximumSelectionPressure.Value = 500;
     64        osga.MaximumGenerations.Value = 100;
     65        MainForm.MainFormManager.MainForm.ShowContent(osga);
    4966      }
    5067
  • branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL.Views/3.4/GpdlExampleProvider.cs

    r9844 r9846  
    3131        {
    3232          new GpdlExampleDataDescriptor("Artificial Ant", "The artificial ant problem.", Resources.Artificial_Ant),
     33          new GpdlExampleDataDescriptor("Lawn mower", "The lawn mower benchmark problem.", Resources.LawnMower),
    3334          new GpdlExampleDataDescriptor("Factorial", "Evolve a program to calculate the factorial function.", Resources.Factorial),
    3435          new GpdlExampleDataDescriptor("Fibonacci", "Evolve a problem to calculate the fibonacci function.", Resources.Fib),
  • branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL.Views/3.4/HeuristicLab.Problems.GPDL.Views-3.4.csproj

    r9844 r9846  
    9393  </PropertyGroup>
    9494  <ItemGroup>
     95    <Reference Include="HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     96      <SpecificVersion>False</SpecificVersion>
     97      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm-3.3.dll</HintPath>
     98    </Reference>
     99    <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     100      <SpecificVersion>False</SpecificVersion>
     101      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Collections-3.3.dll</HintPath>
     102    </Reference>
    95103    <Reference Include="HeuristicLab.Common-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    96104      <SpecificVersion>False</SpecificVersion>
     
    142150      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Problems.Instances.Views-3.3.dll</HintPath>
    143151      <Private>False</Private>
     152    </Reference>
     153    <Reference Include="HeuristicLab.SequentialEngine-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     154      <SpecificVersion>False</SpecificVersion>
     155      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.SequentialEngine-3.3.dll</HintPath>
    144156    </Reference>
    145157    <Reference Include="ICSharpCode.AvalonEdit, Version=4.3.1.9430, Culture=neutral, PublicKeyToken=9cc39be672370310, processorArchitecture=MSIL">
     
    263275      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    264276    </Content>
     277    <None Include="Resources\LawnMower.txt" />
    265278    <None Include="Resources\Multiplexer.txt" />
    266279    <None Include="Resources\EvenParity.txt" />
  • branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL.Views/3.4/Properties/Resources.Designer.cs

    r9844 r9846  
    197197       
    198198        /// <summary>
     199        ///   Looks up a localized string similar to PROBLEM LawnMower
     200        ///
     201        ///CODE &lt;&lt;
     202        ///  public int Width { get { return 8; } }
     203        ///  public int Height { get { return 8; } }
     204        ///
     205        ///  enum Direction {West, East, North, South};
     206        ///
     207        ///  class World {
     208        ///    private bool[,] mowed = new bool[Width, Height];
     209        ///    public World() {
     210        ///      Reset();
     211        ///    }
     212        ///    public void Reset() {
     213        ///      for(int col = 0; col &lt; Width; col++)
     214        ///        for(int row = 0; row &lt; Height; row++) {
     215        ///          mowed[col, row] = false;
     216        ///        }
     217        ///    }
     218        ///    public void SetCellMowed(int col, int row) {
     219        ///      m [rest of string was truncated]&quot;;.
     220        /// </summary>
     221        internal static string LawnMower {
     222            get {
     223                return ResourceManager.GetString("LawnMower", resourceCulture);
     224            }
     225        }
     226       
     227        /// <summary>
    199228        ///   Looks up a localized string similar to PROBLEM MultiOutputMultiplier
    200229        ///
     
    220249        ///
    221250        ///NONTERMINALS
    222         ///  Expr&lt;&lt;bool[] d, out bool p&gt;&gt;.
    223         ///  AND&lt;&lt;bool[] d, out bool p&gt;&gt;.
    224         ///  OR&lt;&lt;bool[] d, out bool p&gt;&gt;.
    225         ///  NOT&lt;&lt;bool[] d, out bool p&gt;&gt;.
    226         ///  IF&lt;&lt;bool[] d, out bool p&gt;&gt;.
     251        ///  Expr&lt;&lt;bool[] d, out bool o&gt;&gt;.
     252        ///  AND&lt;&lt;bool[] d, out bool o&gt;&gt;.
     253        ///  OR&lt;&lt;bool[] d, out bool o&gt;&gt;.
     254        ///  NOT&lt;&lt;bool[] d, out bool o&gt;&gt;.
     255        ///  IF&lt;&lt;bool[] d, out bool o&gt;&gt;.
    227256        ///
    228257        ///TERMINALS
    229         ///  A0. A1. A2. A2. D0. D1. D2. D3. D4. D5. D6. D7.
     258        ///  A0. A1. A2. D0. D1. D2. D3. D4. D5. D6. D7.
    230259        ///
    231260        ///RULES
    232261        ///  Expr&lt;&lt;bool[] d, out bool o&gt;&gt; =
    233         ///    AND&lt;&lt;d, out p&gt;&gt;
    234         ///    | OR&lt;&lt;d, out p&gt;&gt;
    235         ///    | NOT&lt;&lt;d, out p&gt;&gt;
    236         ///    | IF&lt;&lt;d, out p&gt;&gt;
    237         ///    | A0                                                   SEM&lt;&lt; p = d[0]; &gt;&gt;
    238         ///    | A1                                   [rest of string was truncated]&quot;;.
     262        ///    AND&lt;&lt;d, out o&gt;&gt;
     263        ///    | OR&lt;&lt;d, out o&gt;&gt;
     264        ///    | NOT&lt;&lt;d, out o&gt;&gt;
     265        ///    | IF&lt;&lt;d, out o&gt;&gt;
     266        ///    | A0                                                   SEM&lt;&lt; o = d[0]; &gt;&gt;
     267        ///    | A1                                       [rest of string was truncated]&quot;;.
    239268        /// </summary>
    240269        internal static string Multiplexer {
  • branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL.Views/3.4/Properties/Resources.resx

    r9844 r9846  
    134134    <value>..\Resources\GPDL.xshd;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
    135135  </data>
     136  <data name="LawnMower" type="System.Resources.ResXFileRef, System.Windows.Forms">
     137    <value>..\resources\lawnmower.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
     138  </data>
    136139  <data name="Multiplexer" type="System.Resources.ResXFileRef, System.Windows.Forms">
    137140    <value>..\resources\multiplexer.txt;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
  • branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL.Views/3.4/Resources/Artificial Ant.txt

    r9519 r9846  
    188188
    189189TERMINALS
    190   Left<<>> CONSTRAINTS .
    191   Right<<>> CONSTRAINTS .
    192   Move<<>> CONSTRAINTS .
     190  Left. Right. Move.
    193191 
    194192RULES
     
    197195    | Prog2<<world, state>>
    198196    | Prog3<<world, state>>
    199     | Left<<>>                                         SEM << state.TurnLeft(); >>
    200     | Right<<>>                                        SEM << state.TurnRight(); >>
    201     | Move<<>>                                         SEM << state.MoveForward(); >>
     197    | Left                                             SEM << state.TurnLeft(); >>
     198    | Right                                            SEM << state.TurnRight(); >>
     199    | Move                                             SEM << state.MoveForward(); >>
    202200    .
    203201   
     
    229227    return (double)state.FoodEaten;
    230228  >> 
    231 END ArtitificialAnt.
     229END ArtificialAnt.
  • branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL/3.4/GPDef.atg

    r9844 r9846  
    2828
    2929COMPILER GPDef
    30   public HeuristicLab.Optimization.IProblem problem;
     30  public HeuristicLab.Optimization.ISingleObjectiveHeuristicOptimizationProblem problem;
    3131 
    3232CHARACTERS
  • branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL/3.4/Parser.cs

    r9844 r9846  
    2828  int errDist = minErrDist;
    2929
    30 public HeuristicLab.Optimization.IProblem problem;
     30public HeuristicLab.Optimization.ISingleObjectiveHeuristicOptimizationProblem problem;
    3131 
    3232
  • branches/HeuristicLab.Problems.GPDL/HeuristicLab.Problems.GPDL/3.4/ProblemGenerator.cs

    r9842 r9846  
    397397  }
    398398
    399   public IProblem GenerateFromAst(GPDefNode definition) {
     399  public ISingleObjectiveHeuristicOptimizationProblem GenerateFromAst(GPDefNode definition) {
    400400    problemSourceCode.AppendLine(usings);
    401401
     
    447447      AppDomain.CurrentDomain.Load(asm.GetName());
    448448      var problem = Activator.CreateInstance(asm.FullName, definition.Name + "." + definition.Name + "Problem").Unwrap();
    449       return (HeuristicLab.Optimization.IProblem)problem;
     449      return (ISingleObjectiveHeuristicOptimizationProblem)problem;
    450450    }
    451451  }
  • branches/HeuristicLab.Problems.GPDL/Test/Test.csproj

    r9844 r9846  
    5757      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Core-3.3.dll</HintPath>
    5858      <Private>True</Private>
     59    </Reference>
     60    <Reference Include="HeuristicLab.Data-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     61      <SpecificVersion>False</SpecificVersion>
     62      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Data-3.3.dll</HintPath>
    5963    </Reference>
    6064    <Reference Include="HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4">
  • branches/HeuristicLab.Problems.GPDL/Test/TestGpdlExamples.cs

    r9843 r9846  
    2424using System.Linq;
    2525using System.Text;
     26using System.Threading;
     27using HeuristicLab.Algorithms.GeneticAlgorithm;
    2628using HeuristicLab.Problems.GPDL;
    2729using HeuristicLab.Problems.GPDL.Views;
     30using HeuristicLab.SequentialEngine;
    2831using Microsoft.VisualStudio.TestTools.UnitTesting;
    2932
     
    3942        parser.Parse();
    4043        Assert.IsNotNull(parser.problem);
     44
     45        // test: run one generation
     46        var ga = new GeneticAlgorithm();
     47        ga.Engine = new SequentialEngine();
     48        ga.PopulationSize.Value = 100;
     49        ga.MaximumGenerations.Value = 1;
     50        ga.Problem = parser.problem;
     51
     52        var wh = new AutoResetEvent(false);
     53        Exception e = null;
     54        ga.ExceptionOccurred += (sender, args) => {
     55          e = args.Value;
     56          wh.Set();
     57        };
     58        ga.Stopped += (sender, args) => { wh.Set(); };
     59        ga.Start();
     60        wh.WaitOne();
     61        if (e != null) Assert.Fail(e.Message, e);
    4162      }
    4263    }
Note: See TracChangeset for help on using the changeset viewer.