Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/06/19 15:36:43 (6 years ago)
Author:
bburlacu
Message:

#2679: Update branch: framework version 4.6.1, use heal.attic for persistence, some minor refactoring.

Location:
branches/2679_HeuristicLab.GoalSeekingProblem/HeuristicLab.GoalSeekingProblem/3.4
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/2679_HeuristicLab.GoalSeekingProblem/HeuristicLab.GoalSeekingProblem/3.4/Analyzers/BestSolutionAnalyzer.cs

    r14526 r16901  
    2020#endregion
    2121
    22 using System.Collections.Generic;
    23 using System.Linq;
     22using HEAL.Attic;
    2423using HeuristicLab.Common;
    2524using HeuristicLab.Core;
     
    2928using HeuristicLab.Optimization;
    3029using HeuristicLab.Parameters;
    31 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3230using HeuristicLab.Problems.DataAnalysis;
     31using System.Collections.Generic;
     32using System.Linq;
    3333
    3434namespace HeuristicLab.GoalSeeking {
    35   [StorableClass]
    3635  [Item("BestSolutionAnalyzer", "An analyzer which identifies the best solution from the SingleObjectiveProcessParameterOptimizationProblem")]
     36  [StorableType("2CAFF3A8-D2FC-4402-A2F8-DD828465870E")]
    3737  public class BestSolutionAnalyzer : SingleSuccessorOperator, IAnalyzer {
    3838    private const string RowParameterName = "Row";
     
    100100
    101101    [StorableConstructor]
    102     protected BestSolutionAnalyzer(bool deserializing) : base(deserializing) { }
     102    protected BestSolutionAnalyzer(StorableConstructorFlag _) : base(_) { }
    103103
    104104
  • branches/2679_HeuristicLab.GoalSeekingProblem/HeuristicLab.GoalSeekingProblem/3.4/GoalParameter.cs

    r14338 r16901  
    2020#endregion
    2121
    22 using System;
     22using HEAL.Attic;
    2323using HeuristicLab.Common;
    2424using HeuristicLab.Core;
    25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     25using System;
    2626
    2727namespace HeuristicLab.GoalSeeking {
    2828  [Item("GoalParameter", "An object describing a tunable parameter used in goal seeking.")]
    29   [StorableClass]
     29  [StorableType("493140D6-5DA2-40AD-97C9-86CDCA72CDA7")]
    3030  public class GoalParameter : NamedItem {
    3131    [Storable]
     
    107107
    108108    [StorableConstructor]
    109     protected GoalParameter(bool deserializing) : base(deserializing) { }
     109    protected GoalParameter(StorableConstructorFlag _) : base(_) { }
    110110
    111111    public GoalParameter(string name, double goal, double weight, double variance, double step, bool active = true) {
  • branches/2679_HeuristicLab.GoalSeekingProblem/HeuristicLab.GoalSeekingProblem/3.4/GoalSeekingOptimizer.cs

    r14526 r16901  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    24 using System.Drawing;
    25 using System.Linq;
     22using HEAL.Attic;
    2623using HeuristicLab.Analysis;
    2724using HeuristicLab.Common;
     
    2926using HeuristicLab.Data;
    3027using HeuristicLab.Optimization;
    31 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3228using HeuristicLab.Problems.DataAnalysis;
     29using System;
     30using System.Collections.Generic;
     31using System.Drawing;
     32using System.Linq;
     33using System.Threading;
     34using System.Threading.Tasks;
    3335
    3436namespace HeuristicLab.GoalSeeking {
    3537  internal enum GoalSeekingOptimizerAction { None, Prepare, Start, Stop, Pause }
    3638
    37   [StorableClass]
    3839  [Item("GoalSeeking Optimizer", "A wrapper for the GoalSeekingProblem class to facilitate adding models and problem data.")]
    3940  [Creatable("Algorithms")]
     41  [StorableType("92552DF1-7FC7-4DC9-A021-8661E878A72B")]
    4042  public class GoalSeekingOptimizer : NamedItem, IOptimizer, IStorableContent {
    4143    [Storable]
     
    108110    }
    109111
    110     private GoalSeekingOptimizerAction gsoAction;
     112    private GoalSeekingOptimizerAction optimizerAction;
    111113
    112114    public GoalSeekingOptimizer() {
     
    115117
    116118    [StorableConstructor]
    117     protected GoalSeekingOptimizer(bool deserializing) : base(deserializing) { }
     119    protected GoalSeekingOptimizer(StorableConstructorFlag _) : base(_) { }
    118120
    119121
     
    166168    private int currentRow;
    167169
     170    private void PrepareAndConfigure() {
     171      Optimizer.Prepare(clearRuns: true);
     172      calculatedRows = 0;
     173      currentRow = problemData.TrainingIndices.First();
     174      problem.Configure(problemData, currentRow);
     175    }
     176
    168177    public void Start() {
     178      Start(CancellationToken.None);
     179    }
     180
     181    public void Start(CancellationToken cancellationToken) {
    169182      if ((ExecutionState != ExecutionState.Prepared) && (ExecutionState != ExecutionState.Paused))
    170183        throw new InvalidOperationException(string.Format("Start not allowed in execution state \"{0}\".", ExecutionState));
    171184      if (optimizer == null) return;
    172       gsoAction = GoalSeekingOptimizerAction.Start;
     185      optimizerAction = GoalSeekingOptimizerAction.Start;
    173186      if (Optimizer.ExecutionState == ExecutionState.Stopped) {
    174         Optimizer.Prepare(clearRuns: true);
    175         calculatedRows = 0;
    176         currentRow = problemData.TrainingIndices.Skip(calculatedRows).First();
    177         problem.Configure(problemData, currentRow);
    178         optimizer.Prepare();
    179       }
    180       optimizer.Start();
     187        PrepareAndConfigure();
     188      }
     189      Optimizer.Start(cancellationToken);
     190    }
     191
     192    public async Task StartAsync() {
     193      await StartAsync(CancellationToken.None);
     194    }
     195
     196    public async Task StartAsync(CancellationToken cancellationToken) {
     197      await AsyncHelper.DoAsync(Start, cancellationToken);
    181198    }
    182199
     
    185202        throw new InvalidOperationException(string.Format("Pause not allowed in execution state \"{0}\".", ExecutionState));
    186203      if (optimizer == null) return;
    187       gsoAction = GoalSeekingOptimizerAction.Pause;
     204      optimizerAction = GoalSeekingOptimizerAction.Pause;
    188205      if (optimizer.ExecutionState != ExecutionState.Started) return;
    189206      // a race-condition may occur when the algorithm has changed the state by itself in the meantime
    190       try { optimizer.Pause(); }
    191       catch (InvalidOperationException) { }
     207      try { optimizer.Pause(); } catch (InvalidOperationException) { }
    192208    }
    193209
     
    196212        throw new InvalidOperationException(string.Format("Stop not allowed in execution state \"{0}\".", ExecutionState));
    197213      if (optimizer == null) return;
    198       gsoAction = GoalSeekingOptimizerAction.Stop;
     214      optimizerAction = GoalSeekingOptimizerAction.Stop;
    199215      if (optimizer.ExecutionState != ExecutionState.Started && optimizer.ExecutionState != ExecutionState.Paused) {
    200216        OnStopped();
     
    202218      }
    203219      // a race-condition may occur when the algorithm has changed the state by itself in the meantime
    204       try { optimizer.Stop(); }
    205       catch (InvalidOperationException) { }
     220      try { optimizer.Stop(); } catch (InvalidOperationException) { }
    206221    }
    207222
     
    220235        ExecutionTime = TimeSpan.Zero;
    221236        if (clearRuns) optimizer.Runs.Clear();
    222         gsoAction = GoalSeekingOptimizerAction.Prepare;
     237        optimizerAction = GoalSeekingOptimizerAction.Prepare;
    223238        // a race-condition may occur when the algorithm has changed the state by itself in the meantime
    224         try { optimizer.Prepare(clearRuns); }
    225         catch (InvalidOperationException) { }
     239        try { optimizer.Prepare(clearRuns); } catch (InvalidOperationException) { }
    226240      } else {
    227241        ExecutionState = ExecutionState.Stopped;
     
    290304    public event EventHandler Prepared;
    291305    private void OnPrepared() {
    292       gsoAction = GoalSeekingOptimizerAction.None;
     306      optimizerAction = GoalSeekingOptimizerAction.None;
    293307      ExecutionState = ExecutionState.Prepared;
    294308      EventHandler handler = Prepared;
     
    305319    public event EventHandler Paused;
    306320    private void OnPaused() {
    307       gsoAction = GoalSeekingOptimizerAction.None;
     321      optimizerAction = GoalSeekingOptimizerAction.None;
    308322      ExecutionState = ExecutionState.Paused;
    309323      EventHandler handler = Paused;
     
    313327    public event EventHandler Stopped;
    314328    private void OnStopped() {
    315       gsoAction = GoalSeekingOptimizerAction.None;
     329      optimizerAction = GoalSeekingOptimizerAction.None;
    316330      ExecutionState = ExecutionState.Stopped;
    317331      EventHandler handler = Stopped;
     
    337351    }
    338352
    339     public event EventHandler RepetetionsCounterChanged;
     353    public event EventHandler RepetitionsCounterChanged;
    340354    private void OnRepetitionsCounterChanged() {
    341       EventHandler handler = RepetetionsCounterChanged;
     355      EventHandler handler = RepetitionsCounterChanged;
    342356      if (handler != null) handler(this, EventArgs.Empty);
    343357    }
     
    378392
    379393    private void Optimizer_Prepared(object sender, EventArgs e) {
    380       if (gsoAction == GoalSeekingOptimizerAction.Prepare || ExecutionState == ExecutionState.Stopped) {
     394      if (optimizerAction == GoalSeekingOptimizerAction.Prepare || ExecutionState == ExecutionState.Stopped) {
    381395        calculatedRows = 0;
    382396        ExecutionTime = TimeSpan.Zero;
     
    399413      GetResults();
    400414
    401       if (gsoAction == GoalSeekingOptimizerAction.Stop)
     415      if (optimizerAction == GoalSeekingOptimizerAction.Stop)
    402416        OnStopped();
    403417      else if (!remainingRows.Any()) {
    404418        OnStopped();
    405       } else switch (gsoAction) {
     419      } else switch (optimizerAction) {
    406420          case GoalSeekingOptimizerAction.Pause:
    407421            OnPaused();
  • branches/2679_HeuristicLab.GoalSeekingProblem/HeuristicLab.GoalSeekingProblem/3.4/GoalSeekingProblem.csproj

    r14526 r16901  
    11<?xml version="1.0" encoding="utf-8"?>
    2 <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
     2<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    33  <PropertyGroup>
    44    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     
    1111    <RootNamespace>HeuristicLab.GoalSeekingProblem</RootNamespace>
    1212    <AssemblyName>HeuristicLab.GoalSeekingProblem-3.4</AssemblyName>
    13     <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
     13    <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
    1414    <FileAlignment>512</FileAlignment>
    1515    <TargetFrameworkProfile />
     
    1919    <DebugType>full</DebugType>
    2020    <Optimize>false</Optimize>
    21     <OutputPath>..\..\..\..\trunk\sources\bin\</OutputPath>
     21    <OutputPath>..\..\..\..\trunk\bin\</OutputPath>
    2222    <DefineConstants>DEBUG;TRACE</DefineConstants>
    2323    <ErrorReport>prompt</ErrorReport>
     
    2525    <Prefer32Bit>false</Prefer32Bit>
    2626    <PlatformTarget>AnyCPU</PlatformTarget>
    27     <LangVersion>4</LangVersion>
     27    <LangVersion>5</LangVersion>
    2828  </PropertyGroup>
    2929  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    3030    <DebugType>pdbonly</DebugType>
    3131    <Optimize>true</Optimize>
    32     <OutputPath>..\..\..\..\trunk\sources\bin\</OutputPath>
     32    <OutputPath>..\..\..\..\trunk\bin\</OutputPath>
    3333    <DefineConstants>TRACE</DefineConstants>
    3434    <ErrorReport>prompt</ErrorReport>
     
    3636    <Prefer32Bit>false</Prefer32Bit>
    3737    <PlatformTarget>AnyCPU</PlatformTarget>
     38    <LangVersion>5</LangVersion>
    3839  </PropertyGroup>
    3940  <PropertyGroup>
     
    4546  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
    4647    <DebugSymbols>true</DebugSymbols>
    47     <OutputPath>..\..\..\..\trunk\sources\bin\</OutputPath>
     48    <OutputPath>..\..\..\..\trunk\bin\</OutputPath>
    4849    <DefineConstants>DEBUG;TRACE</DefineConstants>
    4950    <DebugType>full</DebugType>
     
    6162  </PropertyGroup>
    6263  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
    63     <OutputPath>..\..\..\..\trunk\sources\bin\</OutputPath>
     64    <OutputPath>..\..\..\..\trunk\bin\</OutputPath>
    6465    <DefineConstants>TRACE</DefineConstants>
    6566    <Optimize>true</Optimize>
     
    7879  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
    7980    <DebugSymbols>true</DebugSymbols>
    80     <OutputPath>..\..\..\..\trunk\sources\bin\</OutputPath>
     81    <OutputPath>..\..\..\..\trunk\bin\</OutputPath>
    8182    <DefineConstants>DEBUG;TRACE</DefineConstants>
    8283    <DebugType>full</DebugType>
     
    9495  </PropertyGroup>
    9596  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
    96     <OutputPath>..\..\..\..\trunk\sources\bin\</OutputPath>
     97    <OutputPath>..\..\..\..\trunk\bin\</OutputPath>
    9798    <DefineConstants>TRACE</DefineConstants>
    9899    <Optimize>true</Optimize>
     
    112113  </PropertyGroup>
    113114  <ItemGroup>
     115    <Reference Include="HEAL.Attic">
     116      <HintPath>..\..\..\..\trunk\bin\HEAL.Attic.dll</HintPath>
     117      <Private>False</Private>
     118    </Reference>
    114119    <Reference Include="HeuristicLab.Analysis-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    115120      <SpecificVersion>False</SpecificVersion>
    116       <HintPath>..\..\..\..\..\Projects\HeuristicLab\trunk\sources\HeuristicLab trunk sources\binHeuristicLab.Analysis-3.3.dll</HintPath>
    117       <Private>False</Private>
    118     </Reference>
    119     <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    120       <SpecificVersion>False</SpecificVersion>
    121       <HintPath>..\HeuristicLab trunk sources\binHeuristicLab.Collections-3.3.dll</HintPath>
    122       <Private>False</Private>
    123     </Reference>
    124     <Reference Include="HeuristicLab.Common-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    125       <SpecificVersion>False</SpecificVersion>
    126       <HintPath>..\HeuristicLab trunk sources\binHeuristicLab.Common-3.3.dll</HintPath>
     121      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Analysis-3.3.dll</HintPath>
     122      <Private>False</Private>
     123    </Reference>
     124    <Reference Include="HeuristicLab.Collections-3.3">
     125      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Collections-3.3.dll</HintPath>
     126      <Private>False</Private>
     127    </Reference>
     128    <Reference Include="HeuristicLab.Common-3.3">
     129      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Common-3.3.dll</HintPath>
    127130      <Private>False</Private>
    128131    </Reference>
    129132    <Reference Include="HeuristicLab.Common.Resources-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    130133      <SpecificVersion>False</SpecificVersion>
    131       <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Common.Resources-3.3.dll</HintPath>
    132       <Private>False</Private>
    133     </Reference>
    134     <Reference Include="HeuristicLab.Core-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    135       <SpecificVersion>False</SpecificVersion>
    136       <HintPath>..\HeuristicLab trunk sources\binHeuristicLab.Core-3.3.dll</HintPath>
    137       <Private>False</Private>
    138     </Reference>
    139     <Reference Include="HeuristicLab.Data-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    140       <SpecificVersion>False</SpecificVersion>
    141       <HintPath>..\HeuristicLab trunk sources\binHeuristicLab.Data-3.3.dll</HintPath>
    142       <Private>False</Private>
    143     </Reference>
    144     <Reference Include="HeuristicLab.Encodings.RealVectorEncoding-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    145       <SpecificVersion>False</SpecificVersion>
    146       <HintPath>..\HeuristicLab trunk sources\binHeuristicLab.Encodings.RealVectorEncoding-3.3.dll</HintPath>
     134      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Common.Resources-3.3.dll</HintPath>
     135      <Private>False</Private>
     136    </Reference>
     137    <Reference Include="HeuristicLab.Core-3.3">
     138      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Core-3.3.dll</HintPath>
     139      <Private>False</Private>
     140    </Reference>
     141    <Reference Include="HeuristicLab.Data-3.3">
     142      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Data-3.3.dll</HintPath>
     143      <Private>False</Private>
     144    </Reference>
     145    <Reference Include="HeuristicLab.Encodings.RealVectorEncoding-3.3">
     146      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Encodings.RealVectorEncoding-3.3.dll</HintPath>
    147147      <Private>False</Private>
    148148    </Reference>
    149149    <Reference Include="HeuristicLab.Operators-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    150150      <SpecificVersion>False</SpecificVersion>
    151       <HintPath>..\HeuristicLab trunk sources\binHeuristicLab.Operators-3.3.dll</HintPath>
    152       <Private>False</Private>
    153     </Reference>
    154     <Reference Include="HeuristicLab.Optimization-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    155       <SpecificVersion>False</SpecificVersion>
    156       <HintPath>..\HeuristicLab trunk sources\binHeuristicLab.Optimization-3.3.dll</HintPath>
    157       <Private>False</Private>
    158     </Reference>
    159     <Reference Include="HeuristicLab.Parameters-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    160       <SpecificVersion>False</SpecificVersion>
    161       <HintPath>..\HeuristicLab trunk sources\binHeuristicLab.Parameters-3.3.dll</HintPath>
    162       <Private>False</Private>
    163     </Reference>
    164     <Reference Include="HeuristicLab.Persistence-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    165       <SpecificVersion>False</SpecificVersion>
    166       <HintPath>..\HeuristicLab trunk sources\binHeuristicLab.Persistence-3.3.dll</HintPath>
    167       <Private>False</Private>
    168     </Reference>
    169     <Reference Include="HeuristicLab.PluginInfrastructure-3.3">
    170       <HintPath>C:\Program Files\HeuristicLab 3.3\PluginInfrastructure-3.3.dll</HintPath>
    171       <Private>False</Private>
    172     </Reference>
    173     <Reference Include="HeuristicLab.Problems.DataAnalysis-3.4, Version=3.4.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    174       <SpecificVersion>False</SpecificVersion>
    175       <HintPath>..\HeuristicLab trunk sources\binHeuristicLab.Problems.DataAnalysis-3.4.dll</HintPath>
    176       <Private>False</Private>
    177     </Reference>
    178     <Reference Include="HeuristicLab.Problems.DataAnalysis.Symbolic-3.4, Version=3.4.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    179       <SpecificVersion>False</SpecificVersion>
    180       <HintPath>..\HeuristicLab trunk sources\binHeuristicLab.Problems.DataAnalysis.Symbolic-3.4.dll</HintPath>
    181       <Private>False</Private>
    182     </Reference>
    183     <Reference Include="HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4, Version=3.4.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    184       <SpecificVersion>False</SpecificVersion>
    185       <HintPath>..\HeuristicLab trunk sources\binHeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.dll</HintPath>
     151      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Operators-3.3.dll</HintPath>
     152      <Private>False</Private>
     153    </Reference>
     154    <Reference Include="HeuristicLab.Optimization-3.3">
     155      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Optimization-3.3.dll</HintPath>
     156      <Private>False</Private>
     157    </Reference>
     158    <Reference Include="HeuristicLab.Parameters-3.3">
     159      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Parameters-3.3.dll</HintPath>
     160      <Private>False</Private>
     161    </Reference>
     162    <Reference Include="HeuristicLab.PluginInfrastructure-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     163      <SpecificVersion>False</SpecificVersion>
     164      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath>
     165      <Private>False</Private>
     166    </Reference>
     167    <Reference Include="HeuristicLab.Problems.DataAnalysis-3.4">
     168      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Problems.DataAnalysis-3.4.dll</HintPath>
    186169      <Private>False</Private>
    187170    </Reference>
  • branches/2679_HeuristicLab.GoalSeekingProblem/HeuristicLab.GoalSeekingProblem/3.4/InputParameter.cs

    r14338 r16901  
    2020#endregion
    2121
    22 using System;
     22using HEAL.Attic;
    2323using HeuristicLab.Common;
    2424using HeuristicLab.Core;
    25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     25using System;
    2626
    2727namespace HeuristicLab.GoalSeeking {
    2828  [Item("InputParameter", "An object describing a target for the goal seeking.")]
    29   [StorableClass]
     29  [StorableType("3F8B2C70-7EF4-439C-8E5A-A770F5431E65")]
    3030  public class InputParameter : NamedItem {
    3131    [Storable]
     
    106106
    107107    [StorableConstructor]
    108     protected InputParameter(bool deserializing) : base(deserializing) { }
     108    protected InputParameter(StorableConstructorFlag _) : base(_) { }
    109109
    110110    public InputParameter(string name, double value, double min, double max, double step, bool active = true) {
  • branches/2679_HeuristicLab.GoalSeekingProblem/HeuristicLab.GoalSeekingProblem/3.4/MultiObjectiveGoalSeekingProblem.cs

    r14526 r16901  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    24 using System.Linq;
     22using HEAL.Attic;
    2523using HeuristicLab.Collections;
    2624using HeuristicLab.Common;
     
    3028using HeuristicLab.Optimization;
    3129using HeuristicLab.Parameters;
    32 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3330using HeuristicLab.Problems.DataAnalysis;
     31using System;
     32using System.Collections.Generic;
     33using System.Linq;
    3434
    3535namespace HeuristicLab.GoalSeeking {
    3636  [Item("Goal seeking problem (multi-objective)", "Represents a single objective optimization problem which uses configurable regression models to evaluate targets from a given dataset.")]
    3737  [Creatable("Problems")]
    38   [StorableClass]
     38  [StorableType("76EA4627-FD52-41D0-A594-20C99F700F46")]
    3939  public sealed class MultiObjectiveGoalSeekingProblem : MultiObjectiveBasicProblem<RealVectorEncoding>, IGoalSeekingProblem {
    4040    #region parameter names
     
    9191    public IEnumerable<double> GetEstimatedGoalValues(IEnumerable<double> parameterValues, bool round = false) {
    9292      var ds = (ModifiableDataset)dataset.Clone();
    93       foreach (var parameter in ActiveInputs.Zip(parameterValues, (p, v) => new { Name = p.Name, Value = v })) {
     93      foreach (var parameter in ActiveInputs.Zip(parameterValues, (p, v) => new { p.Name, Value = v })) {
    9494        ds.SetVariableValue(parameter.Value, parameter.Name, 0);
    9595      }
    9696      var rows = new[] { 0 }; // actually just one row
    97       var estimatedValues =
    98         round ? ActiveGoals.Select(t => RoundToNearestStepMultiple(GetModels(t.Name).Average(m => m.GetEstimatedValues(ds, rows).Single()), t.Step))
    99               : ActiveGoals.Select(t => GetModels(t.Name).Average(m => m.GetEstimatedValues(ds, rows).Single()));
    100       return estimatedValues;
     97      return round ? ActiveGoals.Select(t => RoundToNearestStepMultiple(GetModels(t.Name).Average(m => m.GetEstimatedValues(ds, rows).Single()), t.Step))
     98                   : ActiveGoals.Select(t => GetModels(t.Name).Average(m => m.GetEstimatedValues(ds, rows).Single()));
    10199    }
    102100
     
    131129    #region constructors
    132130    [StorableConstructor]
    133     private MultiObjectiveGoalSeekingProblem(bool deserializing) : base(deserializing) { }
     131    private MultiObjectiveGoalSeekingProblem(StorableConstructorFlag _) : base(_) { }
    134132
    135133    private MultiObjectiveGoalSeekingProblem(MultiObjectiveGoalSeekingProblem original, Cloner cloner) : base(original, cloner) {
     
    219217        for (int j = 0; j < activeGoals.Count * 2; j += 2) {
    220218          int k = j + offset;
    221           var goal = activeGoals[j / 2].Goal;
    222           rowValues[k] = goal; // original value
     219          rowValues[k] = activeGoals[j / 2].Goal; // original value
    223220          rowValues[k + 1] = estimatedValues[j / 2]; // estimated value
    224221        }
  • branches/2679_HeuristicLab.GoalSeekingProblem/HeuristicLab.GoalSeekingProblem/3.4/SingleObjectiveGoalSeekingProblem.cs

    r14526 r16901  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    24 using System.Linq;
     22using HEAL.Attic;
    2523using HeuristicLab.Collections;
    2624using HeuristicLab.Common;
     
    3028using HeuristicLab.Optimization;
    3129using HeuristicLab.Parameters;
    32 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3330using HeuristicLab.Problems.DataAnalysis;
     31using System;
     32using System.Collections.Generic;
     33using System.Linq;
    3434
    3535namespace HeuristicLab.GoalSeeking {
    3636  [Item("Goal seeking problem (single-objective)", "Represents a single objective optimization problem which uses configurable regression solutions to evaluate targets from a given dataset.")]
    3737  [Creatable("Problems")]
    38   [StorableClass]
     38  [StorableType("DD67A460-1A32-414A-AB18-E0C773B46689")]
    3939  public sealed class SingleObjectiveGoalSeekingProblem : SingleObjectiveBasicProblem<RealVectorEncoding>, IGoalSeekingProblem {
    4040    #region parameter names
     
    9191      }
    9292      var rows = new[] { 0 }; // actually just one row
    93       var estimatedValues =
    94         round ? ActiveGoals.Select(t => RoundToNearestStepMultiple(GetModels(t.Name).Average(m => m.GetEstimatedValues(ds, rows).Single()), t.Step))
    95               : ActiveGoals.Select(t => GetModels(t.Name).Average(m => m.GetEstimatedValues(ds, rows).Single()));
    96       return estimatedValues;
     93      return round ? ActiveGoals.Select(t => RoundToNearestStepMultiple(GetModels(t.Name).Average(m => m.GetEstimatedValues(ds, rows).Single()), t.Step))
     94                   : ActiveGoals.Select(t => GetModels(t.Name).Average(m => m.GetEstimatedValues(ds, rows).Single()));
    9795    }
    9896
     
    118116    #region constructors
    119117    [StorableConstructor]
    120     private SingleObjectiveGoalSeekingProblem(bool deserializing) : base(deserializing) { }
     118    private SingleObjectiveGoalSeekingProblem(StorableConstructorFlag _) : base(_) { }
    121119
    122120    private SingleObjectiveGoalSeekingProblem(SingleObjectiveGoalSeekingProblem original, Cloner cloner) : base(original, cloner) {
     
    156154      }
    157155      var estimatedValues = GetEstimatedGoalValues(vector, round: true);
    158       var quality = ActiveGoals.Zip(estimatedValues, (t, v) => new { Target = t, EstimatedValue = v })
    159                                .Average(x => x.Target.Weight * Math.Pow(x.EstimatedValue - x.Target.Goal, 2) / x.Target.Variance);
    160       return quality;
     156      return ActiveGoals.Zip(estimatedValues, (t, v) => new { Target = t, EstimatedValue = v })
     157                        .Average(x => x.Target.Weight * Math.Pow(x.EstimatedValue - x.Target.Goal, 2) / x.Target.Variance);
    161158    }
    162159
Note: See TracChangeset for help on using the changeset viewer.