Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/07/19 09:16:04 (6 years ago)
Author:
ddorfmei
Message:

#2931: Merged revision(s) 16803-16897 from trunk

Location:
branches/2931_OR-Tools_LP_MIP
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/2931_OR-Tools_LP_MIP

  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.Problems.DataAnalysis.Symbolic

  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/LinearModelToTreeConverter.cs

    r16720 r16902  
    3838      double @const = 0) {
    3939
    40       if (factorCoefficients.Length == 0 && coefficients.Length == 0) throw new ArgumentException();
     40      if (factorCoefficients.Length == 0 && coefficients.Length == 0 && @const==0) throw new ArgumentException();
     41
     42      // Combine both trees
     43      ISymbolicExpressionTreeNode add = (new Addition()).CreateTreeNode();
    4144
    4245      // Create tree for double variables
    43       ISymbolicExpressionTree tree = null;     
    4446      if (coefficients.Length > 0) {
    45         tree = CreateTree(variableNames, new int[variableNames.Length], coefficients, @const);
    46         if (factorCoefficients.Length == 0) return tree;
     47        var varTree = CreateTree(variableNames, new int[variableNames.Length], coefficients);
     48        foreach (var varNode in varTree.IterateNodesPrefix().OfType<VariableTreeNode>())
     49          add.AddSubtree(varNode);
    4750      }
    4851
    4952      // Create tree for string variables
    50       ISymbolicExpressionTree factorTree = null;     
    5153      if (factorCoefficients.Length > 0) {
    52         factorTree = CreateTree(factors, factorCoefficients, @const);
    53         if (tree == null) return factorTree; 
     54        var factorTree = CreateTree(factors, factorCoefficients);
     55        foreach (var binFactorNode in factorTree.IterateNodesPrefix().OfType<BinaryFactorVariableTreeNode>())
     56          add.AddSubtree(binFactorNode);
    5457      }
    5558
    56       // Combine both trees
    57       ISymbolicExpressionTreeNode add = tree.Root.GetSubtree(0).GetSubtree(0);
    58       foreach (var binFactorNode in factorTree.IterateNodesPrefix().OfType<BinaryFactorVariableTreeNode>())
    59         add.InsertSubtree(add.SubtreeCount - 1, binFactorNode);
     59      if (@const!=0.0) {
     60        ConstantTreeNode cNode = (ConstantTreeNode)new Constant().CreateTreeNode();
     61        cNode.Value = @const;
     62        add.AddSubtree(cNode);
     63      }
     64
     65      ISymbolicExpressionTree tree = new SymbolicExpressionTree(new ProgramRootSymbol().CreateTreeNode());
     66      ISymbolicExpressionTreeNode startNode = new StartSymbol().CreateTreeNode();
     67      tree.Root.AddSubtree(startNode);
     68      startNode.AddSubtree(add);
    6069      return tree;
    61 
    62       throw new ArgumentException();
    6370    }
    6471
  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionExcelFormatter.cs

    r16803 r16902  
    133133          stringBuilder.Append(")");
    134134        }
    135         stringBuilder.Append(")");
     135        stringBuilder.Append("))");
    136136      } else if (symbol is Constant) {
    137137        ConstantTreeNode constantTreeNode = node as ConstantTreeNode;
  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/IntervalInterpreter.cs

    r16803 r16902  
    7575
    7676    public Interval GetSymbolicExpressionTreeIntervals(ISymbolicExpressionTree tree, IDataset dataset,
    77       out Dictionary<ISymbolicExpressionTreeNode, Interval> nodeIntervals, IEnumerable<int> rows = null) {
     77      out IDictionary<ISymbolicExpressionTreeNode, Interval> nodeIntervals, IEnumerable<int> rows = null) {
    7878      var variableRanges = DatasetUtil.GetVariableRanges(dataset, rows);
    7979      return GetSymbolicExpressionTreeIntervals(tree, variableRanges, out nodeIntervals);
    8080    }
    8181
    82     public Interval GetSymbolicExpressionTreeInterval(ISymbolicExpressionTree tree, Dictionary<string, Interval> variableRanges) {
     82    public Interval GetSymbolicExpressionTreeInterval(ISymbolicExpressionTree tree, IDictionary<string, Interval> variableRanges) {
    8383      lock (syncRoot) {
    8484        EvaluatedSolutions++;
     
    9797
    9898    public Interval GetSymbolicExpressionTreeIntervals(ISymbolicExpressionTree tree,
    99       Dictionary<string, Interval> variableRanges, out Dictionary<ISymbolicExpressionTreeNode, Interval> nodeIntervals) {
     99      IDictionary<string, Interval> variableRanges, out IDictionary<ISymbolicExpressionTreeNode, Interval> nodeIntervals) {
    100100      lock (syncRoot) {
    101101        EvaluatedSolutions++;
     
    124124
    125125
    126     private static Instruction[] PrepareInterpreterState(ISymbolicExpressionTree tree, Dictionary<string, Interval> variableRanges) {
     126    private static Instruction[] PrepareInterpreterState(ISymbolicExpressionTree tree, IDictionary<string, Interval> variableRanges) {
    127127      if (variableRanges == null)
    128128        throw new ArgumentNullException("No variablew ranges are present!", nameof(variableRanges));
     
    141141    }
    142142
    143     private Interval Evaluate(Instruction[] instructions, ref int instructionCounter, Dictionary<ISymbolicExpressionTreeNode, Interval> nodeIntervals = null) {
     143    private Interval Evaluate(Instruction[] instructions, ref int instructionCounter, IDictionary<ISymbolicExpressionTreeNode, Interval> nodeIntervals = null) {
    144144      Instruction currentInstr = instructions[instructionCounter];
    145145      //Use ref parameter, because the tree will be iterated through recursively from the left-side branch to the right side
  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Selectors/DiversitySelector.cs

    r16623 r16902  
    100100    #region Events
    101101    private void RegisterParameterEventHandlers() {
    102       SelectorParameter.ValueChanged += new EventHandler(SelectorParameter_ValueChanged);
    103       CopySelected.ValueChanged += new EventHandler(CopySelected_ValueChanged);
     102      SelectorParameter.ValueChanged += SelectorParameter_ValueChanged;
     103      CopySelectedParameter.ValueChanged += CopySelectedParameter_ValueChanged;
     104      CopySelected.ValueChanged += CopySelected_ValueChanged;
     105    }
     106
     107    private void CopySelectedParameter_ValueChanged(object sender, EventArgs e) {
     108      if (CopySelected.Value != true) {
     109        CopySelected.Value = true;
     110      }
     111      CopySelected.ValueChanged += CopySelected_ValueChanged;
    104112    }
    105113
Note: See TracChangeset for help on using the changeset viewer.