Changeset 4897
- Timestamp:
- 11/22/10 10:34:37 (14 years ago)
- Location:
- branches/GP-MemoryOperations/HeuristicLab.Problems.DataAnalysis
- Files:
-
- 3 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/GP-MemoryOperations/HeuristicLab.Problems.DataAnalysis/3.3/HeuristicLab.Problems.DataAnalysis-3.3.csproj
r4562 r4897 149 149 <Compile Include="Symbolic\Symbols\Constant.cs" /> 150 150 <Compile Include="Symbolic\Symbols\ConstantTreeNode.cs" /> 151 <Compile Include="Symbolic\Symbols\ReadMem.cs" /> 152 <Compile Include="Symbolic\Symbols\ReadMemTreeNode.cs" /> 153 <Compile Include="Symbolic\Symbols\SetMem.cs" /> 154 <Compile Include="Symbolic\Symbols\SetMemTreeNode.cs" /> 151 155 <Compile Include="Symbolic\Symbols\LaggedVariable.cs" /> 152 156 <Compile Include="Symbolic\Symbols\LaggedVariableTreeNode.cs" /> -
branches/GP-MemoryOperations/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/FullFunctionalExpressionGrammar.cs
r4722 r4897 60 60 var or = new Or(); 61 61 var not = new Not(); 62 var setMem = new SetMem(); 63 var readMem = new ReadMem(); 62 64 var constant = new Constant(); 63 65 constant.MinValue = -20; … … 67 69 laggedVariable.InitialFrequency = 0.0; 68 70 69 var allSymbols = new List<Symbol>() { add, sub, mul, div, mean, sin, cos, tan, log, exp, @if, gt, lt, and, or, not, constant, variableSymbol, laggedVariable };70 var unaryFunctionSymbols = new List<Symbol>() { sin, cos, tan, log, exp, not 71 var allSymbols = new List<Symbol>() { add, sub, mul, div, mean, sin, cos, tan, log, exp, @if, gt, lt, and, or, not, setMem, readMem, constant, variableSymbol, laggedVariable }; 72 var unaryFunctionSymbols = new List<Symbol>() { sin, cos, tan, log, exp, not, setMem}; 71 73 var binaryFunctionSymbols = new List<Symbol>() { gt, lt }; 72 74 var functionSymbols = new List<Symbol>() { add, sub, mul, div, mean, and, or }; 73 var terminalSymbols = new List<Symbol>() { variableSymbol, constant, laggedVariable };75 var terminalSymbols = new List<Symbol>() { variableSymbol, constant, laggedVariable, readMem }; 74 76 75 77 foreach (var symb in allSymbols) -
branches/GP-MemoryOperations/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/SimpleArithmeticExpressionInterpreter.cs
r4722 r4897 57 57 public const byte NOT = 15; 58 58 59 60 59 public const byte Average = 16; 61 60 … … 66 65 public const byte Constant = 20; 67 66 public const byte Arg = 21; 67 68 public const byte Set = 22; 69 public const byte Read = 23; 68 70 } 69 71 … … 90 92 { typeof(Constant), OpCodes.Constant }, 91 93 { typeof(Argument), OpCodes.Arg }, 94 { typeof(SetMem), OpCodes.Set }, 95 { typeof(ReadMem), OpCodes.Read }, 92 96 }; 93 97 private const int ARGUMENT_STACK_SIZE = 1024; 98 private const int MAX_MEMORY_SIZE = 128; 94 99 95 100 private Dataset dataset; … … 99 104 private double[] argumentStack = new double[ARGUMENT_STACK_SIZE]; 100 105 private int argStackPointer; 106 private double[] memory = new double[MAX_MEMORY_SIZE]; 101 107 102 108 public override bool CanChangeName { … … 124 130 compiler.AddInstructionPostProcessingHook(PostProcessInstruction); 125 131 code = compiler.Compile(tree, MapSymbolToOpCode); 132 Array.Clear(memory, 0, MAX_MEMORY_SIZE); 126 133 foreach (var row in rows) { 127 134 this.row = row; … … 139 146 var variableTreeNode = instr.dynamicNode as LaggedVariableTreeNode; 140 147 instr.iArg0 = (ushort)dataset.GetVariableIndex(variableTreeNode.VariableName); 148 } else if (instr.opCode == OpCodes.Set) { 149 var setMemTreeNode = instr.dynamicNode as SetMemTreeNode; 150 instr.iArg0 = (ushort)setMemTreeNode.Address; 151 } else if (instr.opCode == OpCodes.Read) { 152 var readMemTreeNode = instr.dynamicNode as ReadMemTreeNode; 153 instr.iArg0 = (ushort)readMemTreeNode.Address; 141 154 } 142 155 return instr; … … 290 303 return constTreeNode.Value; 291 304 } 305 case OpCodes.Set: { 306 double d = Evaluate(); 307 memory[currentInstr.iArg0] = d; 308 return d; 309 } 310 case OpCodes.Read: { 311 return memory[currentInstr.iArg0]; 312 } 292 313 default: throw new NotSupportedException(); 293 314 }
Note: See TracChangeset
for help on using the changeset viewer.