Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9847 for branches


Ignore:
Timestamp:
08/05/13 12:23:31 (11 years ago)
Author:
gkronber
Message:

#2026 lawn mower programs are only executed once. This makes the problem much harder.

File:
1 edited

Legend:

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

    r9846 r9847  
    11PROBLEM LawnMower
    22/* the lawn mower problem with syntax to enforce that constants and sums are only used
    3  * in sub-trees under the "frog" symbol. Interestingly, this increases success rates in
    4  * comparison with the original formulation where functions could be combined freely.
     3 * in sub-trees under the "frog" symbol. (Original formulation by Koza did not use a grammar)
    54 */
    65CODE <<
     
    2019  class World {
    2120    private bool[,] mowed = new bool[Width, Height];
    22     public World() {
    23       Reset();
    24     }
    25     public void Reset() {
    26       for(int col = 0; col < Width; col++)
    27         for(int row = 0; row < Height; row++) {
    28           mowed[col, row] = false;
    29         }
    30     }
     21
    3122    public void SetCellMowed(Point p) {
    3223      mowed[p.x, p.y] = true;
     
    10899  }
    109100
    110 World CreateWorld() {   
    111   return new World();
    112 }
    113 
    114 World world;
    115101/* set of possible values for constants [-100, 100] */
    116102int[] ints = Enumerable.Range(-100, 201).ToArray();
    117103>>
    118104INIT <<
    119   world = CreateWorld();
    120105>>
    121106
     
    165150MAXIMIZE
    166151  <<   
    167     world.Reset();
     152    var world = new World();
    168153    var state = new MowerState() {Position = new Point(0,0),
    169154                                  Energy = 2 * Height * Width,
    170155                                  Direction = Direction.South,
    171156                                  World = world};
    172     while(state.Energy > 0) {
    173       LawnMower(state);
    174     }
     157    world.SetCellMowed(state.Position); // set initial cell mowed
     158    // execute the mower program once
     159    LawnMower(state);
    175160    return (double)state.MowedCells;
    176161  >> 
Note: See TracChangeset for help on using the changeset viewer.