Changeset 10099
- Timestamp:
- 10/31/13 13:11:51 (11 years ago)
- Location:
- branches/HeuristicLab.Problems.GPDL/Examples
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Problems.GPDL/Examples/Artificial Ant.txt
r10080 r10099 121 121 122 122 public void TurnLeft() { 123 Steps++;123 if(Steps++ > MaxSteps) return; 124 124 switch(Direction) { 125 125 case Direction.West: Direction = Direction.South; break; … … 130 130 } 131 131 public void TurnRight() { 132 Steps++;132 if(Steps++ > MaxSteps) return; 133 133 switch(Direction) { 134 134 case Direction.West: Direction = Direction.North; break; … … 139 139 } 140 140 public void MoveForward() { 141 if(Steps++ > MaxSteps) return; 141 142 Position = NextPosition; 142 Steps++;143 143 if(World.FoodAt(Position)) { 144 144 World.RemoveFoodAt(Position); -
branches/HeuristicLab.Problems.GPDL/Examples/Factorial.txt
r10061 r10099 11 11 public int GetValue(string id) { 12 12 int val = 0; 13 values.TryGetValue(id, out val); 13 values.TryGetValue(id, out val); 14 14 return val; 15 15 } … … 18 18 19 19 NONTERMINALS 20 Program<<int n, out int r>>. /* return value is the result of the last statement. */21 StatSeq<<out int r>>. 20 Program<<int n, out int r>>. /* return value is the result of the last statement. */ 21 StatSeq<<out int r>>. 22 22 AssignStat<<out int r>>. /* result of assignment is the assigned value */ 23 23 IncStat<<out int r>>. 24 24 DecStat<<out int r>>. 25 25 WhileStat<<out int r>>. /* result of while loop is the result of the last executed statement */ 26 ReturnStat<<out int r>>.27 26 Expr<<out int r>>. 28 27 AdditionExpr<<out int r>>. … … 36 35 AssignStatAndStatSeq<<out int r>>. 37 36 WhileStatAndStatSeq<<out int r>>. 38 ReturnStatAndStatSeq<<out int r>>.39 37 40 38 TERMINALS … … 56 54 . 57 55 StatSeq<<out int r>> = LOCAL << r = 0; >> 58 Nothing<<out r>> 56 Nothing<<out r>> 59 57 | AssignStatAndStatSeq<<out r>> 60 58 | WhileStatAndStatSeq<<out r>> 61 | ReturnStatAndStatSeq<<out r>> 62 | IncStat<<out r>> 63 | DecStat<<out r>> 59 | IncStat<<out r>> 60 | DecStat<<out r>> 64 61 . 65 62 … … 69 66 WhileStatAndStatSeq<<out int r>> = 70 67 StatSeq<<out r>> WhileStat<<out r>> 71 .72 ReturnStatAndStatSeq<<out int r>> =73 StatSeq<<out r>> ReturnStat<<out r>>74 68 . 75 69 … … 90 84 StatSeq<<out r>> SEM << } >> 91 85 . 92 ReturnStat<<out int r>> = Expr<<out r>> SEM << return; >> 93 . 86 94 87 Expr<<out int r>> = LOCAL << string id; >> 95 88 AdditionExpr<<out r>> … … 98 91 | DivisionExpr<<out r>> 99 92 | Const<<out r>> 100 | ident<<out id>> 93 | ident<<out id>> SEM << r = symTab.GetValue(id); >> 101 94 . 102 AdditionExpr<<out int r>> = 103 Expr<<out e1>> Expr<<out e2>> 95 AdditionExpr<<out int r>> = LOCAL << int e1, e2; >> 96 Expr<<out e1>> Expr<<out e2>> SEM << r = e1 + e2; >> 104 97 . 105 SubtractionExpr<<out int r>> = 106 Expr<<out e1>> Expr<<out e2>> 98 SubtractionExpr<<out int r>> = LOCAL << int e1, e2; >> 99 Expr<<out e1>> Expr<<out e2>> SEM << r = e1 - e2; >> 107 100 . 108 MultiplicationExpr<<out int r>> = 109 Expr<<out e1>> Expr<<out e2>> 101 MultiplicationExpr<<out int r>> = LOCAL << int e1, e2; >> 102 Expr<<out e1>> Expr<<out e2>> SEM << r = e1 * e2; >> 110 103 . 111 DivisionExpr<<out int r>> = 112 Expr<<out e1>> Expr<<out e2>> 104 DivisionExpr<<out int r>> = LOCAL << int e1, e2; >> 105 Expr<<out e1>> Expr<<out e2>> SEM << r = e2 == 0 ? 1 : e1 / e2; >> 113 106 . 114 107 BooleanExpr<<out bool b>> = … … 117 110 | NotExpr<<out b>> 118 111 . 119 NotExpr<<out bool b>> = 120 BooleanExpr<<out notB>> 112 NotExpr<<out bool b>> = LOCAL << bool notB; >> 113 BooleanExpr<<out notB>> SEM << b = !notB; >> 121 114 . 122 LessThanExpr<<out bool b>> = 123 Expr<<out lhs>> Expr<<out rhs>> 115 LessThanExpr<<out bool b>> = LOCAL << int lhs, rhs; >> 116 Expr<<out lhs>> Expr<<out rhs>> SEM << b = lhs < rhs; >> 124 117 . 125 EqualExpr<<out bool b>> = 126 Expr<<out lhs>> Expr<<out rhs>> 118 EqualExpr<<out bool b>> = LOCAL << int lhs, rhs; >> 119 Expr<<out lhs>> Expr<<out rhs>> SEM << b = lhs == rhs; >> 127 120 . 128 121 129 122 130 MINIMIZE /* could also use the keyword MAXIMIZE here */123 MINIMIZE 131 124 << 132 125 var ns = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; -
branches/HeuristicLab.Problems.GPDL/Examples/Fib.txt
r10061 r10099 18 18 19 19 NONTERMINALS 20 Program<<int n, out int r>>. /* return value is the result of the last statement. */21 StatSeq<<out int r>>. 20 Program<<int n, out int r>>. /* return value is the result of the last statement. */ 21 StatSeq<<out int r>>. 22 22 AssignStat<<out int r>>. /* result of assignment is the assigned value */ 23 23 IncStat<<out int r>>. 24 24 DecStat<<out int r>>. 25 25 WhileStat<<out int r>>. /* result of while loop is the result of the last executed statement */ 26 ReturnStat<<out int r>>.27 26 Expr<<out int r>>. 28 27 AdditionExpr<<out int r>>. … … 36 35 AssignStatAndStatSeq<<out int r>>. 37 36 WhileStatAndStatSeq<<out int r>>. 38 ReturnStatAndStatSeq<<out int r>>.39 37 40 38 TERMINALS … … 56 54 . 57 55 StatSeq<<out int r>> = LOCAL << r = 0; >> 58 Nothing<<out r>> 56 Nothing<<out r>> 59 57 | AssignStatAndStatSeq<<out r>> 60 58 | WhileStatAndStatSeq<<out r>> 61 | ReturnStatAndStatSeq<<out r>> 62 | IncStat<<out r>> 63 | DecStat<<out r>> 59 | IncStat<<out r>> 60 | DecStat<<out r>> 64 61 . 65 62 … … 69 66 WhileStatAndStatSeq<<out int r>> = 70 67 StatSeq<<out r>> WhileStat<<out r>> 71 .72 ReturnStatAndStatSeq<<out int r>> =73 StatSeq<<out r>> ReturnStat<<out r>>74 68 . 75 69 … … 89 83 BooleanExpr<<out b>> SEM << if(!b) break; >> 90 84 StatSeq<<out r>> SEM << } >> 91 .92 ReturnStat<<out int r>> = Expr<<out r>> SEM << return; >>93 85 . 94 86 Expr<<out int r>> = LOCAL << string id; >> … … 128 120 129 121 130 MINIMIZE /* could also use the keyword MAXIMIZE here */122 MINIMIZE 131 123 << 132 124 var ns = new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; -
branches/HeuristicLab.Problems.GPDL/Examples/symbreg HEAL.txt
r10086 r10099 43 43 double r = 0.0; 44 44 num = sumxy - ( ( sumx * sumy ) / n ); 45 den = Math.Sqrt( ( sumxSq - ( sumx *sumx ) / n ) *46 ( sumySq - ( sumy *sumy ) / n ) );45 den = Math.Sqrt( ( sumxSq - ( sumx * sumx ) / n ) * 46 ( sumySq - ( sumy * sumy ) / n ) ); 47 47 if(den > 0){ 48 48 r = num / den; … … 53 53 54 54 INIT << 55 // generate 500 case of poly-10 benchmark function55 // generate 500 cases of poly-10 benchmark function 56 56 int n = 500; 57 57 variableNames = new string[] {"x1", "x2", "x3", "x4", "x5", "x6", "x7", "x8", "x9", "x10" }; … … 84 84 Const<<out double val>> 85 85 CONSTRAINTS 86 val IN RANGE <<-10 0>> .. <<100>>86 val IN RANGE <<-10.0>> .. <<10.0>> 87 87 . 88 88 Var<<out string varName, out double weight>> 89 89 CONSTRAINTS 90 90 varName IN SET <<variableNames>> 91 weight IN RANGE <<-10 0>> .. <<100>>91 weight IN RANGE <<-10.0>> .. <<10.0>> 92 92 . 93 93 -
branches/HeuristicLab.Problems.GPDL/Examples/symbreg Koza.txt
r10086 r10099 54 54 55 55 INIT << 56 // generate 500 case of poly-10 benchmark function56 // generate 500 cases of poly-10 benchmark function 57 57 int n = 500; 58 58 variableNames = new string[] {"x1", "x2", "x3", "x4", "x5", "x6", "x7", "x8", "x9", "x10" }; … … 73 73 rows = System.Linq.Enumerable.Range(0, n).ToArray(); 74 74 75 // generate 100 random constants in [-10 0.0 .. 100.0[76 randomConsts = Enumerable.Range(0, 100).Select(i => rand.NextDouble()*20 0.0 - 100.0).ToArray();75 // generate 100 random constants in [-10.0 .. 10.0[ 76 randomConsts = Enumerable.Range(0, 100).Select(i => rand.NextDouble()*20.0 - 10.0).ToArray(); 77 77 >> 78 78
Note: See TracChangeset
for help on using the changeset viewer.