Last change
on this file since 583 was
583,
checked in by abeham, 16 years ago
|
Adding communication framework to branch 3.1 (ticket #278)
|
File size:
1.2 KB
|
Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using System.Xml;
|
---|
6 | using HeuristicLab.Core;
|
---|
7 | using HeuristicLab.Data;
|
---|
8 |
|
---|
9 | namespace HeuristicLab.SimOpt {
|
---|
10 | public class SimOptParameterPacker : OperatorBase {
|
---|
11 | public override string Description {
|
---|
12 | get { return @"Updates a ConstrainedItemList with the variables in the scope and removes them afterwards."; }
|
---|
13 | }
|
---|
14 |
|
---|
15 | public SimOptParameterPacker()
|
---|
16 | : base() {
|
---|
17 | AddVariableInfo(new VariableInfo("Items", "The ConstrainedItemList to be updated", typeof(ConstrainedItemList), VariableKind.In | VariableKind.Out));
|
---|
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) throw new InvalidOperationException("ERROR in SimOptParameterPacker: Cannot find variable " + ((Variable)cil[i]).Name + " in scope");
|
---|
25 | else {
|
---|
26 | ((Variable)cil[i]).Value = (IItem)var.Value.Clone();
|
---|
27 | scope.RemoveVariable(var.Name);
|
---|
28 | }
|
---|
29 | }
|
---|
30 | return null;
|
---|
31 | }
|
---|
32 | }
|
---|
33 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.