Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/16/09 14:38:15 (15 years ago)
Author:
gkronber
Message:

Fixed incompatibility of HL2 model export with old models. #710

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/ModelAnalyzerExporter.cs

    r2166 r2167  
    120120
    121121    public static string ExportToHL2(this Constant constant, IFunctionTree tree) {
    122       double value = ((DoubleData)tree.GetLocalVariable(Constant.VALUE).Value).Data;
     122      HeuristicLab.Core.IItem constantItem = tree.GetLocalVariable(Constant.VALUE).Value;
     123      double value;
     124      if (constantItem is ConstrainedDoubleData) {
     125        value = ((ConstrainedDoubleData)constantItem).Data;
     126      } else {
     127        value = ((DoubleData)constantItem).Data;
     128      }
    123129      return "[T]Constant(" + value.ToString("r") + ";0;0)";
    124130    }
     
    129135
    130136    public static string ExportToHL2(this Differential differential, IFunctionTree tree) {
    131       double weight = ((DoubleData)tree.GetLocalVariable(Differential.WEIGHT).Value).Data;
    132       double index = ((ConstrainedIntData)tree.GetLocalVariable(Differential.INDEX).Value).Data;
    133       double offset = ((ConstrainedIntData)tree.GetLocalVariable(Differential.OFFSET).Value).Data;
     137      HeuristicLab.Core.IItem weightItem = tree.GetLocalVariable(Differential.WEIGHT).Value;
     138      double weight;
     139      if (weightItem is ConstrainedDoubleData) {
     140        weight = ((ConstrainedDoubleData)weightItem).Data;
     141      } else {
     142        weight = ((DoubleData)weightItem).Data;
     143      }
     144      var index = tree.GetLocalVariable(Differential.INDEX).Value;
     145      var offset = ((ConstrainedDoubleData)tree.GetLocalVariable(Differential.OFFSET).Value).Data;
    134146
    135147      return "[T]Differential(" + weight.ToString("r") + ";" + index + ";" + -offset + ")";
     
    177189
    178190    public static string ExportToHL2(this Variable variable, IFunctionTree tree) {
    179       double weight = ((DoubleData)tree.GetLocalVariable(Variable.WEIGHT).Value).Data;
     191      HeuristicLab.Core.IItem weightItem = tree.GetLocalVariable(Differential.WEIGHT).Value;
     192      double weight;
     193      if (weightItem is ConstrainedDoubleData) {
     194        weight = ((ConstrainedDoubleData)weightItem).Data;
     195      } else {
     196        weight = ((DoubleData)weightItem).Data;
     197      }
    180198      double index = ((ConstrainedIntData)tree.GetLocalVariable(Variable.INDEX).Value).Data;
    181199      double offset = ((ConstrainedIntData)tree.GetLocalVariable(Variable.OFFSET).Value).Data;
Note: See TracChangeset for help on using the changeset viewer.