Changeset 18142
- Timestamp:
- 12/16/21 11:22:29 (3 years ago)
- Location:
- branches/3140_NumberSymbol
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicExpressionTreeChart.cs
r18115 r18142 104 104 var symbol = dialog.SelectedSymbol; 105 105 var node = symbol.CreateTreeNode(); 106 if (node is INumericTreeNode numTreeNode) {106 if (node is NumberTreeNode numTreeNode) { 107 107 numTreeNode.Value = double.Parse(dialog.numberValueTextBox.Text); 108 108 } else if (node is VariableTreeNode) { … … 132 132 ISymbolicExpressionTreeNode newNode = null; 133 133 var result = DialogResult.Cancel; 134 if (node is INumericTreeNode) {134 if (node is NumberTreeNode) { 135 135 using (var dialog = new NumberNodeEditDialog(node)) { 136 136 dialog.ShowDialog(this); -
branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeConstantNodeEditDialog.cs
r18115 r18142 29 29 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views { 30 30 public partial class NumberNodeEditDialog : Form { 31 private INumericTreeNode numberTreeNode;32 public INumericTreeNode NewNode {31 private NumberTreeNode numberTreeNode; 32 public NumberTreeNode NewNode { 33 33 get { return numberTreeNode; } 34 34 set { 35 35 if (InvokeRequired) 36 Invoke(new Action<SymbolicExpressionTreeNode>(x => numberTreeNode = ( INumericTreeNode)x), value);36 Invoke(new Action<SymbolicExpressionTreeNode>(x => numberTreeNode = (NumberTreeNode)x), value); 37 37 else 38 38 numberTreeNode = value; … … 43 43 InitializeComponent(); 44 44 oldValueTextBox.TabStop = false; // cannot receive focus using tab key 45 NewNode = ( INumericTreeNode)node;45 NewNode = (NumberTreeNode)node; 46 46 InitializeFields(); 47 47 } … … 103 103 // we impose an extra validation condition: that the new value is different from the original value 104 104 if (numberTreeNode.Value.Equals(value)) return; 105 106 105 numberTreeNode.Value = value; 107 106 DialogResult = DialogResult.OK; -
branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Converters/DerivativeCalculator.cs
r18130 r18142 156 156 var newPower = (ISymbolicExpressionTreeNode)branch.Clone(); 157 157 var f = (ISymbolicExpressionTreeNode)newPower.GetSubtree(0).Clone(); 158 var newExponent = ( INumericTreeNode)numberSy.CreateTreeNode();159 newExponent.Value = (( INumericTreeNode)newPower.GetSubtree(1)).Value - 1;158 var newExponent = (NumberTreeNode)numberSy.CreateTreeNode(); 159 newExponent.Value = ((NumberTreeNode)newPower.GetSubtree(1)).Value - 1; 160 160 return Product(Product(CreateNumber(exponent.Value), newPower), Derive(f, variableName)); 161 161 } else throw new NotSupportedException("Cannot derive non-integer powers"); -
branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Hashing/SymbolicExpressionTreeHash.cs
r18115 r18142 215 215 variableTreeNode.Weight = variable.Weight; 216 216 } else if (node.Data is INumericTreeNode existingNumNode) { 217 var newNumNode = ( INumericTreeNode)treeNodes[i];217 var newNumNode = (NumberTreeNode)treeNodes[i]; 218 218 newNumNode.Value = existingNumNode.Value; 219 219 } … … 277 277 278 278 var symbol = child.Data.Symbol; 279 if (child.Data is INumericTreeNode firstNum) {279 if (child.Data is NumberTreeNode firstNum) { 280 280 // fold sibling number nodes into the first number 281 281 for (int k = j + 1; k < children.Length; ++k) { -
branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Importer/SymbolicExpressionImporter.cs
r18123 r18142 162 162 return tree; 163 163 } else if (tokens.Peek().Symbol == TokenSymbol.CONSTANT) { 164 var t = (INumericTreeNode)number.CreateTreeNode();165 t.Value = tokens.Dequeue().DoubleValue;166 return t;164 var value = tokens.Dequeue().DoubleValue; 165 var constant = new Constant() { Value = value }; 166 return constant.CreateTreeNode(); 167 167 } else if (tokens.Peek().Symbol == TokenSymbol.LBRACKET) { 168 168 Expect(Token.LBRACKET, tokens); 169 169 Expect(Token.NUM, tokens); 170 var t = ( INumericTreeNode)number.CreateTreeNode();170 var t = (NumberTreeNode)number.CreateTreeNode(); 171 171 if (tokens.Peek().Symbol == TokenSymbol.EQ) { 172 172 Expect(Token.EQ, tokens); -
branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interfaces/INumericTreeNode.cs
r18100 r18142 26 26 [StorableType("194AFEE6-96E2-4F53-A5AD-D3CCFE928AE5")] 27 27 public interface INumericTreeNode : ISymbolicExpressionTreeNode { 28 double Value { get; set;}28 double Value { get; } 29 29 } 30 30 } -
branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Symbols/ConstantTreeNode.cs
r18115 r18142 30 30 public new Constant Symbol => (Constant) base.Symbol; 31 31 32 public double Value { 33 get => Symbol.Value; 34 set => throw new System.NotSupportedException("Cannot change the value of a constant."); 35 } 32 public double Value => Symbol.Value; 36 33 37 34 [StorableConstructor] -
branches/3140_NumberSymbol/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisProblemData.cs
r18140 r18142 187 187 Parameters.Add(new FixedValueParameter<ReadOnlyItemList<ITransformation>>(TransformationsParameterName, "", transformationsList.AsReadOnly())); 188 188 189 IntervalCollection varRanges = null; 189 190 if (variableRanges == null) { 190 var iableRanges = Dataset.GetVariableRanges();191 varRanges = Dataset.GetVariableRanges(); 191 192 }else { 192 foreach (var entry in variableRanges.GetVariableIntervals()) 193 VariableRanges.SetInterval(entry.Item1, entry.Item2); 194 } 195 196 Parameters.Add(new FixedValueParameter<IntervalCollection>(VariableRangesParameterName, variableRanges)); 193 varRanges = (IntervalCollection) variableRanges.Clone(); 194 } 195 196 Parameters.Add(new FixedValueParameter<IntervalCollection>(VariableRangesParameterName, varRanges)); 197 197 198 198 TransformationsParameter.Hidden = true;
Note: See TracChangeset
for help on using the changeset viewer.