Changeset 17292


Ignore:
Timestamp:
10/02/19 14:49:31 (12 days ago)
Author:
gkronber
Message:

#2994: fixed a bug in the interval calculation for variables

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2994-AutoDiffForIntervals/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/Interpreter.cs

    r17240 r17292  
    381381      var code = Compile(tree);
    382382      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}");
    383384      return new Interval(code[0].value.LowerBound.Value.Value, code[0].value.UpperBound.Value.Value);
    384385    }
     
    408409      instruction.dblVal = constant.Value;
    409410      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 key
     411        new MultivariateDual<AlgebraicDouble>(instruction.dblVal, constant, 1.0),
     412        new MultivariateDual<AlgebraicDouble>(instruction.dblVal, constant, 1.0) // use node as key
    412413        );
    413414    }
     
    415416    protected override void InitializeTerminalInstruction(ref Instruction instruction, VariableTreeNode variable) {
    416417      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
    417423      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)
    420426        );
    421427    }
Note: See TracChangeset for help on using the changeset viewer.