Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5640


Ignore:
Timestamp:
03/09/11 02:08:07 (12 years ago)
Author:
swagner
Message:

Worked on OKB (#1174)

Location:
branches/OKB (trunk integration)
Files:
3 deleted
25 edited

Legend:

Unmodified
Added
Removed
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/HeuristicLab.Clients.OKB-3.3.csproj

    r5612 r5640  
    280280      <DependentUpon>StringComparisonFilterView.cs</DependentUpon>
    281281    </Compile>
     282    <Compile Include="RunCreation\EmptyAlgorithm.cs" />
     283    <Compile Include="RunCreation\EmptyEvaluator.cs" />
     284    <Compile Include="RunCreation\EmptyMultiObjectiveEvaluator.cs" />
     285    <Compile Include="RunCreation\EmptyMultiObjectiveProblem.cs" />
     286    <Compile Include="RunCreation\EmptyProblem.cs" />
     287    <Compile Include="RunCreation\EmptySingleObjectiveEvaluator.cs" />
     288    <Compile Include="RunCreation\EmptySingleObjectiveProblem.cs" />
     289    <Compile Include="RunCreation\EmptySolutionCreator.cs" />
     290    <Compile Include="RunCreation\ItemWrapper.cs" />
     291    <Compile Include="RunCreation\MultiObjectiveOKBProblem.cs" />
     292    <Compile Include="RunCreation\NamedItemWrapper.cs" />
     293    <Compile Include="RunCreation\OKBAlgorithm.cs" />
     294    <Compile Include="RunCreation\OKBProblem.cs" />
     295    <Compile Include="RunCreation\OKBRun.cs" />
     296    <Compile Include="RunCreation\RunCreationClient.cs" />
    282297    <Compile Include="RunCreation\ServiceClient\RunCreationServiceClient.cs" />
    283298    <Compile Include="HeuristicLabClientsOKBPlugin.cs" />
    284299    <Compile Include="Properties\AssemblyInfo.cs" />
     300    <Compile Include="RunCreation\SingleObjectiveOKBProblem.cs" />
     301    <Compile Include="RunCreation\Views\OKBAlgorithmView.cs">
     302      <SubType>UserControl</SubType>
     303    </Compile>
     304    <Compile Include="RunCreation\Views\OKBAlgorithmView.Designer.cs">
     305      <DependentUpon>OKBAlgorithmView.cs</DependentUpon>
     306    </Compile>
     307    <Compile Include="RunCreation\Views\OKBProblemView.cs">
     308      <SubType>UserControl</SubType>
     309    </Compile>
     310    <Compile Include="RunCreation\Views\OKBProblemView.Designer.cs">
     311      <DependentUpon>OKBProblemView.cs</DependentUpon>
     312    </Compile>
    285313    <None Include="app.config" />
    286314    <None Include="Authentication\ServiceClient\GenerateServiceClient.cmd" />
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Query/QueryClient.cs

    r5611 r5640  
    2828
    2929namespace HeuristicLab.Clients.OKB.Query {
    30   [Item("QueryClient", "Client for accessing the OKB.")]
     30  [Item("QueryClient", "OKB query client.")]
    3131  public sealed class QueryClient : IContent {
    3232    private static QueryClient instance;
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/EmptyAlgorithm.cs

    r5639 r5640  
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2727
    28 namespace HeuristicLab.Clients.OKB {
     28namespace HeuristicLab.Clients.OKB.RunCreation {
    2929  [Item("Empty Algorithm", "A dummy algorithm which serves as a placeholder and cannot be executed.")]
    3030  [StorableClass]
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/EmptyEvaluator.cs

    r5639 r5640  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 namespace HeuristicLab.Clients.OKB {
     29namespace HeuristicLab.Clients.OKB.RunCreation {
    3030  [Item("EmptyEvaluator", "A dummy evaluator which throws an exception when executed.")]
    3131  [StorableClass]
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/EmptyMultiObjectiveEvaluator.cs

    r5639 r5640  
    2929using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3030
    31 namespace HeuristicLab.Clients.OKB {
     31namespace HeuristicLab.Clients.OKB.RunCreation {
    3232  [Item("EmptyMultiObjectiveEvaluator", "A dummy multi-objective evaluator which throws an exception when executed.")]
    3333  [StorableClass]
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/EmptyMultiObjectiveProblem.cs

    r5639 r5640  
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2626
    27 namespace HeuristicLab.Clients.OKB {
     27namespace HeuristicLab.Clients.OKB.RunCreation {
    2828  [Item("Empty Multi-Objective Problem", "A dummy multi-objective problem which serves as a placeholder and cannot be solved.")]
    2929  [StorableClass]
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/EmptyProblem.cs

    r5639 r5640  
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2626
    27 namespace HeuristicLab.Clients.OKB {
     27namespace HeuristicLab.Clients.OKB.RunCreation {
    2828  [Item("Empty Problem", "A dummy problem which serves as a placeholder and cannot be solved.")]
    2929  [StorableClass]
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/EmptySingleObjectiveEvaluator.cs

    r5639 r5640  
    2323using HeuristicLab.Common;
    2424using HeuristicLab.Core;
    25 using HeuristicLab.Data;
    2625using HeuristicLab.Operators;
    2726using HeuristicLab.Optimization;
     
    2928using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3029
    31 namespace HeuristicLab.Clients.OKB {
     30namespace HeuristicLab.Clients.OKB.RunCreation {
    3231  [Item("EmptySingleObjectiveEvaluator", "A dummy single-objective evaluator which throws an exception when executed.")]
    3332  [StorableClass]
     
    4241    }
    4342
    44     public ILookupParameter<DoubleValue> QualityParameter {
    45       get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; }
     43    public ILookupParameter<Data.DoubleValue> QualityParameter {
     44      get { return (ILookupParameter<Data.DoubleValue>)Parameters["Quality"]; }
    4645    }
    4746
     
    6261    public EmptySingleObjectiveEvaluator()
    6362      : base() {
    64       Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The evaluated quality of a solution."));
     63      Parameters.Add(new LookupParameter<Data.DoubleValue>("Quality", "The evaluated quality of a solution."));
    6564    }
    6665    public EmptySingleObjectiveEvaluator(string exceptionMessage)
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/EmptySingleObjectiveProblem.cs

    r5639 r5640  
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2626
    27 namespace HeuristicLab.Clients.OKB {
     27namespace HeuristicLab.Clients.OKB.RunCreation {
    2828  [Item("Empty Single-Objective Problem", "A dummy single-objective problem which serves as a placeholder and cannot be solved.")]
    2929  [StorableClass]
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/EmptySolutionCreator.cs

    r5639 r5640  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828
    29 namespace HeuristicLab.Clients.OKB {
     29namespace HeuristicLab.Clients.OKB.RunCreation {
    3030  [Item("EmptySolutionCreator", "A dummy solution creator which throws an exception when executed.")]
    3131  [StorableClass]
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/ItemWrapper.cs

    r5639 r5640  
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2727
    28 namespace HeuristicLab.Clients.OKB {
     28namespace HeuristicLab.Clients.OKB.RunCreation {
    2929  [Item("ItemWrapper", "A wrapper which wraps an IItem.")]
    3030  [StorableClass]
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/MultiObjectiveOKBProblem.cs

    r5639 r5640  
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2727
    28 namespace HeuristicLab.Clients.OKB {
     28namespace HeuristicLab.Clients.OKB.RunCreation {
    2929  [Item("Multi-Objective OKB Problem", "Represents a multi-objective problem which is stored in the OKB.")]
    3030  [Creatable("Optimization Knowledge Base (OKB)")]
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/NamedItemWrapper.cs

    r5639 r5640  
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2626
    27 namespace HeuristicLab.Clients.OKB {
     27namespace HeuristicLab.Clients.OKB.RunCreation {
    2828  [Item("NamedItemWrapper", "A wrapper which wraps an INamedItem.")]
    2929  [StorableClass]
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/OKBAlgorithm.cs

    r5639 r5640  
    3131using HeuristicLab.Persistence.Default.Xml;
    3232
    33 namespace HeuristicLab.Clients.OKB {
     33namespace HeuristicLab.Clients.OKB.RunCreation {
    3434  [Item("OKB Algorithm", "An algorithm which is stored in the OKB.")]
    3535  [Creatable("Optimization Knowledge Base (OKB)")]
     
    7575    }
    7676
     77    public IEnumerable<IOptimizer> NestedOptimizers {
     78      get {
     79        if (Algorithm == null) yield break;
     80        yield return Algorithm;
     81        foreach (IOptimizer optimizer in Algorithm.NestedOptimizers)
     82          yield return optimizer;
     83      }
     84    }
     85
    7786    public override Image ItemImage {
    7887      get { return Algorithm.ItemImage; }
     
    126135      set { Algorithm.StoreAlgorithmInEachRun = value; }
    127136    }
     137
     138
    128139
    129140    #region Persistence Properties
     
    184195      if (this.algorithmId != algorithmId) {
    185196        IAlgorithm algorithm;
    186         AlgorithmData algorithmData = OKBClient.Instance.GetAlgorithmData(algorithmId);
    187         using (MemoryStream stream = new MemoryStream(algorithmData.Data)) {
     197        byte[] algorithmData = RunCreationClient.GetAlgorithmData(algorithmId);
     198        using (MemoryStream stream = new MemoryStream(algorithmData)) {
    188199          algorithm = XmlParser.Deserialize<IAlgorithm>(stream);
    189200        }
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/OKBProblem.cs

    r5639 r5640  
    3030using HeuristicLab.Persistence.Default.Xml;
    3131
    32 namespace HeuristicLab.Clients.OKB {
     32namespace HeuristicLab.Clients.OKB.RunCreation {
    3333  [Item("OKB Problem", "A base class for problems which are stored in the OKB.")]
    3434  [StorableClass]
     
    142142      if (this.problemId != problemId) {
    143143        IProblem problem;
    144         ProblemData problemData = OKBClient.Instance.GetProblemData(problemId);
    145         using (MemoryStream stream = new MemoryStream(problemData.Data)) {
     144        byte[] problemData = RunCreationClient.GetProblemData(problemId);
     145        using (MemoryStream stream = new MemoryStream(problemData)) {
    146146          problem = XmlParser.Deserialize<IProblem>(stream);
    147147        }
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/OKBRun.cs

    r5639 r5640  
    2828using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2929
    30 namespace HeuristicLab.Clients.OKB {
     30namespace HeuristicLab.Clients.OKB.RunCreation {
    3131  [Item("OKB Run", "The parameters and results of an algorithm run which are stored in the OKB.")]
    3232  [StorableClass]
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/RunCreationClient.cs

    r5639 r5640  
    2222using System;
    2323using System.Collections.Generic;
    24 using System.IO;
    25 using System.Linq;
    2624using HeuristicLab.Clients.Common;
    27 using HeuristicLab.Collections;
    2825using HeuristicLab.Common;
    2926using HeuristicLab.Core;
    30 using HeuristicLab.Data;
    31 using HeuristicLab.Optimization;
    32 using HeuristicLab.Persistence.Default.Xml;
    33 using HeuristicLab.PluginInfrastructure;
    3427
    35 namespace HeuristicLab.Clients.OKB {
    36   [Item("OKBClient", "Client for accessing the OKB.")]
    37   public sealed class OKBClient : IContent {
    38     private static OKBClient instance;
    39     public static OKBClient Instance {
     28namespace HeuristicLab.Clients.OKB.RunCreation {
     29  [Item("RunCreationClient", "OKB run creation client.")]
     30  public sealed class RunCreationClient : IContent {
     31    private static RunCreationClient instance;
     32    public static RunCreationClient Instance {
    4033      get {
    41         if (instance == null) instance = new OKBClient();
     34        if (instance == null) instance = new RunCreationClient();
    4235        return instance;
    4336      }
     
    4538
    4639    #region Properties
    47     private ItemCollection<Platform> platforms;
    48     public ItemCollection<Platform> Platforms {
    49       get { return platforms; }
    50     }
    51     private ItemCollection<DataType> dataTypes;
    52     public ItemCollection<DataType> DataTypes {
    53       get { return dataTypes; }
    54     }
    55     private IEnumerable<User> users;
    56     public IEnumerable<User> Users {
    57       get { return users; }
    58     }
    59     private ItemCollection<AlgorithmClass> algorithmClasses;
    60     public ItemCollection<AlgorithmClass> AlgorithmClasses {
    61       get { return algorithmClasses; }
    62     }
    63     private ItemCollection<Algorithm> algorithms;
    64     public ItemCollection<Algorithm> Algorithms {
     40    private List<Algorithm> algorithms;
     41    public IEnumerable<Algorithm> Algorithms {
    6542      get { return algorithms; }
    6643    }
    67     private ItemCollection<ProblemClass> problemClasses;
    68     public ItemCollection<ProblemClass> ProblemClasses {
    69       get { return problemClasses; }
    70     }
    71     private ItemCollection<Problem> problems;
    72     public ItemCollection<Problem> Problems {
     44    private List<Problem> problems;
     45    public IEnumerable<Problem> Problems {
    7346      get { return problems; }
    7447    }
    7548    #endregion
    7649
    77     private OKBClient() {
    78       platforms = new ItemCollection<Platform>();
    79       platforms.ItemsRemoved += new CollectionItemsChangedEventHandler<Platform>(platforms_ItemsRemoved);
    80       dataTypes = new ItemCollection<DataType>();
    81       dataTypes.ItemsRemoved += new CollectionItemsChangedEventHandler<DataType>(dataTypes_ItemsRemoved);
    82       algorithmClasses = new ItemCollection<AlgorithmClass>();
    83       algorithmClasses.ItemsRemoved += new CollectionItemsChangedEventHandler<AlgorithmClass>(algorithmClasses_ItemsRemoved);
    84       algorithms = new ItemCollection<Algorithm>();
    85       algorithms.ItemsRemoved += new CollectionItemsChangedEventHandler<Algorithm>(algorithms_ItemsRemoved);
    86       problemClasses = new ItemCollection<ProblemClass>();
    87       problemClasses.ItemsRemoved += new CollectionItemsChangedEventHandler<ProblemClass>(problemClasses_ItemsRemoved);
    88       problems = new ItemCollection<Problem>();
    89       problems.ItemsRemoved += new CollectionItemsChangedEventHandler<Problem>(problems_ItemsRemoved);
     50    private RunCreationClient() {
     51      algorithms = new List<Algorithm>();
     52      problems = new List<Problem>();
    9053    }
    9154
     
    9356    public void Refresh() {
    9457      OnRefreshing();
    95 
    96       platforms.Clear();
    97       dataTypes.Clear();
    98       algorithmClasses.Clear();
    99       algorithms.Clear();
    100       problemClasses.Clear();
    101       problems.Clear();
    102 
     58      algorithms = new List<Algorithm>();
     59      problems = new List<Problem>();
     60      try {
     61        algorithms.AddRange(CallRunCreationService<List<Algorithm>>(s => s.GetAlgorithms("HeuristicLab 3.3")));
     62        problems.AddRange(CallRunCreationService<List<Problem>>(s => s.GetProblems("HeuristicLab 3.3")));
     63      }
     64      finally {
     65        OnRefreshed();
     66      }
     67    }
     68    public void RefreshAsync(Action<Exception> exceptionCallback) {
    10369      var call = new Func<Exception>(delegate() {
    10470        try {
    105           platforms.AddRange(CallAdministrationService<List<Platform>>(s => s.GetPlatforms()).OrderBy(x => x.Name));
    106           dataTypes.AddRange(CallAdministrationService<List<DataType>>(s => s.GetDataTypes()).OrderBy(x => x.Name));
    107           users = CallAuthenticationService<List<User>>(s => s.GetUsers()).OrderBy(x => x.Name);
    108           algorithmClasses.AddRange(CallAdministrationService<List<AlgorithmClass>>(s => s.GetAlgorithmClasses()).OrderBy(x => x.Name));
    109           algorithms.AddRange(CallAdministrationService<List<Algorithm>>(s => s.GetAlgorithms()).OrderBy(x => x.Name));
    110           problemClasses.AddRange(CallAdministrationService<List<ProblemClass>>(s => s.GetProblemClasses()).OrderBy(x => x.Name));
    111           problems.AddRange(CallAdministrationService<List<Problem>>(s => s.GetProblems()).OrderBy(x => x.Name));
    112           return null;
     71          Refresh();
    11372        }
    11473        catch (Exception ex) {
    11574          return ex;
    11675        }
     76        return null;
    11777      });
    11878      call.BeginInvoke(delegate(IAsyncResult result) {
    11979        Exception ex = call.EndInvoke(result);
    120         if (ex != null) ErrorHandling.ShowErrorDialog("Refresh failed.", ex);
    121         OnRefreshed();
     80        if (ex != null) exceptionCallback(ex);
    12281      }, null);
    12382    }
    12483    #endregion
    12584
    126     #region Store
    127     public bool Store(IOKBItem item) {
    128       try {
    129         if (item.Id == 0) {
    130           if (item is Platform)
    131             item.Id = CallAdministrationService<long>(s => s.AddPlatform((Platform)item));
    132           else if (item is DataType)
    133             item.Id = CallAdministrationService<long>(s => s.AddDataType((DataType)item));
    134           else if (item is AlgorithmClass)
    135             item.Id = CallAdministrationService<long>(s => s.AddAlgorithmClass((AlgorithmClass)item));
    136           else if (item is Algorithm)
    137             item.Id = CallAdministrationService<long>(s => s.AddAlgorithm((Algorithm)item));
    138           else if (item is AlgorithmParameter)
    139             item.Id = CallAdministrationService<long>(s => s.AddAlgorithmParameter((AlgorithmParameter)item));
    140           else if (item is ProblemClass)
    141             item.Id = CallAdministrationService<long>(s => s.AddProblemClass((ProblemClass)item));
    142           else if (item is Problem)
    143             item.Id = CallAdministrationService<long>(s => s.AddProblem((Problem)item));
    144           else if (item is ProblemParameter)
    145             item.Id = CallAdministrationService<long>(s => s.AddProblemParameter((ProblemParameter)item));
    146           else if (item is Result)
    147             item.Id = CallAdministrationService<long>(s => s.AddResult((Result)item));
    148           else if (item is Experiment)
    149             item.Id = CallAdministrationService<long>(s => s.AddExperiment((Experiment)item));
    150           else if (item is Run)
    151             item.Id = CallAdministrationService<long>(s => s.AddRun((Run)item));
    152         } else {
    153           if (item is Platform)
    154             CallAdministrationService(s => s.UpdatePlatform((Platform)item));
    155           else if (item is DataType)
    156             CallAdministrationService(s => s.UpdateDataType((DataType)item));
    157           else if (item is AlgorithmClass)
    158             CallAdministrationService(s => s.UpdateAlgorithmClass((AlgorithmClass)item));
    159           else if (item is Algorithm)
    160             CallAdministrationService(s => s.UpdateAlgorithm((Algorithm)item));
    161           else if (item is AlgorithmParameter)
    162             CallAdministrationService(s => s.UpdateAlgorithmParameter((AlgorithmParameter)item));
    163           else if (item is ProblemClass)
    164             CallAdministrationService(s => s.UpdateProblemClass((ProblemClass)item));
    165           else if (item is Problem)
    166             CallAdministrationService(s => s.UpdateProblem((Problem)item));
    167           else if (item is ProblemParameter)
    168             CallAdministrationService(s => s.UpdateProblemParameter((ProblemParameter)item));
    169           else if (item is Result)
    170             CallAdministrationService(s => s.UpdateResult((Result)item));
    171           else if (item is Experiment)
    172             item.Id = CallAdministrationService<long>(s => s.AddExperiment((Experiment)item));
    173           else if (item is Run)
    174             item.Id = CallAdministrationService<long>(s => s.AddRun((Run)item));
    175         }
    176         return true;
    177       }
    178       catch (Exception ex) {
    179         ErrorHandling.ShowErrorDialog("Store failed.", ex);
    180         return false;
    181       }
    182     }
    183     #endregion
    184 
    185     #region DataType Methods
    186     public DataType ConvertToDataType(Type type) {
    187       DataType dataType = DataTypes.FirstOrDefault(x => x.TypeName == type.AssemblyQualifiedName);
    188       if (dataType == null) {
    189         dataType = new DataType();
    190         dataType.Name = type.Name;
    191         dataType.TypeName = type.AssemblyQualifiedName;
    192         dataType.PlatformId = Platforms.FirstOrDefault(x => x.Name == "HeuristicLab 3.3").Id;
    193 
    194         if (typeof(BoolValue).IsAssignableFrom(type))
    195           dataType.SqlName = "bit";
    196         else if (typeof(IntValue).IsAssignableFrom(type))
    197           dataType.SqlName = "bigint";
    198         else if (typeof(DoubleValue).IsAssignableFrom(type))
    199           dataType.SqlName = "float";
    200         else if (typeof(StringValue).IsAssignableFrom(type) || typeof(IStringConvertibleValue).IsAssignableFrom(type))
    201           dataType.SqlName = "nvarchar";
    202         else
    203           dataType.SqlName = "varbinary";
    204 
    205         dataType.Store();
    206         DataTypes.Add(dataType);
    207       }
    208       return dataType;
    209     }
    210     #endregion
    211 
    21285    #region Algorithm Methods
    213     public List<Guid> GetAlgorithmUsers(long algorithmId) {
    214       try {
    215         return CallAdministrationService<List<Guid>>(s => s.GetAlgorithmUsers(algorithmId));
    216       }
    217       catch (Exception ex) {
    218         ErrorHandling.ShowErrorDialog("Refresh authorized algorithm users failed.", ex);
    219         return null;
    220       }
    221     }
    222     public bool UpdateAlgorithmUsers(long algorithmId, List<Guid> users) {
    223       try {
    224         CallAdministrationService(s => s.UpdateAlgorithmUsers(algorithmId, users));
    225         return true;
    226       }
    227       catch (Exception ex) {
    228         ErrorHandling.ShowErrorDialog("Update authorized algorithm users failed.", ex);
    229         return false;
    230       }
    231     }
    232     public AlgorithmData GetAlgorithmData(long algorithmId) {
    233       try {
    234         return CallAdministrationService<AlgorithmData>(s => s.GetAlgorithmData(algorithmId));
    235       }
    236       catch (Exception ex) {
    237         ErrorHandling.ShowErrorDialog("Refresh algorithm data failed.", ex);
    238         return null;
    239       }
    240     }
    241     public bool UpdateAlgorithmData(AlgorithmData algorithmData) {
    242       try {
    243         CallAdministrationService(s => s.UpdateAlgorithmData(algorithmData));
    244         return true;
    245       }
    246       catch (Exception ex) {
    247         ErrorHandling.ShowErrorDialog("Update algorithm data failed.", ex);
    248         return false;
    249       }
     86    public static byte[] GetAlgorithmData(long algorithmId) {
     87      return CallRunCreationService<byte[]>(s => s.GetAlgorithmData(algorithmId));
    25088    }
    25189    #endregion
    25290
    25391    #region Problem Methods
    254     public List<Guid> GetProblemUsers(long problemId) {
    255       try {
    256         return CallAdministrationService<List<Guid>>(s => s.GetProblemUsers(problemId));
    257       }
    258       catch (Exception ex) {
    259         ErrorHandling.ShowErrorDialog("Refresh authorized problem users failed.", ex);
    260         return null;
    261       }
    262     }
    263     public bool UpdateProblemUsers(long problemId, List<Guid> users) {
    264       try {
    265         CallAdministrationService(s => s.UpdateProblemUsers(problemId, users));
    266         return true;
    267       }
    268       catch (Exception ex) {
    269         ErrorHandling.ShowErrorDialog("Update authorized problem users failed.", ex);
    270         return false;
    271       }
    272     }
    273     public ProblemData GetProblemData(long problemId) {
    274       try {
    275         return CallAdministrationService<ProblemData>(s => s.GetProblemData(problemId));
    276       }
    277       catch (Exception ex) {
    278         ErrorHandling.ShowErrorDialog("Refresh problem data failed.", ex);
    279         return null;
    280       }
    281     }
    282     public bool UpdateProblemData(ProblemData problemData) {
    283       try {
    284         CallAdministrationService(s => s.UpdateProblemData(problemData));
    285         return true;
    286       }
    287       catch (Exception ex) {
    288         ErrorHandling.ShowErrorDialog("Update problem data failed.", ex);
    289         return false;
    290       }
    291     }
    292     #endregion
    293 
    294     #region AlgorithmParameter Methods
    295     public AlgorithmParameter GetAlgorithmParameter(long id) {
    296       try {
    297         return CallAdministrationService<AlgorithmParameter>(s => s.GetAlgorithmParameter(id));
    298       }
    299       catch (Exception ex) {
    300         ErrorHandling.ShowErrorDialog("Refresh algorithm parameter failed.", ex);
    301         return null;
    302       }
    303     }
    304     public ItemCollection<AlgorithmParameter> GetAlgorithmParameters(long algorithmId) {
    305       try {
    306         ItemCollection<AlgorithmParameter> parameters = new ItemCollection<AlgorithmParameter>();
    307         parameters.AddRange(CallAdministrationService<List<AlgorithmParameter>>(s => s.GetAlgorithmParameters(algorithmId)).OrderBy(x => x.Name));
    308         return parameters;
    309       }
    310       catch (Exception ex) {
    311         ErrorHandling.ShowErrorDialog("Refresh algorithm parameters failed.", ex);
    312         return null;
    313       }
    314     }
    315     #endregion
    316 
    317     #region ProblemParameter Methods
    318     public ProblemParameter GetProblemParameter(long id) {
    319       try {
    320         return CallAdministrationService<ProblemParameter>(s => s.GetProblemParameter(id));
    321       }
    322       catch (Exception ex) {
    323         ErrorHandling.ShowErrorDialog("Refresh problem parameter failed.", ex);
    324         return null;
    325       }
    326     }
    327     public ItemCollection<ProblemParameter> GetProblemParameters(long problemId) {
    328       try {
    329         ItemCollection<ProblemParameter> parameters = new ItemCollection<ProblemParameter>();
    330         parameters.AddRange(CallAdministrationService<List<ProblemParameter>>(s => s.GetProblemParameters(problemId)).OrderBy(x => x.Name));
    331         return parameters;
    332       }
    333       catch (Exception ex) {
    334         ErrorHandling.ShowErrorDialog("Refresh problem parameters failed.", ex);
    335         return null;
    336       }
    337     }
    338     #endregion
    339 
    340     #region Result Methods
    341     public Result GetResult(long id) {
    342       try {
    343         return CallAdministrationService<Result>(s => s.GetResult(id));
    344       }
    345       catch (Exception ex) {
    346         ErrorHandling.ShowErrorDialog("Refresh result failed.", ex);
    347         return null;
    348       }
    349     }
    350     public ItemCollection<Result> GetResults(long algorithmId) {
    351       try {
    352         ItemCollection<Result> results = new ItemCollection<Result>();
    353         results.AddRange(CallAdministrationService<List<Result>>(s => s.GetResults(algorithmId)).OrderBy(x => x.Name));
    354         return results;
    355       }
    356       catch (Exception ex) {
    357         ErrorHandling.ShowErrorDialog("Refresh results failed.", ex);
    358         return null;
    359       }
    360     }
    361     #endregion
    362 
    363     #region Experiment Methods
    364     public Experiment GetExperiment(long id) {
    365       try {
    366         return CallAdministrationService<Experiment>(s => s.GetExperiment(id));
    367       }
    368       catch (Exception ex) {
    369         ErrorHandling.ShowErrorDialog("Refresh experiment failed.", ex);
    370         return null;
    371       }
    372     }
    373     public ItemCollection<Experiment> GetExperiments(long algorithmId, long problemId) {
    374       try {
    375         ItemCollection<Experiment> experiments = new ItemCollection<Experiment>();
    376         experiments.AddRange(CallAdministrationService<List<Experiment>>(s => s.GetExperiments(algorithmId, problemId)));
    377         experiments.ItemsRemoved += new CollectionItemsChangedEventHandler<Experiment>(experiments_ItemsRemoved);
    378         return experiments;
    379       }
    380       catch (Exception ex) {
    381         ErrorHandling.ShowErrorDialog("Refresh experiments failed.", ex);
    382         return null;
    383       }
     92    public static byte[] GetProblemData(long problemId) {
     93      return CallRunCreationService<byte[]>(s => s.GetProblemData(problemId));
    38494    }
    38595    #endregion
    38696
    38797    #region Run Methods
    388     public ItemCollection<Run> GetRuns(long experimentId) {
    389       try {
    390         ItemCollection<Run> runs = new ItemCollection<Run>();
    391         runs.AddRange(CallAdministrationService<List<Run>>(s => s.GetRuns(experimentId)).OrderByDescending(x => x.CreatedDate));
    392         runs.ItemsRemoved += new CollectionItemsChangedEventHandler<Run>(runs_ItemsRemoved);
    393         return runs;
    394       }
    395       catch (Exception ex) {
    396         ErrorHandling.ShowErrorDialog("Refresh runs failed.", ex);
    397         return null;
    398       }
    399     }
    400     public bool AddRun(long algorithmId, long problemId, IAlgorithm algorithm) {
    401       try {
    402         IProblem problem = algorithm.Problem;
    403 
    404         ItemCollection<AlgorithmParameter> algorithmParameters = GetAlgorithmParameters(algorithmId);
    405         List<AlgorithmParameterValue> algorithmParameterValues = CollectAlgorithmParameterValues(algorithmId, algorithmParameters, algorithm, "");
    406         ItemCollection<ProblemParameter> problemParameters = GetProblemParameters(problemId);
    407         List<ProblemParameterValue> problemParameterValues = CollectProblemParamterValues(problemId, problemParameters, problem, "");
    408         ItemCollection<Result> results = GetResults(algorithmId);
    409         List<ResultValue> resultValues = CollectResultValues(algorithmId, results, algorithm);
    410 
    411         Experiment exp = new Experiment();
    412         exp.AlgorithmId = algorithmId;
    413         exp.ProblemId = problemId;
    414         exp.AlgorithmParameterValues = algorithmParameterValues;
    415         exp.ProblemParameterValues = problemParameterValues;
    416         exp.Store();
    417 
    418         Run r = new Run();
    419         r.ExperimentId = exp.Id;
    420         r.ClientId = Guid.NewGuid();
    421         r.CreatedDate = DateTime.Now;
    422         r.RandomSeed = ((IntValue)((IValueParameter)algorithm.Parameters["Seed"]).Value).Value;
    423         r.ResultValues = resultValues;
    424         r.Store();
    425 
    426         return true;
    427       }
    428       catch (Exception ex) {
    429         ErrorHandling.ShowErrorDialog("Store run failed.", ex);
    430         return false;
    431       }
    432     }
    433 
    434     private List<AlgorithmParameterValue> CollectAlgorithmParameterValues(long algorithmId, ItemCollection<AlgorithmParameter> parameters, IParameterizedItem item, string prefix) {
    435       List<AlgorithmParameterValue> values = new List<AlgorithmParameterValue>();
    436       foreach (IValueParameter param in item.Parameters.OfType<IValueParameter>()) {
    437         if (param.GetsCollected && (param.Value != null) && (param.Name != "Seed")) {
    438           AlgorithmParameter p = parameters.FirstOrDefault(x => x.Name == prefix + param.Name);
    439           if (p == null) {
    440             p = new AlgorithmParameter();
    441             p.Name = prefix + param.Name;
    442             p.Alias = prefix + param.Name;
    443             p.Description = param.Description;
    444             p.AlgorithmId = algorithmId;
    445             p.DataTypeId = ConvertToDataType(param.DataType).Id;
    446             p.Store();
    447             parameters.Add(p);
    448           }
    449           AlgorithmParameterValue value = CreateAlgorithmParameterValue(param.Value);
    450           value.AlgorithmParameterId = p.Id;
    451           value.DataTypeId = ConvertToDataType(param.Value.GetType()).Id;
    452           values.Add(value);
    453         }
    454 
    455         if (param.Value is IParameterizedItem)
    456           values.AddRange(CollectAlgorithmParameterValues(algorithmId, parameters, (IParameterizedItem)param.Value, (string.IsNullOrEmpty(prefix) ? param.Name : prefix + param.Name) + "."));
    457       }
    458       return values;
    459     }
    460     private AlgorithmParameterValue CreateAlgorithmParameterValue(IItem item) {
    461       if (item is BoolValue) {
    462         AlgorithmParameterBoolValue value = new AlgorithmParameterBoolValue();
    463         value.Value = ((BoolValue)item).Value;
    464         return value;
    465       } else if (item is DoubleValue) {
    466         AlgorithmParameterFloatValue value = new AlgorithmParameterFloatValue();
    467         value.Value = ((DoubleValue)item).Value;
    468         return value;
    469       } else if (item is IntValue) {
    470         AlgorithmParameterIntValue value = new AlgorithmParameterIntValue();
    471         value.Value = ((IntValue)item).Value;
    472         return value;
    473       } else if (item is StringValue) {
    474         AlgorithmParameterStringValue value = new AlgorithmParameterStringValue();
    475         value.Value = ((StringValue)item).Value;
    476         return value;
    477       } else {
    478         AlgorithmParameterBlobValue value = new AlgorithmParameterBlobValue();
    479         try {
    480           using (MemoryStream stream = new MemoryStream()) {
    481             XmlGenerator.Serialize(item, stream);
    482             stream.Close();
    483             value.Value = stream.ToArray();
    484           }
    485         }
    486         catch (Exception ex) {
    487           ErrorHandling.ShowErrorDialog(ex);
    488         }
    489         return value;
    490       }
    491     }
    492     private List<ProblemParameterValue> CollectProblemParamterValues(long problemId, ItemCollection<ProblemParameter> parameters, IParameterizedItem item, string prefix) {
    493       List<ProblemParameterValue> values = new List<ProblemParameterValue>();
    494       foreach (IValueParameter param in item.Parameters.OfType<IValueParameter>()) {
    495         if (param.GetsCollected && (param.Value != null)) {
    496           ProblemParameter p = parameters.FirstOrDefault(x => x.Name == prefix + param.Name);
    497           if (p == null) {
    498             p = new ProblemParameter();
    499             p.Name = prefix + param.Name;
    500             p.Alias = prefix + param.Name;
    501             p.Description = param.Description;
    502             p.ProblemId = problemId;
    503             p.DataTypeId = ConvertToDataType(param.DataType).Id;
    504             p.Store();
    505             parameters.Add(p);
    506           }
    507           ProblemParameterValue value = CreateProblemParameterValue(param.Value);
    508           value.ProblemParameterId = p.Id;
    509           value.DataTypeId = ConvertToDataType(param.Value.GetType()).Id;
    510           values.Add(value);
    511         }
    512 
    513         if (param.Value is IParameterizedItem)
    514           values.AddRange(CollectProblemParamterValues(problemId, parameters, (IParameterizedItem)param.Value, (string.IsNullOrEmpty(prefix) ? param.Name : prefix + param.Name) + "."));
    515       }
    516       return values;
    517     }
    518     private ProblemParameterValue CreateProblemParameterValue(IItem item) {
    519       if (item is BoolValue) {
    520         ProblemParameterBoolValue value = new ProblemParameterBoolValue();
    521         value.Value = ((BoolValue)item).Value;
    522         return value;
    523       } else if (item is DoubleValue) {
    524         ProblemParameterFloatValue value = new ProblemParameterFloatValue();
    525         value.Value = ((DoubleValue)item).Value;
    526         return value;
    527       } else if (item is IntValue) {
    528         ProblemParameterIntValue value = new ProblemParameterIntValue();
    529         value.Value = ((IntValue)item).Value;
    530         return value;
    531       } else if (item is StringValue) {
    532         ProblemParameterStringValue value = new ProblemParameterStringValue();
    533         value.Value = ((StringValue)item).Value;
    534         return value;
    535       } else {
    536         ProblemParameterBlobValue value = new ProblemParameterBlobValue();
    537         try {
    538           using (MemoryStream stream = new MemoryStream()) {
    539             XmlGenerator.Serialize(item, stream);
    540             stream.Close();
    541             value.Value = stream.ToArray();
    542           }
    543         }
    544         catch (Exception ex) {
    545           ErrorHandling.ShowErrorDialog(ex);
    546         }
    547         return value;
    548       }
    549     }
    550     private List<ResultValue> CollectResultValues(long algorithmId, ItemCollection<Result> results, IAlgorithm algorithm) {
    551       List<ResultValue> values = new List<ResultValue>();
    552       foreach (IResult result in algorithm.Results) {
    553         if (result.Value != null) {
    554           Result r = results.FirstOrDefault(x => x.Name == result.Name);
    555           if (r == null) {
    556             r = new Result();
    557             r.Name = result.Name;
    558             r.Alias = result.Name;
    559             r.Description = result.Description;
    560             r.AlgorithmId = algorithmId;
    561             r.DataTypeId = ConvertToDataType(result.DataType).Id;
    562             r.Store();
    563             results.Add(r);
    564           }
    565           ResultValue value = CreateResultValue(result.Value);
    566           value.ResultId = r.Id;
    567           value.DataTypeId = ConvertToDataType(result.Value.GetType()).Id;
    568           values.Add(value);
    569         }
    570       }
    571       return values;
    572     }
    573     private ResultValue CreateResultValue(IItem item) {
    574       if (item is BoolValue) {
    575         ResultBoolValue value = new ResultBoolValue();
    576         value.Value = ((BoolValue)item).Value;
    577         return value;
    578       } else if (item is DoubleValue) {
    579         ResultFloatValue value = new ResultFloatValue();
    580         value.Value = ((DoubleValue)item).Value;
    581         return value;
    582       } else if (item is IntValue) {
    583         ResultIntValue value = new ResultIntValue();
    584         value.Value = ((IntValue)item).Value;
    585         return value;
    586       } else if (item is StringValue) {
    587         ResultStringValue value = new ResultStringValue();
    588         value.Value = ((StringValue)item).Value;
    589         return value;
    590       } else {
    591         ResultBlobValue value = new ResultBlobValue();
    592         try {
    593           using (MemoryStream stream = new MemoryStream()) {
    594             XmlGenerator.Serialize(item, stream);
    595             stream.Close();
    596             value.Value = stream.ToArray();
    597           }
    598         }
    599         catch (Exception ex) {
    600           ErrorHandling.ShowErrorDialog(ex);
    601         }
    602         return value;
    603       }
    604     }
    605     #endregion
    606 
    607     #region Query Methods
    608     private IEnumerable<Filter> filters;
    609     public IEnumerable<Filter> GetFilters(bool refresh) {
    610       if (refresh || (filters == null)) {
    611         try {
    612           filters = CallQueryService<List<Filter>>(s => s.GetFilters());
    613         }
    614         catch (Exception ex) {
    615           ErrorHandling.ShowErrorDialog("Get filters failed.", ex);
    616           return Enumerable.Empty<Filter>();
    617         }
    618       }
    619       return filters;
    620     }
    621     public IEnumerable<Filter> GetFilters() {
    622       return GetFilters(false);
    623     }
    624     public long GetNumberOfQueryResults(Filter filter) {
    625       try {
    626         return CallQueryService<long>(x => x.GetNumberOfQueryResults(filter));
    627       }
    628       catch (Exception ex) {
    629         ErrorHandling.ShowErrorDialog("Get number of query results failed.", ex);
    630         return -1;
    631       }
    632     }
    633     public IEnumerable<long> GetQueryResultIds(Filter filter) {
    634       try {
    635         return CallQueryService<IEnumerable<long>>(x => x.GetQueryResultIds(filter));
    636       }
    637       catch (Exception ex) {
    638         ErrorHandling.ShowErrorDialog("Get query result ids failed.", ex);
    639         return Enumerable.Empty<long>();
    640       }
    641     }
    642     public IEnumerable<QueryResult> GetQueryResults(IEnumerable<long> ids) {
    643       try {
    644         return CallQueryService<IEnumerable<QueryResult>>(s => s.GetQueryResults(ids.ToList()));
    645       }
    646       catch (Exception ex) {
    647         ErrorHandling.ShowErrorDialog("Get query results failed.", ex);
    648         return null;
    649       }
     98    public void AddRun(Run run) {
     99      CallRunCreationService(s => s.AddRun(run));
    650100    }
    651101    #endregion
     
    662112      if (handler != null) handler(this, EventArgs.Empty);
    663113    }
    664 
    665     private void platforms_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<Platform> e) {
    666       try {
    667         foreach (Platform p in e.Items)
    668           CallAdministrationService(s => s.DeletePlatform(p.Id));
    669       }
    670       catch (Exception ex) {
    671         ErrorHandling.ShowErrorDialog("Delete failed.", ex);
    672       }
    673     }
    674     private void dataTypes_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<DataType> e) {
    675       try {
    676         foreach (DataType d in e.Items)
    677           CallAdministrationService(s => s.DeleteDataType(d.Id));
    678       }
    679       catch (Exception ex) {
    680         ErrorHandling.ShowErrorDialog("Delete failed.", ex);
    681       }
    682     }
    683     private void algorithmClasses_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<AlgorithmClass> e) {
    684       try {
    685         foreach (AlgorithmClass a in e.Items)
    686           CallAdministrationService(s => s.DeleteAlgorithmClass(a.Id));
    687       }
    688       catch (Exception ex) {
    689         ErrorHandling.ShowErrorDialog("Delete failed.", ex);
    690       }
    691     }
    692     private void algorithms_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<Algorithm> e) {
    693       try {
    694         foreach (Algorithm a in e.Items)
    695           CallAdministrationService(s => s.DeleteAlgorithm(a.Id));
    696       }
    697       catch (Exception ex) {
    698         ErrorHandling.ShowErrorDialog("Delete failed.", ex);
    699       }
    700     }
    701     private void problemClasses_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<ProblemClass> e) {
    702       try {
    703         foreach (ProblemClass p in e.Items)
    704           CallAdministrationService(s => s.DeleteProblemClass(p.Id));
    705       }
    706       catch (Exception ex) {
    707         ErrorHandling.ShowErrorDialog("Delete failed.", ex);
    708       }
    709     }
    710     private void problems_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<Problem> e) {
    711       try {
    712         foreach (Problem p in e.Items)
    713           CallAdministrationService(s => s.DeleteProblem(p.Id));
    714       }
    715       catch (Exception ex) {
    716         ErrorHandling.ShowErrorDialog("Delete failed.", ex);
    717       }
    718     }
    719     private void experiments_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<Experiment> e) {
    720       try {
    721         foreach (Experiment exp in e.Items)
    722           CallAdministrationService(s => s.DeleteExperiment(exp.Id));
    723       }
    724       catch (Exception ex) {
    725         ErrorHandling.ShowErrorDialog("Delete failed.", ex);
    726       }
    727     }
    728     private void runs_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<Run> e) {
    729       try {
    730         foreach (Run r in e.Items)
    731           CallAdministrationService(s => s.DeleteRun(r.Id));
    732       }
    733       catch (Exception ex) {
    734         ErrorHandling.ShowErrorDialog("Delete failed.", ex);
    735       }
    736     }
    737114    #endregion
    738115
    739116    #region Helpers
    740     private void CallAdministrationService(Action<IAdministrationService> call) {
    741       AdministrationServiceClient client = ClientFactory.CreateClient<AdministrationServiceClient, IAdministrationService>();
     117    private static void CallRunCreationService(Action<IRunCreationService> call) {
     118      RunCreationServiceClient client = ClientFactory.CreateClient<RunCreationServiceClient, IRunCreationService>();
    742119      try {
    743120        call(client);
     
    752129      }
    753130    }
    754     private T CallAdministrationService<T>(Func<IAdministrationService, T> call) {
    755       AdministrationServiceClient client = ClientFactory.CreateClient<AdministrationServiceClient, IAdministrationService>();
    756       try {
    757         return call(client);
    758       }
    759       finally {
    760         try {
    761           client.Close();
    762         }
    763         catch (Exception) {
    764           client.Abort();
    765         }
    766       }
    767     }
    768     private void CallQueryService(Action<IQueryService> call) {
    769       QueryServiceClient client = ClientFactory.CreateClient<QueryServiceClient, IQueryService>();
    770       try {
    771         call(client);
    772       }
    773       finally {
    774         try {
    775           client.Close();
    776         }
    777         catch (Exception) {
    778           client.Abort();
    779         }
    780       }
    781     }
    782     private T CallQueryService<T>(Func<IQueryService, T> call) {
    783       QueryServiceClient client = ClientFactory.CreateClient<QueryServiceClient, IQueryService>();
    784       try {
    785         return call(client);
    786       }
    787       finally {
    788         try {
    789           client.Close();
    790         }
    791         catch (Exception) {
    792           client.Abort();
    793         }
    794       }
    795     }
    796     private T CallAuthenticationService<T>(Func<IAuthenticationService, T> call) {
    797       AuthenticationServiceClient client = ClientFactory.CreateClient<AuthenticationServiceClient, IAuthenticationService>();
     131    private static T CallRunCreationService<T>(Func<IRunCreationService, T> call) {
     132      RunCreationServiceClient client = ClientFactory.CreateClient<RunCreationServiceClient, IRunCreationService>();
    798133      try {
    799134        return call(client);
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/ServiceClient/RunCreationServiceClient.cs

    r5504 r5640  
    953953       
    954954        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IRunCreationService/AddRun", ReplyAction="http://tempuri.org/IRunCreationService/AddRunResponse")]
    955         long AddRun(HeuristicLab.Clients.OKB.RunCreation.Run run);
     955        void AddRun(HeuristicLab.Clients.OKB.RunCreation.Run run);
    956956    }
    957957   
     
    10101010        }
    10111011       
    1012         public long AddRun(HeuristicLab.Clients.OKB.RunCreation.Run run)
    1013         {
    1014             return base.Channel.AddRun(run);
     1012        public void AddRun(HeuristicLab.Clients.OKB.RunCreation.Run run)
     1013        {
     1014            base.Channel.AddRun(run);
    10151015        }
    10161016    }
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/SingleObjectiveOKBProblem.cs

    r5639 r5640  
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2727
    28 namespace HeuristicLab.Clients.OKB {
     28namespace HeuristicLab.Clients.OKB.RunCreation {
    2929  [Item("Single-Objective OKB Problem", "Represents a single-objective problem which is stored in the OKB.")]
    3030  [Creatable("Optimization Knowledge Base (OKB)")]
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/Views/OKBAlgorithmView.Designer.cs

    r5639 r5640  
    2020#endregion
    2121
    22 namespace HeuristicLab.Clients.OKB {
     22namespace HeuristicLab.Clients.OKB.RunCreation {
    2323  partial class OKBAlgorithmView {
    2424    /// <summary>
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/Views/OKBAlgorithmView.cs

    r5639 r5640  
    2727using HeuristicLab.MainForm.WindowsForms;
    2828
    29 namespace HeuristicLab.Clients.OKB {
     29namespace HeuristicLab.Clients.OKB.RunCreation {
    3030  [View("OKBAlgorithm View")]
    3131  [Content(typeof(OKBAlgorithm), true)]
     
    4242    protected override void OnInitialized(System.EventArgs e) {
    4343      base.OnInitialized(e);
    44       OKBClient.Instance.Refreshing += new EventHandler(OKBClient_Refreshing);
    45       OKBClient.Instance.Refreshed += new EventHandler(OKBClient_Refreshed);
     44      RunCreationClient.Instance.Refreshing += new EventHandler(RunCreationClient_Refreshing);
     45      RunCreationClient.Instance.Refreshed += new EventHandler(RunCreationClient_Refreshed);
    4646      PopulateComboBox();
    4747    }
     
    6262        viewHost.Content = null;
    6363      } else {
    64         algorithmComboBox.SelectedItem = OKBClient.Instance.Algorithms.FirstOrDefault(x => x.Id == Content.AlgorithmId);
     64        algorithmComboBox.SelectedItem = RunCreationClient.Instance.Algorithms.FirstOrDefault(x => x.Id == Content.AlgorithmId);
    6565        viewHost.Content = Content.Algorithm;
    6666      }
     
    7474    private void PopulateComboBox() {
    7575      algorithmComboBox.DataSource = null;
    76       Platform platform = OKBClient.Instance.Platforms.FirstOrDefault(x => x.Name == "HeuristicLab 3.3");
    77       if (platform != null) {
    78         algorithmComboBox.DataSource = OKBClient.Instance.Algorithms.Where(x => x.PlatformId == platform.Id).ToList();
    79         algorithmComboBox.DisplayMember = "Name";
    80       }
     76      algorithmComboBox.DataSource = RunCreationClient.Instance.Algorithms.ToList();
     77      algorithmComboBox.DisplayMember = "Name";
    8178    }
    8279
    8380    protected override void OnClosed(FormClosedEventArgs e) {
    84       OKBClient.Instance.Refreshing -= new EventHandler(OKBClient_Refreshing);
    85       OKBClient.Instance.Refreshed -= new EventHandler(OKBClient_Refreshed);
     81      RunCreationClient.Instance.Refreshing -= new EventHandler(RunCreationClient_Refreshing);
     82      RunCreationClient.Instance.Refreshed -= new EventHandler(RunCreationClient_Refreshed);
    8683      base.OnClosed(e);
    8784    }
    8885
    89     private void OKBClient_Refreshing(object sender, EventArgs e) {
     86    private void RunCreationClient_Refreshing(object sender, EventArgs e) {
    9087      if (InvokeRequired) {
    91         Invoke(new EventHandler(OKBClient_Refreshing), sender, e);
     88        Invoke(new EventHandler(RunCreationClient_Refreshing), sender, e);
    9289      } else {
    9390        Cursor = Cursors.AppStarting;
     
    9592      }
    9693    }
    97     private void OKBClient_Refreshed(object sender, EventArgs e) {
     94    private void RunCreationClient_Refreshed(object sender, EventArgs e) {
    9895      if (InvokeRequired) {
    99         Invoke(new EventHandler(OKBClient_Refreshed), sender, e);
     96        Invoke(new EventHandler(RunCreationClient_Refreshed), sender, e);
    10097      } else {
    10198        PopulateComboBox();
     
    110107        Invoke(new EventHandler(Content_AlgorithmChanged), sender, e);
    111108      else {
    112         algorithmComboBox.SelectedItem = OKBClient.Instance.Algorithms.FirstOrDefault(x => x.Id == Content.AlgorithmId);
     109        algorithmComboBox.SelectedItem = RunCreationClient.Instance.Algorithms.FirstOrDefault(x => x.Id == Content.AlgorithmId);
    113110        viewHost.Content = Content.Algorithm;
    114111      }
     
    118115    #region Control Events
    119116    private void refreshButton_Click(object sender, System.EventArgs e) {
    120       OKBClient.Instance.Refresh();
     117      RunCreationClient.Instance.Refresh();
    121118    }
    122119    private void algorithmComboBox_SelectedValueChanged(object sender, System.EventArgs e) {
     
    125122        Content.Load(algorithm.Id);
    126123        if (Content.AlgorithmId != algorithm.Id)  // reset selected item if load was not successful
    127           algorithmComboBox.SelectedItem = OKBClient.Instance.Algorithms.FirstOrDefault(x => x.Id == Content.AlgorithmId);
     124          algorithmComboBox.SelectedItem = RunCreationClient.Instance.Algorithms.FirstOrDefault(x => x.Id == Content.AlgorithmId);
    128125      }
    129126    }
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/Views/OKBProblemView.Designer.cs

    r5639 r5640  
    2020#endregion
    2121
    22 namespace HeuristicLab.Clients.OKB {
     22namespace HeuristicLab.Clients.OKB.RunCreation {
    2323  partial class OKBProblemView {
    2424    /// <summary>
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/Views/OKBProblemView.cs

    r5639 r5640  
    2727using HeuristicLab.MainForm.WindowsForms;
    2828
    29 namespace HeuristicLab.Clients.OKB {
     29namespace HeuristicLab.Clients.OKB.RunCreation {
    3030  [View("OKBProblem View")]
    3131  [Content(typeof(OKBProblem), true)]
     
    4242    protected override void OnInitialized(System.EventArgs e) {
    4343      base.OnInitialized(e);
    44       OKBClient.Instance.Refreshing += new EventHandler(OKBClient_Refreshing);
    45       OKBClient.Instance.Refreshed += new EventHandler(OKBClient_Refreshed);
     44      RunCreationClient.Instance.Refreshing += new EventHandler(RunCreationClient_Refreshing);
     45      RunCreationClient.Instance.Refreshed += new EventHandler(RunCreationClient_Refreshed);
    4646      PopulateComboBox();
    4747    }
     
    6262        viewHost.Content = null;
    6363      } else {
    64         problemComboBox.SelectedItem = OKBClient.Instance.Problems.FirstOrDefault(x => x.Id == Content.ProblemId);
     64        problemComboBox.SelectedItem = RunCreationClient.Instance.Problems.FirstOrDefault(x => x.Id == Content.ProblemId);
    6565        viewHost.Content = Content.Problem;
    6666      }
     
    7474    private void PopulateComboBox() {
    7575      problemComboBox.DataSource = null;
    76       Platform platform = OKBClient.Instance.Platforms.FirstOrDefault(x => x.Name == "HeuristicLab 3.3");
    77       if (platform != null) {
    78         problemComboBox.DataSource = OKBClient.Instance.Problems.Where(x => x.PlatformId == platform.Id).ToList();
    79         problemComboBox.DisplayMember = "Name";
    80       }
     76      problemComboBox.DataSource = RunCreationClient.Instance.Problems.ToList();
     77      problemComboBox.DisplayMember = "Name";
    8178    }
    8279
    8380    protected override void OnClosed(FormClosedEventArgs e) {
    84       OKBClient.Instance.Refreshing -= new EventHandler(OKBClient_Refreshing);
    85       OKBClient.Instance.Refreshed -= new EventHandler(OKBClient_Refreshed);
     81      RunCreationClient.Instance.Refreshing -= new EventHandler(RunCreationClient_Refreshing);
     82      RunCreationClient.Instance.Refreshed -= new EventHandler(RunCreationClient_Refreshed);
    8683      base.OnClosed(e);
    8784    }
    8885
    89     private void OKBClient_Refreshing(object sender, EventArgs e) {
     86    private void RunCreationClient_Refreshing(object sender, EventArgs e) {
    9087      if (InvokeRequired) {
    91         Invoke(new EventHandler(OKBClient_Refreshing), sender, e);
     88        Invoke(new EventHandler(RunCreationClient_Refreshing), sender, e);
    9289      } else {
    9390        Cursor = Cursors.AppStarting;
     
    9592      }
    9693    }
    97     private void OKBClient_Refreshed(object sender, EventArgs e) {
     94    private void RunCreationClient_Refreshed(object sender, EventArgs e) {
    9895      if (InvokeRequired) {
    99         Invoke(new EventHandler(OKBClient_Refreshed), sender, e);
     96        Invoke(new EventHandler(RunCreationClient_Refreshed), sender, e);
    10097      } else {
    10198        PopulateComboBox();
     
    110107        Invoke(new EventHandler(Content_ProblemChanged), sender, e);
    111108      else {
    112         problemComboBox.SelectedItem = OKBClient.Instance.Problems.FirstOrDefault(x => x.Id == Content.ProblemId);
     109        problemComboBox.SelectedItem = RunCreationClient.Instance.Problems.FirstOrDefault(x => x.Id == Content.ProblemId);
    113110        viewHost.Content = Content.Problem;
    114111      }
     
    118115    #region Control Events
    119116    private void refreshButton_Click(object sender, System.EventArgs e) {
    120       OKBClient.Instance.Refresh();
     117      RunCreationClient.Instance.Refresh();
    121118    }
    122119    private void problemComboBox_SelectedValueChanged(object sender, System.EventArgs e) {
     
    125122        Content.Load(problem.Id);
    126123        if (Content.ProblemId != problem.Id)  // reset selected item if load was not successful
    127           problemComboBox.SelectedItem = OKBClient.Instance.Problems.FirstOrDefault(x => x.Id == Content.ProblemId);
     124          problemComboBox.SelectedItem = RunCreationClient.Instance.Problems.FirstOrDefault(x => x.Id == Content.ProblemId);
    128125      }
    129126    }
  • branches/OKB (trunk integration)/HeuristicLab.Services.OKB/3.3/RunCreation/IRunCreationService.cs

    r5478 r5640  
    4444
    4545    [OperationContract]
    46     long AddRun(Run run);
     46    void AddRun(Run run);
    4747  }
    4848}
  • branches/OKB (trunk integration)/HeuristicLab.Services.OKB/3.3/RunCreation/RunCreationService.cs

    r5478 r5640  
    6464    }
    6565
    66     public long AddRun(DataTransfer.Run run) {
     66    public void AddRun(DataTransfer.Run run) {
    6767      using (OKBDataContext okb = new OKBDataContext()) {
    6868        DataAccess.Run entity = Convert.ToEntity(run, okb);
    6969        okb.Runs.InsertOnSubmit(entity);
    7070        okb.SubmitChanges();
    71         return entity.Id;
    7271      }
    7372    }
Note: See TracChangeset for help on using the changeset viewer.