Changeset 225
- Timestamp:
- 05/07/08 01:39:57 (17 years ago)
- Location:
- branches/ExperimentalFunctionsBaking
- Files:
-
- 1 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ExperimentalFunctionsBaking/HeuristicLab.Functions.csproj
r223 r225 57 57 <Compile Include="Constant.cs" /> 58 58 <Compile Include="GreaterThan.cs" /> 59 <Compile Include="FunctionTree.cs" />60 59 <Compile Include="IfThenElse.cs"> 61 60 <SubType>Code</SubType> -
branches/ExperimentalFunctionsBaking/ProgrammableFunction.cs
r220 r225 187 187 } 188 188 189 class ProgrammableFunctionTree : FunctionTree {190 private ProgrammableFunction progFun;191 public ProgrammableFunctionTree() : base() { }192 public ProgrammableFunctionTree(ProgrammableFunction progFun) : base(progFun) {193 this.progFun = progFun;194 }195 public override double Evaluate(Dataset dataset, int sampleIndex) {196 // evaluate sub-trees197 double[] evaluationResults = new double[SubTrees.Count];198 for(int subTree = 0; subTree < SubTrees.Count; subTree++) {199 evaluationResults[subTree] = SubTrees[subTree].Evaluate(dataset, sampleIndex);200 }201 202 // collect parameters203 object[] parameters = new object[LocalVariables.Count + 3];204 parameters[0] = dataset;205 parameters[1] = sampleIndex;206 int i = 2;207 // all local variables are available in the custom function208 foreach(IVariable variable in LocalVariables) {209 parameters[i] = variable;210 i++;211 }212 parameters[i] = evaluationResults;213 return progFun.Call(parameters);214 }215 }189 //class ProgrammableFunctionTree : FunctionTree { 190 // private ProgrammableFunction progFun; 191 // public ProgrammableFunctionTree() : base() { } 192 // public ProgrammableFunctionTree(ProgrammableFunction progFun) : base(progFun) { 193 // this.progFun = progFun; 194 // } 195 // public override double Evaluate(Dataset dataset, int sampleIndex) { 196 // // evaluate sub-trees 197 // double[] evaluationResults = new double[SubTrees.Count]; 198 // for(int subTree = 0; subTree < SubTrees.Count; subTree++) { 199 // evaluationResults[subTree] = SubTrees[subTree].Evaluate(dataset, sampleIndex); 200 // } 201 202 // // collect parameters 203 // object[] parameters = new object[LocalVariables.Count + 3]; 204 // parameters[0] = dataset; 205 // parameters[1] = sampleIndex; 206 // int i = 2; 207 // // all local variables are available in the custom function 208 // foreach(IVariable variable in LocalVariables) { 209 // parameters[i] = variable; 210 // i++; 211 // } 212 // parameters[i] = evaluationResults; 213 // return progFun.Call(parameters); 214 // } 215 //} 216 216 }
Note: See TracChangeset
for help on using the changeset viewer.