Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.SimOpt/SimOptParameterExtractor.cs @ 584

Last change on this file since 584 was 584, checked in by abeham, 16 years ago

merged communication framework to trunk (ticket #279)

File size: 1.0 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Xml;
6using HeuristicLab.Core;
7using HeuristicLab.Data;
8
9namespace HeuristicLab.SimOpt {
10  public class SimOptParameterExtractor : OperatorBase {
11    public override string Description {
12      get { return @"Injects the contents of a ConstrainedItemList into the scope"; }
13    }
14
15    public SimOptParameterExtractor()
16      : base() {
17      AddVariableInfo(new VariableInfo("Items", "The ConstrainedItemList to be extracted", typeof(ConstrainedItemList), VariableKind.In));
18    }
19
20    public override IOperation Apply(IScope scope) {
21      ConstrainedItemList cil = GetVariableValue<ConstrainedItemList>("Items", scope, false);
22      for (int i = 0; i < cil.Count; i++) {
23        IVariable var = scope.GetVariable(((Variable)cil[i]).Name);
24        if (var == null) scope.AddVariable((IVariable)cil[i].Clone());
25        else var.Value = (IItem)((Variable)cil[i]).Value.Clone();
26      }
27      return null;
28    }
29  }
30}
Note: See TracBrowser for help on using the repository browser.