Free cookie consent management tool by TermsFeed Policy Generator

Changeset 6140


Ignore:
Timestamp:
05/06/11 15:08:57 (14 years ago)
Author:
epitzer
Message:

Add new CachedExternalEvaluator with replaceable permanent cache of all evaluated solutions (#1516)

Location:
trunk/sources
Files:
5 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.ExternalEvaluation.Views/3.3/HeuristicLab.Problems.ExternalEvaluation.Views-3.3.csproj

    r5832 r6140  
    111111  <ItemGroup>
    112112    <None Include="HeuristicLabProblemsExternalEvaluationViewsPlugin.cs.frame" />
     113    <Compile Include="EvaluationCacheView.cs">
     114      <SubType>UserControl</SubType>
     115    </Compile>
     116    <Compile Include="EvaluationCacheView.Designer.cs">
     117      <DependentUpon>EvaluationCacheView.cs</DependentUpon>
     118    </Compile>
    113119    <Compile Include="EvaluationServiceClientView.cs">
    114120      <SubType>UserControl</SubType>
     
    197203    </BootstrapperPackage>
    198204  </ItemGroup>
     205  <ItemGroup>
     206    <EmbeddedResource Include="EvaluationCacheView.resx">
     207      <DependentUpon>EvaluationCacheView.cs</DependentUpon>
     208    </EmbeddedResource>
     209  </ItemGroup>
    199210  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    200211  <PropertyGroup>
  • trunk/sources/HeuristicLab.Problems.ExternalEvaluation/3.3/ExternalEvaluator.cs

    r5445 r6140  
    3232  [StorableClass]
    3333  public class ExternalEvaluator : ValuesCollector, IExternalEvaluationProblemEvaluator {
     34
    3435    public ILookupParameter<DoubleValue> QualityParameter {
    3536      get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; }
     
    4344    }
    4445
    45     private SolutionMessageBuilder MessageBuilder {
     46    protected SolutionMessageBuilder MessageBuilder {
    4647      get { return MessageBuilderParameter.Value; }
    4748    }
     
    6162
    6263    public override IOperation Apply() {
     64      SolutionMessage message = BuildSolutionMessage();
     65
    6366      IEvaluationServiceClient client = ClientParameter.ActualValue;
     67      QualityMessage answer = client.Evaluate(message);
     68
     69      if (QualityParameter.ActualValue == null)
     70        QualityParameter.ActualValue = new DoubleValue(answer.Quality);
     71      else QualityParameter.ActualValue.Value = answer.Quality;
     72
     73      return base.Apply();
     74    }
     75
     76    protected virtual SolutionMessage BuildSolutionMessage() {
    6477      SolutionMessage.Builder protobufBuilder = SolutionMessage.CreateBuilder();
    6578      protobufBuilder.SolutionId = 0;
     
    7184          try {
    7285            MessageBuilder.AddToMessage(value, name, protobufBuilder);
    73           }
    74           catch (ArgumentException ex) {
     86          } catch (ArgumentException ex) {
    7587            throw new InvalidOperationException("ERROR in " + Name + ": Parameter " + name + " cannot be added to the message.", ex);
    7688          }
    7789        }
    7890      }
    79       QualityMessage answer = client.Evaluate(protobufBuilder.Build());
    80       if (QualityParameter.ActualValue == null)
    81         QualityParameter.ActualValue = new DoubleValue(answer.Quality);
    82       else QualityParameter.ActualValue.Value = answer.Quality;
    83 
    84       return base.Apply();
     91      return protobufBuilder.Build();
    8592    }
    8693  }
  • trunk/sources/HeuristicLab.Problems.ExternalEvaluation/3.3/HeuristicLab.Problems.ExternalEvaluation-3.3.csproj

    r5163 r6140  
    9898    </Reference>
    9999    <Reference Include="System.Drawing" />
     100    <Reference Include="System.Windows.Forms" />
    100101    <Reference Include="System.Xml.Linq">
    101102      <RequiredTargetFramework>3.5</RequiredTargetFramework>
     
    115116    <Compile Include="Converters\IntegerConverter.cs" />
    116117    <Compile Include="Converters\StringConverter.cs" />
     118    <Compile Include="CachedExternalEvaluator.cs" />
     119    <Compile Include="EvaluationCache.cs" />
    117120    <Compile Include="Drivers\EvaluationServiceClient.cs" />
    118121    <Compile Include="Drivers\EvaluationChannel.cs" />
     
    150153      <Name>HeuristicLab.Common-3.3</Name>
    151154    </ProjectReference>
     155    <ProjectReference Include="..\..\HeuristicLab.Core.Views\3.3\HeuristicLab.Core.Views-3.3.csproj">
     156      <Project>{E226881D-315F-423D-B419-A766FE0D8685}</Project>
     157      <Name>HeuristicLab.Core.Views-3.3</Name>
     158    </ProjectReference>
    152159    <ProjectReference Include="..\..\HeuristicLab.Core\3.3\HeuristicLab.Core-3.3.csproj">
    153160      <Project>{C36BD924-A541-4A00-AFA8-41701378DDC5}</Project>
     
    165172      <Project>{6908BDCE-D925-43F3-94AC-A531E6DF2591}</Project>
    166173      <Name>ProtocolBuffers</Name>
     174    </ProjectReference>
     175    <ProjectReference Include="..\..\HeuristicLab.MainForm.WindowsForms\3.3\HeuristicLab.MainForm.WindowsForms-3.3.csproj">
     176      <Project>{AB687BBE-1BFE-476B-906D-44237135431D}</Project>
     177      <Name>HeuristicLab.MainForm.WindowsForms-3.3</Name>
     178    </ProjectReference>
     179    <ProjectReference Include="..\..\HeuristicLab.MainForm\3.3\HeuristicLab.MainForm-3.3.csproj">
     180      <Project>{3BD61258-31DA-4B09-89C0-4F71FEF5F05A}</Project>
     181      <Name>HeuristicLab.MainForm-3.3</Name>
    167182    </ProjectReference>
    168183    <ProjectReference Include="..\..\HeuristicLab.Operators\3.3\HeuristicLab.Operators-3.3.csproj">
Note: See TracChangeset for help on using the changeset viewer.