Changeset 13870
- Timestamp:
- 06/01/16 17:59:36 (9 years ago)
- Location:
- branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/Grammar.cs
r13867 r13870 3 3 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 4 4 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 5 using HeuristicLab.Problems.DataAnalysis.Symbolic; 5 6 6 7 namespace HeuristicLab.Problems.GeneticProgramming.GlucosePrediction { … … 60 61 var curvedIns = new CurvedInsVariableSymbol("CurvedIns", ""); 61 62 var realInsVar = new RealInsulineVariableSymbol(); 63 64 var constSy = new Constant(); 62 65 // var cteCh = new CteSymbol(); 63 66 … … 98 101 AddSymbol(logIns); 99 102 AddSymbol(realInsVar); 103 AddSymbol(constSy); 100 104 101 105 // <func> ::= <exprgluc> + <exprch> - <exprins> … … 111 115 |realData(k-<idx2hOrMore>) 112 116 */ 113 var opGlucSet = new Symbol[] { plusGluc, minusGluc, prodGluc, divGluc, expGluc, sinGluc, cosGluc, logGluc };117 var opGlucSet = new Symbol[] { plusGluc, minusGluc, prodGluc, divGluc, expGluc, sinGluc, cosGluc, logGluc, predGlucData, realGlucData, constSy }; 114 118 foreach (var opGluc in opGlucSet) { 115 119 AddAllowedChildSymbol(exprGluc, opGluc); 116 120 } 117 121 118 // <exprgluc> ::= (<exprgluc> <op> <exprgluc>) 119 // <exprgluc> ::= (<cte> <op> <exprgluc>)120 foreach (var op in new Symbol[] { plusGluc, minusGluc, prodGluc, divGluc }) {121 AddAllowedChildSymbol(op, exprGluc, 0);122 // AddAllowedChildSymbol(op, cteGluc, 0); // cte is only allowed as first child123 AddAllowedChildSymbol(op, exprGluc, 1);122 123 foreach (var parentOp in new Symbol[] { plusGluc, minusGluc, prodGluc, divGluc }) { 124 foreach (var childOp in opGlucSet) { 125 AddAllowedChildSymbol(parentOp, childOp, 0); 126 AddAllowedChildSymbol(parentOp, childOp, 1); 127 } 124 128 } 125 129 // <exprgluc> ::= <preop> (<exprgluc>) 126 foreach (var op in new Symbol[] { expGluc, sinGluc, cosGluc, logGluc }) { 127 AddAllowedChildSymbol(op, exprGluc, 0); 128 } 129 130 AddAllowedChildSymbol(exprGluc, predGlucData); // <exprgluc> ::= predictedData(k-<idxCurr2h>) 131 AddAllowedChildSymbol(exprGluc, realGlucData); // <exprgluc> ::= realData(k-<idx2hOrMore>) 132 130 foreach (var parentOp in new Symbol[] { expGluc, sinGluc, cosGluc, logGluc }) { 131 foreach (var childOp in opGlucSet) { 132 AddAllowedChildSymbol(parentOp, childOp, 0); 133 } 134 } 133 135 134 136 /* … … 150 152 |beta(0.02*Math.min(48,getPrevDataDistance(1,k,1)),5,2) 151 153 */ 152 var opChSet = new Symbol[] { plusCh, minusCh, prodCh, divCh, expCh, sinCh, cosCh, logCh };154 var opChSet = new Symbol[] { plusCh, minusCh, prodCh, divCh, expCh, sinCh, cosCh, logCh, curvedCh, constSy }; 153 155 foreach (var opCh in opChSet) { 154 156 AddAllowedChildSymbol(exprCh, opCh); 155 157 } 156 158 157 // <exprch> ::= (<exprch> <op> <exprch>) 158 // <exprch> ::= (<cte> <op> <exprch>) 159 foreach (var op in new Symbol[] { plusCh, minusCh, prodCh, divCh }) { 160 AddAllowedChildSymbol(op, exprCh, 0); 161 // AddAllowedChildSymbol(op, cteCh, 0); // cte is only allowed as first child 162 AddAllowedChildSymbol(op, exprCh, 1); 159 foreach (var parentOp in new Symbol[] { plusCh, minusCh, prodCh, divCh }) { 160 foreach (var childOp in opChSet) { 161 AddAllowedChildSymbol(parentOp, childOp, 0); 162 AddAllowedChildSymbol(parentOp, childOp, 1); 163 } 163 164 } 164 165 // <exprch> ::= <preop> (<exprch>) 165 foreach (var op in new Symbol[] { expCh, sinCh, cosCh, logCh }) { 166 AddAllowedChildSymbol(op, exprCh, 0); 167 } 168 // <exprch> ::= (getPrevData(1,k,1) * <cte> * <curvedCH>) 169 AddAllowedChildSymbol(exprCh, curvedCh); 170 166 foreach (var parentOp in new Symbol[] { expCh, sinCh, cosCh, logCh }) { 167 foreach (var childOp in opChSet) { 168 AddAllowedChildSymbol(parentOp, childOp, 0); 169 } 170 } 171 171 172 172 /* … … 192 192 193 193 */ 194 var opInsSet = new Symbol[] { plusIns, minusIns, prodIns, divIns, expIns, sinIns, cosIns, logIns };194 var opInsSet = new Symbol[] { plusIns, minusIns, prodIns, divIns, expIns, sinIns, cosIns, logIns, realInsVar, curvedIns, constSy }; 195 195 foreach (var opIns in opInsSet) { 196 196 AddAllowedChildSymbol(exprIns, opIns); … … 199 199 // <exprins> ::= (<exprins> <op> <exprins>) 200 200 // <exprins> ::= (<cte> <op> <exprins>) 201 foreach (var op in new Symbol[] { plusIns, minusIns, prodIns, divIns }) { 202 AddAllowedChildSymbol(op, exprIns, 0); 203 // AddAllowedChildSymbol(op, cteIns, 0); // cte is only allowed as first child 204 AddAllowedChildSymbol(op, exprIns, 1); 201 foreach (var parentOp in new Symbol[] { plusIns, minusIns, prodIns, divIns }) { 202 foreach (var childOp in opInsSet) { 203 AddAllowedChildSymbol(parentOp, childOp, 0); 204 AddAllowedChildSymbol(parentOp, childOp, 1); 205 } 205 206 } 206 207 // <exprins> ::= <preop> (<exprins>) 207 208 foreach (var op in new Symbol[] { expIns, sinIns, cosIns, logIns }) { 208 AddAllowedChildSymbol(op, exprIns, 0); 209 } 210 211 // <exprIns> ::= getVariable(2,k-<idx>) 212 AddAllowedChildSymbol(exprIns, realInsVar); 213 214 AddAllowedChildSymbol(exprIns, curvedIns); 209 foreach (var childOp in opInsSet) { 210 AddAllowedChildSymbol(op, childOp, 0); 211 } 212 } 215 213 216 214 // root is func -
branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction-3.3.csproj
r13865 r13870 135 135 <HintPath>..\..\trunk\sources\bin\HeuristicLab.Problems.DataAnalysis-3.4.dll</HintPath> 136 136 </Reference> 137 <Reference Include="HeuristicLab.Problems.DataAnalysis.Symbolic-3.4, Version=3.4.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 138 <SpecificVersion>False</SpecificVersion> 139 <HintPath>..\..\trunk\sources\bin\HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.dll</HintPath> 140 </Reference> 137 141 <Reference Include="HeuristicLab.Problems.Instances-3.3"> 138 142 <HintPath>..\..\trunk\sources\bin\HeuristicLab.Problems.Instances-3.3.dll</HintPath> -
branches/HeuristicLab.Problems.GeneticProgramming.BloodGlucosePrediction/Interpreter.cs
r13867 r13870 7 7 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 8 8 using HeuristicLab.Problems.DataAnalysis; 9 using HeuristicLab.Problems.DataAnalysis.Symbolic; 9 10 10 11 namespace HeuristicLab.Problems.GeneticProgramming.GlucosePrediction { … … 26 27 }; 27 28 data.predGluc = new double[data.realGluc.Length]; 29 Array.Copy(data.realGluc, data.predGluc, data.predGluc.Length); 28 30 for (int k = 0; k < data.predGluc.Length; k++) { 29 31 if (double.IsNaN(targetGluc[k])) { … … 122 124 GetMaxValueAndDistance(data.realIns, k, out maxVal, out maxValDistance, maxDistance: 48); 123 125 return n.Weight * (sum - maxVal) * maxVal * Beta(maxValDistance / 48.0, n.Alpha, n.Beta); 126 } else if (node.Symbol is Constant) { 127 var n = (ConstantTreeNode)node; 128 return n.Value; 124 129 } else { 125 130 throw new InvalidProgramException("found unknown symbol " + node.Symbol);
Note: See TracChangeset
for help on using the changeset viewer.