Changeset 17292 for branches/2994-AutoDiffForIntervals/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/Interpreter.cs
- Timestamp:
- 10/02/19 14:49:31 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2994-AutoDiffForIntervals/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/Interpreter.cs
r17240 r17292 381 381 var code = Compile(tree); 382 382 Evaluate(code); 383 if (code[0].value.LowerBound.Value.Value > code[0].value.UpperBound.Value.Value) throw new InvalidProgramException($"lower: {code[0].value.LowerBound.Value.Value} > upper: {code[0].value.UpperBound.Value.Value}"); 383 384 return new Interval(code[0].value.LowerBound.Value.Value, code[0].value.UpperBound.Value.Value); 384 385 } … … 408 409 instruction.dblVal = constant.Value; 409 410 instruction.value = new AlgebraicInterval( 410 new MultivariateDual<AlgebraicDouble>( constant.Value, constant, 1.0),411 new MultivariateDual<AlgebraicDouble>( constant.Value, constant, 1.0) // use node as key411 new MultivariateDual<AlgebraicDouble>(instruction.dblVal, constant, 1.0), 412 new MultivariateDual<AlgebraicDouble>(instruction.dblVal, constant, 1.0) // use node as key 412 413 ); 413 414 } … … 415 416 protected override void InitializeTerminalInstruction(ref Instruction instruction, VariableTreeNode variable) { 416 417 instruction.dblVal = variable.Weight; 418 var v1 = instruction.dblVal * intervals[variable.VariableName].LowerBound; 419 var v2 = instruction.dblVal * intervals[variable.VariableName].UpperBound; 420 var lower = Math.Min(v1, v2); 421 var upper = Math.Max(v1, v2); 422 // we assume that the for variable nodes ( v(x,w) = w * x ) the gradient is returned for parameter w 417 423 instruction.value = new AlgebraicInterval( 418 low: new MultivariateDual<AlgebraicDouble>( intervals[variable.VariableName].LowerBound, variable, intervals[variable.VariableName].LowerBound), // bounds change by variable value d/dc (c I(var)) = I(var)419 high: new MultivariateDual<AlgebraicDouble>( intervals[variable.VariableName].UpperBound, variable,intervals[variable.VariableName].UpperBound)424 low: new MultivariateDual<AlgebraicDouble>(v: lower, key: variable, dv: intervals[variable.VariableName].LowerBound), 425 high: new MultivariateDual<AlgebraicDouble>(v: upper, key: variable, dv: intervals[variable.VariableName].UpperBound) 420 426 ); 421 427 }
Note: See TracChangeset
for help on using the changeset viewer.