Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/31/10 21:06:45 (14 years ago)
Author:
abeham
Message:

#866

  • Added license headers to designer files
  • Refactored message building, to be user customizable and better extendable
    • A SolutionMessageBuilder holds several Converters
    • A Converter specifies several types to convert and a conversion method
  • ExternalEvaluator has the message builder as parameter and exposes it to the UI through the parameters collection
  • The proto file has been updated to include a length field in the array variables
  • Converters exist for all types in HeuristicLab.Data
Location:
trunk/sources/HeuristicLab.Problems.ExternalEvaluation/3.3
Files:
9 added
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.ExternalEvaluation/3.3/ExternalEvaluator.cs

    r3872 r3881  
    3838    }
    3939
     40    public IValueParameter<SolutionMessageBuilder> MessageBuilderParameter {
     41      get { return (IValueParameter<SolutionMessageBuilder>)Parameters["MessageBuilder"]; }
     42    }
     43
     44    private SolutionMessageBuilder MessageBuilder {
     45      get { return MessageBuilderParameter.Value; }
     46    }
     47
    4048    public ExternalEvaluator()
    4149      : base() {
    4250      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality of the current solution."));
    4351      Parameters.Add(new ValueLookupParameter<IEvaluationServiceClient>("Client", "The client that communicates with the external process."));
     52      Parameters.Add(new ValueParameter<SolutionMessageBuilder>("MessageBuilder", "The message builder that converts from HeuristicLab objects to SolutionMessage representation.", new SolutionMessageBuilder()));
    4453    }
    4554
    4655    public override IOperation Apply() {
    4756      IEvaluationServiceClient client = ClientParameter.ActualValue;
    48       SolutionMessage.Builder messageBuilder = SolutionMessage.CreateBuilder();
    49       messageBuilder.SolutionId = 0;
     57      SolutionMessage.Builder protobufBuilder = SolutionMessage.CreateBuilder();
     58      protobufBuilder.SolutionId = 0;
    5059      foreach (IParameter param in CollectedValues) {
    5160        IItem value = param.ActualValue;
     
    5463          string name = lookupParam != null ? lookupParam.TranslatedName : param.Name;
    5564          try {
    56             value.AddToSolutionMessage(name, messageBuilder);
     65            MessageBuilder.AddToMessage(value, name, protobufBuilder);
    5766          } catch (ArgumentException ex) {
    5867            throw new InvalidOperationException("ERROR in " + Name + ": Parameter " + name + " cannot be added to the message.", ex);
     
    6069        }
    6170      }
    62       QualityMessage answer = client.Evaluate(messageBuilder.Build());
     71      QualityMessage answer = client.Evaluate(protobufBuilder.Build());
    6372      if (QualityParameter.ActualValue == null)
    6473        QualityParameter.ActualValue = new DoubleValue(answer.Quality);
  • trunk/sources/HeuristicLab.Problems.ExternalEvaluation/3.3/HeuristicLab.Problems.ExternalEvaluation-3.3.csproj

    r3872 r3881  
    8383  <ItemGroup>
    8484    <None Include="HeuristicLabProblemsExternalEvaluationPlugin.cs.frame" />
     85    <Compile Include="Converters\BoolConverter.cs" />
     86    <Compile Include="Converters\TimeSpanValueConverter.cs" />
     87    <Compile Include="Converters\DateTimeValueConverter.cs" />
     88    <Compile Include="Converters\DoubleConverter.cs" />
     89    <Compile Include="Converters\IntegerConverter.cs" />
     90    <Compile Include="Converters\StringConverter.cs" />
    8591    <Compile Include="Drivers\EvaluationServiceClient.cs" />
    8692    <Compile Include="Drivers\EvaluationChannel.cs" />
     
    9399    <Compile Include="Interfaces\IEvaluationChannel.cs" />
    94100    <Compile Include="Interfaces\IExternalEvaluationProblemEvaluator.cs" />
     101    <Compile Include="Interfaces\IItemToSolutionMessageConverter.cs" />
    95102    <Compile Include="Properties\AssemblyInfo.cs" />
    96103    <None Include="Properties\AssemblyInfo.frame" />
    97104    <Compile Include="Protos\ExternalEvaluationMessages.cs" />
    98     <Compile Include="SolutionMessageBuilding.cs" />
     105    <Compile Include="SolutionMessageBuilder.cs" />
    99106    <None Include="Protos\ProcessProtos.cmd" />
    100107  </ItemGroup>
  • trunk/sources/HeuristicLab.Problems.ExternalEvaluation/3.3/Protos/ExternalEvaluationMessages.proto

    r3872 r3881  
    1414    required string name = 1;
    1515    repeated int32 data = 2;
     16    optional int32 length = 3;
    1617  }
    1718  repeated IntegerArrayVariable integerArrayVars = 3;
     
    2627    required string name = 1;
    2728    repeated double data = 2;
     29    optional int32 length = 3;
    2830  }
    2931  repeated DoubleArrayVariable doubleArrayVars = 5;
     
    3840    required string name = 1;
    3941    repeated bool data = 2;
     42    optional int32 length = 3;
    4043  }
    4144  repeated BoolArrayVariable boolArrayVars = 7;
     
    5053    required string name = 1;
    5154    repeated string data = 2;
     55    optional int32 length = 3;
    5256  }
    5357  repeated StringArrayVariable stringArrayVars = 9;
Note: See TracChangeset for help on using the changeset viewer.