Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Modeling Database Backend/sources/HeuristicLab.SupportVectorMachines/3.2/SupportVectorRegression.cs @ 2201

Last change on this file since 2201 was 2201, checked in by gkronber, 15 years ago

Added statements to set the input variables of models in all regression engines. #712

File size: 22.1 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Collections.Generic;
24using System.Linq;
25using System.Text;
26using HeuristicLab.Core;
27using System.Xml;
28using System.Diagnostics;
29using HeuristicLab.DataAnalysis;
30using HeuristicLab.Data;
31using HeuristicLab.Operators;
32using HeuristicLab.GP.StructureIdentification;
33using HeuristicLab.Logging;
34using HeuristicLab.Operators.Programmable;
35using HeuristicLab.Modeling;
36using HeuristicLab.Random;
37using HeuristicLab.Selection;
38
39namespace HeuristicLab.SupportVectorMachines {
40  public class SupportVectorRegression : ItemBase, IEditable, IAlgorithm {
41
42    public string Name { get { return "SupportVectorRegression"; } }
43    public string Description { get { return "TODO"; } }
44
45    private SequentialEngine.SequentialEngine engine;
46    public IEngine Engine {
47      get { return engine; }
48    }
49
50    public Dataset Dataset {
51      get { return ProblemInjector.GetVariableValue<Dataset>("Dataset", null, false); }
52      set { ProblemInjector.GetVariable("Dataset").Value = value; }
53    }
54
55    public int TargetVariable {
56      get { return ProblemInjector.GetVariableValue<IntData>("TargetVariable", null, false).Data; }
57      set { ProblemInjector.GetVariableValue<IntData>("TargetVariable", null, false).Data = value; }
58    }
59
60    public IOperator ProblemInjector {
61      get {
62        IOperator main = GetMainOperator();
63        return main.SubOperators[0].SubOperators[1];
64      }
65      set {
66        IOperator main = GetMainOperator();
67        main.RemoveSubOperator(1);
68        main.AddSubOperator(value, 1);
69      }
70    }
71
72    public IModel Model {
73      get {
74        if (!engine.Terminated) throw new InvalidOperationException("The algorithm is still running. Wait until the algorithm is terminated to retrieve the result.");
75        IScope bestModelScope = engine.GlobalScope.SubScopes[0];
76        return CreateSVMModel(bestModelScope);
77      }
78    }
79
80    public DoubleArrayData NuList {
81      get { return GetVariableInjector().GetVariable("NuList").GetValue<DoubleArrayData>(); }
82      set { GetVariableInjector().GetVariable("NuList").Value = value; }
83    }
84
85    public int MaxNuIndex {
86      get { return GetVariableInjector().GetVariable("MaxNuIndex").GetValue<IntData>().Data; }
87      set { GetVariableInjector().GetVariable("MaxNuIndex").GetValue<IntData>().Data = value; }
88    }
89
90    public DoubleArrayData CostList {
91      get { return GetVariableInjector().GetVariable("CostList").GetValue<DoubleArrayData>(); }
92      set { GetVariableInjector().GetVariable("CostList").Value = value; }
93    }
94
95    public int MaxCostIndex {
96      get { return GetVariableInjector().GetVariable("MaxCostIndex").GetValue<IntData>().Data; }
97      set { GetVariableInjector().GetVariable("MaxCostIndex").GetValue<IntData>().Data = value; }
98    }
99
100    public DoubleArrayData GammaList {
101      get { return GetVariableInjector().GetVariable("GammaList").GetValue<DoubleArrayData>(); }
102      set { GetVariableInjector().GetVariable("GammaList").Value = value; }
103    }
104
105    public int MaxGammaIndex {
106      get { return GetVariableInjector().GetVariable("MaxGammaIndex").GetValue<IntData>().Data; }
107      set { GetVariableInjector().GetVariable("MaxGammaIndex").GetValue<IntData>().Data = value; }
108    }
109
110    public SupportVectorRegression() {
111      engine = new SequentialEngine.SequentialEngine();
112      CombinedOperator algo = CreateAlgorithm();
113      engine.OperatorGraph.AddOperator(algo);
114      engine.OperatorGraph.InitialOperator = algo;
115      MaxCostIndex = CostList.Data.Length;
116      MaxNuIndex = NuList.Data.Length;
117      MaxGammaIndex = GammaList.Data.Length;
118    }
119
120    private CombinedOperator CreateAlgorithm() {
121      CombinedOperator algo = new CombinedOperator();
122      SequentialProcessor seq = new SequentialProcessor();
123      algo.Name = "SupportVectorRegression";
124      seq.Name = "SupportVectorRegression";
125
126      IOperator initialization = CreateInitialization();
127      IOperator main = CreateMainLoop();
128      IOperator postProc = CreateModelAnalyser();
129
130      seq.AddSubOperator(initialization);
131      seq.AddSubOperator(main);
132      seq.AddSubOperator(postProc);
133
134      algo.OperatorGraph.InitialOperator = seq;
135      algo.OperatorGraph.AddOperator(seq);
136
137      return algo;
138    }
139
140    private IOperator CreateInitialization() {
141      SequentialProcessor seq = new SequentialProcessor();
142      seq.Name = "Initialization";
143      seq.AddSubOperator(CreateGlobalInjector());
144      ProblemInjector probInjector = new ProblemInjector();
145      probInjector.GetVariableInfo("MaxNumberOfTrainingSamples").Local = true;
146      probInjector.AddVariable(new Variable("MaxNumberOfTrainingSamples", new IntData(5000)));
147      seq.AddSubOperator(probInjector);
148      seq.AddSubOperator(new RandomInjector());
149
150      DatasetShuffler shuffler = new DatasetShuffler();
151      shuffler.GetVariableInfo("ShuffleStart").ActualName = "TrainingSamplesStart";
152      shuffler.GetVariableInfo("ShuffleEnd").ActualName = "TrainingSamplesEnd";
153      seq.AddSubOperator(shuffler);
154      return seq;
155    }
156
157    private IOperator CreateMainLoop() {
158      SequentialProcessor main = new SequentialProcessor();
159      main.Name = "Main";
160      #region initial solution
161      SubScopesCreater modelScopeCreator = new SubScopesCreater();
162      modelScopeCreator.GetVariableInfo("SubScopes").Local = true;
163      modelScopeCreator.AddVariable(new HeuristicLab.Core.Variable("SubScopes", new IntData(1)));
164      main.AddSubOperator(modelScopeCreator);
165     
166      SequentialSubScopesProcessor seqSubScopesProc = new SequentialSubScopesProcessor();
167      IOperator modelProcessor = CreateModelProcessor();
168
169      seqSubScopesProc.AddSubOperator(modelProcessor);
170      main.AddSubOperator(seqSubScopesProc);
171      #endregion
172
173      SequentialProcessor nuLoop = new SequentialProcessor();
174      nuLoop.Name = "NuLoop";
175
176      SequentialProcessor gammaLoop = new SequentialProcessor();
177      gammaLoop.Name = "GammaLoop";
178
179      nuLoop.AddSubOperator(gammaLoop);
180
181      IOperator costCounter = CreateCounter("Cost");
182      IOperator costComparator = CreateComparator("Cost");
183      gammaLoop.AddSubOperator(costCounter);
184      gammaLoop.AddSubOperator(costComparator);
185
186      ConditionalBranch costBranch = new ConditionalBranch();
187      costBranch.Name = "IfValidCostIndex";
188      costBranch.GetVariableInfo("Condition").ActualName = "RepeatCostLoop";
189
190      // build cost loop
191      SequentialProcessor costLoop = new SequentialProcessor();
192      costLoop.Name = "CostLoop";
193
194      #region selection of better solution
195      costLoop.AddSubOperator(modelScopeCreator);
196      SequentialSubScopesProcessor subScopesProcessor = new SequentialSubScopesProcessor();
197      costLoop.AddSubOperator(subScopesProcessor);
198      subScopesProcessor.AddSubOperator(new EmptyOperator());
199      subScopesProcessor.AddSubOperator(modelProcessor);
200
201      Sorter sorter = new Sorter();
202      sorter.GetVariableInfo("Value").ActualName = "ValidationQuality";
203      sorter.GetVariableInfo("Descending").Local = true;
204      sorter.AddVariable(new Variable("Descending", new BoolData(false)));
205      costLoop.AddSubOperator(sorter);
206
207      LeftSelector selector = new LeftSelector();
208      selector.GetVariableInfo("Selected").Local = true;
209      selector.AddVariable(new Variable("Selected", new IntData(1)));
210      costLoop.AddSubOperator(selector);
211
212      RightReducer reducer = new RightReducer();
213      costLoop.AddSubOperator(reducer);
214      #endregion
215
216      costLoop.AddSubOperator(costCounter);
217      costLoop.AddSubOperator(costComparator);
218
219      costBranch.AddSubOperator(costLoop);
220      costLoop.AddSubOperator(costBranch);
221
222      gammaLoop.AddSubOperator(costBranch); // inner loop
223      gammaLoop.AddSubOperator(CreateResetOperator("CostIndex", -1));
224      gammaLoop.AddSubOperator(CreateCounter("Gamma"));
225      gammaLoop.AddSubOperator(CreateComparator("Gamma"));
226
227      ConditionalBranch gammaBranch = new ConditionalBranch();
228      gammaBranch.Name = "GammaLoop";
229      gammaBranch.GetVariableInfo("Condition").ActualName = "RepeatGammaLoop";
230      gammaBranch.AddSubOperator(gammaLoop);
231      gammaLoop.AddSubOperator(gammaBranch);
232
233      nuLoop.AddSubOperator(CreateResetOperator("GammaIndex", 0));
234
235      nuLoop.AddSubOperator(CreateCounter("Nu"));
236      nuLoop.AddSubOperator(CreateComparator("Nu"));
237
238      ConditionalBranch nuBranch = new ConditionalBranch();
239      nuBranch.Name = "NuLoop";
240      nuBranch.GetVariableInfo("Condition").ActualName = "RepeatNuLoop";
241     
242      nuBranch.AddSubOperator(nuLoop);
243      nuLoop.AddSubOperator(nuBranch);
244
245      main.AddSubOperator(nuLoop);
246      return main;
247    }
248
249    private IOperator CreateModelProcessor() {
250      SequentialProcessor modelProcessor = new SequentialProcessor();
251      modelProcessor.AddSubOperator(CreateSetNextParameterValueOperator("Nu"));
252      modelProcessor.AddSubOperator(CreateSetNextParameterValueOperator("Cost"));
253      modelProcessor.AddSubOperator(CreateSetNextParameterValueOperator("Gamma"));
254
255      SupportVectorCreator modelCreator = new SupportVectorCreator();
256      modelCreator.GetVariableInfo("SamplesStart").ActualName = "ActualTrainingSamplesStart";
257      modelCreator.GetVariableInfo("SamplesEnd").ActualName = "ActualTrainingSamplesEnd";
258      modelCreator.GetVariableInfo("SVMCost").ActualName = "Cost";
259      modelCreator.GetVariableInfo("SVMGamma").ActualName = "Gamma";
260      modelCreator.GetVariableInfo("SVMKernelType").ActualName = "KernelType";
261      modelCreator.GetVariableInfo("SVMModel").ActualName = "Model";
262      modelCreator.GetVariableInfo("SVMNu").ActualName = "Nu";
263      modelCreator.GetVariableInfo("SVMType").ActualName = "Type";
264
265      modelProcessor.AddSubOperator(modelCreator);
266      CombinedOperator trainingEvaluator = (CombinedOperator)CreateEvaluator("ActualTraining");
267      trainingEvaluator.OperatorGraph.InitialOperator.SubOperators[1].GetVariableInfo("MSE").ActualName = "Quality";
268      modelProcessor.AddSubOperator(trainingEvaluator);
269      modelProcessor.AddSubOperator(CreateEvaluator("Validation"));
270      modelProcessor.AddSubOperator(CreateEvaluator("Test"));
271
272      DataCollector collector = new DataCollector();
273      collector.GetVariableInfo("Values").ActualName = "Log";
274      ((ItemList<StringData>)collector.GetVariable("VariableNames").Value).Add(new StringData("Nu"));
275      ((ItemList<StringData>)collector.GetVariable("VariableNames").Value).Add(new StringData("Cost"));
276      ((ItemList<StringData>)collector.GetVariable("VariableNames").Value).Add(new StringData("Gamma"));
277      ((ItemList<StringData>)collector.GetVariable("VariableNames").Value).Add(new StringData("ValidationQuality"));
278      modelProcessor.AddSubOperator(collector);
279      return modelProcessor;
280    }
281
282    private IOperator CreateComparator(string p) {
283      LessThanComparator comparator = new LessThanComparator();
284      comparator.Name = p + "IndexComparator";
285      comparator.GetVariableInfo("LeftSide").ActualName = p + "Index";
286      comparator.GetVariableInfo("RightSide").ActualName = "Max" + p + "Index";
287      comparator.GetVariableInfo("Result").ActualName = "Repeat" + p + "Loop";
288      return comparator;
289    }
290
291    private IOperator CreateCounter(string p) {
292      Counter c = new Counter();
293      c.GetVariableInfo("Value").ActualName = p + "Index";
294      c.Name = p + "Counter";
295      return c;
296    }
297
298    private IOperator CreateEvaluator(string p) {
299      CombinedOperator op = new CombinedOperator();
300      op.Name = p + "Evaluator";
301      SequentialProcessor seqProc = new SequentialProcessor();
302
303      SupportVectorEvaluator evaluator = new SupportVectorEvaluator();
304      evaluator.Name = p + "SimpleEvaluator";
305      evaluator.GetVariableInfo("SVMModel").ActualName = "Model";
306      evaluator.GetVariableInfo("SamplesStart").ActualName = p + "SamplesStart";
307      evaluator.GetVariableInfo("SamplesEnd").ActualName = p + "SamplesEnd";
308      evaluator.GetVariableInfo("Values").ActualName = p + "Values";
309      SimpleMSEEvaluator mseEvaluator = new SimpleMSEEvaluator();
310      mseEvaluator.Name = p + "MseEvaluator";
311      mseEvaluator.GetVariableInfo("Values").ActualName = p + "Values";
312      mseEvaluator.GetVariableInfo("MSE").ActualName = p + "Quality";
313      SimpleR2Evaluator r2Evaluator = new SimpleR2Evaluator();
314      r2Evaluator.Name = p + "R2Evaluator";
315      r2Evaluator.GetVariableInfo("Values").ActualName = p + "Values";
316      r2Evaluator.GetVariableInfo("R2").ActualName = p + "R2";
317      SimpleMeanAbsolutePercentageErrorEvaluator mapeEvaluator = new SimpleMeanAbsolutePercentageErrorEvaluator();
318      mapeEvaluator.Name = p + "MAPEEvaluator";
319      mapeEvaluator.GetVariableInfo("Values").ActualName = p + "Values";
320      mapeEvaluator.GetVariableInfo("MAPE").ActualName = p + "MAPE";
321      SimpleMeanAbsolutePercentageOfRangeErrorEvaluator mapreEvaluator = new SimpleMeanAbsolutePercentageOfRangeErrorEvaluator();
322      mapreEvaluator.Name = p + "MAPREEvaluator";
323      mapreEvaluator.GetVariableInfo("Values").ActualName = p + "Values";
324      mapreEvaluator.GetVariableInfo("MAPRE").ActualName = p + "MAPRE";
325      SimpleVarianceAccountedForEvaluator vafEvaluator = new SimpleVarianceAccountedForEvaluator();
326      vafEvaluator.Name = p + "VAFEvaluator";
327      vafEvaluator.GetVariableInfo("Values").ActualName = p + "Values";
328      vafEvaluator.GetVariableInfo("VAF").ActualName = p + "VAF";
329
330      seqProc.AddSubOperator(evaluator);
331      seqProc.AddSubOperator(mseEvaluator);
332      seqProc.AddSubOperator(r2Evaluator);
333      seqProc.AddSubOperator(mapeEvaluator);
334      seqProc.AddSubOperator(mapreEvaluator);
335      seqProc.AddSubOperator(vafEvaluator);
336
337      op.OperatorGraph.AddOperator(seqProc);
338      op.OperatorGraph.InitialOperator = seqProc;
339      return op;
340    }
341
342    private IOperator CreateSetNextParameterValueOperator(string paramName) {
343      ProgrammableOperator progOp = new ProgrammableOperator();
344      progOp.Name = "SetNext" + paramName;
345      progOp.RemoveVariableInfo("Result");
346      progOp.AddVariableInfo(new VariableInfo("Value", "Value", typeof(DoubleData), VariableKind.New));
347      progOp.AddVariableInfo(new VariableInfo("ValueIndex", "ValueIndex", typeof(IntData), VariableKind.In));
348      progOp.AddVariableInfo(new VariableInfo("ValueList", "ValueList", typeof(DoubleArrayData), VariableKind.In));
349      progOp.Code =
350@"
351Value.Data = ValueList.Data[ValueIndex.Data];
352";
353
354      progOp.GetVariableInfo("Value").ActualName = paramName;
355      progOp.GetVariableInfo("ValueIndex").ActualName = paramName + "Index";
356      progOp.GetVariableInfo("ValueList").ActualName = paramName + "List";
357      return progOp;
358    }
359
360    private IOperator CreateResetOperator(string paramName, int value) {
361      ProgrammableOperator progOp = new ProgrammableOperator();
362      progOp.Name = "Reset" + paramName;
363      progOp.RemoveVariableInfo("Result");
364      progOp.AddVariableInfo(new VariableInfo("Value", "Value", typeof(IntData), VariableKind.In | VariableKind.Out));
365      progOp.Code = "Value.Data = "+value+";";
366      progOp.GetVariableInfo("Value").ActualName = paramName;
367      return progOp;
368    }
369
370    private IOperator CreateGlobalInjector() {
371      VariableInjector injector = new VariableInjector();
372      injector.AddVariable(new HeuristicLab.Core.Variable("CostIndex", new IntData(0)));
373      injector.AddVariable(new HeuristicLab.Core.Variable("CostList", new DoubleArrayData(new double[] {
374        Math.Pow(2,-5),
375        Math.Pow(2,-3),
376        Math.Pow(2,-1),
377        2,
378        Math.Pow(2,3),
379        Math.Pow(2,5),
380        Math.Pow(2,7),
381        Math.Pow(2,9),
382        Math.Pow(2,11),
383        Math.Pow(2,13),
384        Math.Pow(2,15)})));
385      injector.AddVariable(new HeuristicLab.Core.Variable("MaxCostIndex", new IntData()));
386      injector.AddVariable(new HeuristicLab.Core.Variable("NuIndex", new IntData(0)));
387      injector.AddVariable(new HeuristicLab.Core.Variable("NuList", new DoubleArrayData(new double[] { 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.9, 0.8, 1 })));
388      injector.AddVariable(new HeuristicLab.Core.Variable("MaxNuIndex", new IntData()));
389      injector.AddVariable(new HeuristicLab.Core.Variable("Log", new ItemList()));
390      injector.AddVariable(new HeuristicLab.Core.Variable("GammaIndex", new IntData(0)));
391      injector.AddVariable(new HeuristicLab.Core.Variable("GammaList", new DoubleArrayData(new double[] {
392        3.0517578125E-05, 0.0001220703125,0.00048828125,0.001953125,
393        0.0078125,0.03125,0.125,0.5,2,4,8})));
394      injector.AddVariable(new HeuristicLab.Core.Variable("MaxGammaIndex", new IntData()));
395      injector.AddVariable(new HeuristicLab.Core.Variable("KernelType", new StringData("RBF")));
396      injector.AddVariable(new HeuristicLab.Core.Variable("Type", new StringData("NU_SVR")));
397
398      return injector;
399    }
400
401    private IOperator CreateModelAnalyser() {
402      CombinedOperator modelAnalyser = new CombinedOperator();
403      modelAnalyser.Name = "Model Analyzer";
404      SequentialSubScopesProcessor seqSubScopeProc = new SequentialSubScopesProcessor();
405      SequentialProcessor seqProc = new SequentialProcessor();
406      VariableEvaluationImpactCalculator evalImpactCalc = new VariableEvaluationImpactCalculator();
407      evalImpactCalc.GetVariableInfo("SVMModel").ActualName = "Model";
408      VariableQualityImpactCalculator qualImpactCalc = new VariableQualityImpactCalculator();
409      qualImpactCalc.GetVariableInfo("SVMModel").ActualName = "Model";
410
411      seqProc.AddSubOperator(evalImpactCalc);
412      seqProc.AddSubOperator(qualImpactCalc);
413      seqSubScopeProc.AddSubOperator(seqProc);
414      modelAnalyser.OperatorGraph.InitialOperator = seqSubScopeProc;
415      modelAnalyser.OperatorGraph.AddOperator(seqSubScopeProc);
416      return modelAnalyser;
417    }
418
419
420    protected internal virtual Model CreateSVMModel(IScope bestModelScope) {
421      Model model = new Model();
422      model.TrainingMeanSquaredError = bestModelScope.GetVariableValue<DoubleData>("Quality", false).Data;
423      model.ValidationMeanSquaredError = bestModelScope.GetVariableValue<DoubleData>("ValidationQuality", false).Data;
424      model.TestMeanSquaredError = bestModelScope.GetVariableValue<DoubleData>("TestQuality", false).Data;
425      model.TrainingCoefficientOfDetermination = bestModelScope.GetVariableValue<DoubleData>("ActualTrainingR2", false).Data;
426      model.ValidationCoefficientOfDetermination = bestModelScope.GetVariableValue<DoubleData>("ValidationR2", false).Data;
427      model.TestCoefficientOfDetermination = bestModelScope.GetVariableValue<DoubleData>("TestR2", false).Data;
428      model.TrainingMeanAbsolutePercentageError = bestModelScope.GetVariableValue<DoubleData>("ActualTrainingMAPE", false).Data;
429      model.ValidationMeanAbsolutePercentageError = bestModelScope.GetVariableValue<DoubleData>("ValidationMAPE", false).Data;
430      model.TestMeanAbsolutePercentageError = bestModelScope.GetVariableValue<DoubleData>("TestMAPE", false).Data;
431      model.TrainingMeanAbsolutePercentageOfRangeError = bestModelScope.GetVariableValue<DoubleData>("ActualTrainingMAPRE", false).Data;
432      model.ValidationMeanAbsolutePercentageOfRangeError = bestModelScope.GetVariableValue<DoubleData>("ValidationMAPRE", false).Data;
433      model.TestMeanAbsolutePercentageOfRangeError = bestModelScope.GetVariableValue<DoubleData>("TestMAPRE", false).Data;
434      model.TrainingVarianceAccountedFor = bestModelScope.GetVariableValue<DoubleData>("ActualTrainingVAF", false).Data;
435      model.ValidationVarianceAccountedFor = bestModelScope.GetVariableValue<DoubleData>("ValidationVAF", false).Data;
436      model.TestVarianceAccountedFor = bestModelScope.GetVariableValue<DoubleData>("TestVAF", false).Data;
437
438      model.Data = bestModelScope.GetVariableValue<SVMModel>("Model", false);
439      HeuristicLab.DataAnalysis.Dataset ds = bestModelScope.GetVariableValue<Dataset>("Dataset", true);
440      model.Dataset = ds;
441      model.TargetVariable = ds.GetVariableName(bestModelScope.GetVariableValue<IntData>("TargetVariable", true).Data);
442
443      ItemList evaluationImpacts = bestModelScope.GetVariableValue<ItemList>("VariableEvaluationImpacts", false);
444      ItemList qualityImpacts = bestModelScope.GetVariableValue<ItemList>("VariableQualityImpacts", false);
445      foreach (ItemList row in evaluationImpacts) {
446        string variableName = ((StringData)row[0]).Data;
447        double impact = ((DoubleData)row[1]).Data;
448        model.SetVariableEvaluationImpact(variableName, impact);
449        model.AddInputVariables(variableName);
450      }
451      foreach (ItemList row in qualityImpacts) {
452        string variableName = ((StringData)row[0]).Data;
453        double impact = ((DoubleData)row[1]).Data;
454        model.SetVariableQualityImpact(variableName, impact);
455        model.AddInputVariables(variableName);
456      }
457
458      return model;
459    }
460
461    private IOperator GetVariableInjector() {
462      return GetMainOperator().SubOperators[0].SubOperators[0];
463    }
464
465    private IOperator GetMainOperator() {
466      CombinedOperator svm = (CombinedOperator)Engine.OperatorGraph.InitialOperator;
467      return svm.OperatorGraph.InitialOperator;
468    }
469
470    public override IView CreateView() {
471      return engine.CreateView();
472    }
473
474    #region IEditable Members
475
476    public IEditor CreateEditor() {
477      return engine.CreateEditor();
478    }
479
480    #endregion
481  }
482}
Note: See TracBrowser for help on using the repository browser.