Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/20/12 13:00:30 (12 years ago)
Author:
fschoepp
Message:

#1888:

  • Web project now creates custom html for each type we want to enter / display
  • Added endpointConfigurationName to HiveServiceLocator (because Web Project contains more than one endpoint configuration)
  • Removed logging statement from ConfigurationService to prevent exception during failure of loading ConfigurationSettings
  • ApplicationManager: Changed default implementation to WebApplicationManager (instead of LightWeight) for testing purposes within Web Project
  • WebApplicationManager: The application manager which returns plugin descriptors from the currently loaded assemblies (instead of LightweightAppManager)
  • HiveService: Fixed a transaction bug
  • IControllerService: Created a method to dispatch Scenarios to certain IScenarioManager (in this case HiveScenarioManager)
  • Added more mappable types to ControllerModel
  • PlaceholderControllerService dispatches all Scenarios to the HiveScenarioManager
  • Web project now dispatches the scenario to the controller after pressing "Run Job"
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/OaaS/HeuristicLab.Services.Optimization.Controller/Model/ControllerModel.cs

    r8384 r8506  
    44using System.Text;
    55using System.Runtime.Serialization;
     6using System.Globalization;
     7using System.Xml;
    68
    79namespace HeuristicLab.Services.Optimization.ControllerService.Model {
     
    2527
    2628  [DataContract]
    27   public abstract class Value {   
     29  public abstract class Value {
     30    [DataMember]
     31    public string Name { get; set; }
     32
     33    public abstract bool TrySetFromString(string input);
     34  }
     35
     36
     37  [DataContract]
     38  public class DecimalMatrix : Value {
     39    [DataMember]
     40    public double[][] Value { get; set; }
     41
     42    public override bool TrySetFromString(string input) {
     43      var splitted = input.Split(':');
     44      int i, j;
     45      if (splitted.Length != 3)
     46        return false;
     47
     48      if (!int.TryParse(splitted[0], out i))
     49        return false;
     50
     51      if (!int.TryParse(splitted[1], out j))
     52        return false;
     53
     54      double value;
     55      if (!double.TryParse(splitted[2], out value))
     56        return false;
     57      // very, very buggy
     58      if (i >= Value.Length || j >= Value[0].Length ) {
     59        double[][] valueArr = new double[i >= Value.GetLength(0) ? i : Value.GetLength(0)][];       
     60        for (int k = 0; k < Value.Length; k++) {
     61          valueArr[k] = new double[j >= Value.GetLength(1) ? j : Value.GetLength(1)];
     62          for (int l = 0; l < Value[k].Length; l++) {
     63            valueArr[k][l] = Value[k][l];
     64          }
     65        }
     66        Value = valueArr;
     67      }
     68
     69      Value[i][j] = value;
     70      return true;
     71    }
     72  }
     73
     74  [DataContract]
     75  public class DecimalVector : Value {
     76    [DataMember]
     77    public double[] Value { get; set; }
     78
     79    public override bool TrySetFromString(string input) {
     80      var splitted = input.Split(':');
     81      int index;
     82      if (splitted.Length != 2)
     83        return false;
     84
     85      if (!int.TryParse(splitted[0], out index))
     86        return false;
     87
     88      double value;
     89      if (!double.TryParse(splitted[1], out value))
     90        return false;
     91
     92      if (index >= Value.Length) {
     93        double[] valueArr = new double[index + 1];
     94        Array.Copy(Value, valueArr, Value.Length);
     95        Value = valueArr;
     96      }
     97
     98      Value[index] = value;
     99      return true;
     100    }
     101  }
     102
     103  [DataContract]
     104  public class TypeValue : Value {
     105    [DataMember]
     106    public string Value { get; set; }
     107
     108    [DataMember]
     109    public string[] Options { get; set; }
     110
     111    public override bool TrySetFromString(string input) {
     112      if (Options.Contains(input)) {
     113        Value = input;
     114        return true;
     115      }
     116      return false;
     117    }
    28118  }
    29119
     
    32122    [DataMember]
    33123    public double Value { get; set; }
     124
     125    public override bool TrySetFromString(string input) {
     126      double result;
     127      if (double.TryParse(input, out result)) {
     128        Value = result;
     129        return true;
     130      }
     131      return false;
     132    }
    34133  }
    35134
     
    38137    [DataMember]
    39138    public bool Value { get; set; }
     139
     140    public override bool TrySetFromString(string input) {
     141      bool result;
     142      if (input.Contains(","))
     143        input = input.Split(',')[0].Trim();
     144      if (bool.TryParse(input, out result)) {
     145        Value = result;
     146        return true;
     147      }
     148      return false;
     149    }
    40150  }
    41151
     
    43153  [KnownType(typeof(BoolValue))]
    44154  [KnownType(typeof(DecimalValue))]
    45   public class Parameter {
    46     [DataMember]
    47     public string Name { get; set; }
    48    
     155  [KnownType(typeof(TypeValue))]
     156  [KnownType(typeof(DecimalVector))]
     157  [KnownType(typeof(DecimalMatrix))]
     158  public class Parameter {       
    49159    // some kind of value type
    50160    [DataMember]
     
    52162   
    53163    [DataMember]
    54     public Value Value { get; set; }
    55 
     164    public Value Value { get; set; }   
    56165    /*
    57166    //[DataMember]
     
    60169
    61170  [DataContract]
     171  public class InputParameters {
     172    private IList<Parameter> items = new List<Parameter>();
     173
     174    [DataMember]
     175    public IList<Parameter> Items {
     176      get { return items; }
     177      set { items = value; }
     178    }
     179  }
     180
     181  [DataContract]
     182  public class AlgorithmParameters {
     183    private IList<Parameter> items = new List<Parameter>();
     184
     185    [DataMember]
     186    public IList<Parameter> Items {
     187      get { return items; }
     188      set { items = value; }
     189    }
     190  }
     191
     192  [DataContract]
    62193  public class OptimizationScenario {
    63194    [DataMember]
    64195    public string Name { get; set; }
    65196
    66     private IList<Parameter> inputParameters = new List<Parameter>();
    67 
    68     [DataMember]
    69     public IList<Parameter> InputParameters {
    70       get { return inputParameters; }
    71       set { inputParameters = value; }
    72     }
    73 
    74     private IList<Parameter> algorithmParameters = new List<Parameter>();
    75 
    76     [DataMember]
    77     public IList<Parameter> AlgorithmParameters {
     197    private InputParameters inputParams = new InputParameters();
     198
     199    [DataMember]
     200    public InputParameters InputParameters {
     201      get { return inputParams; }
     202      set { inputParams = value; }
     203    }
     204
     205
     206    private AlgorithmParameters algorithmParameters = new AlgorithmParameters();
     207
     208    [DataMember]
     209    public AlgorithmParameters AlgorithmParameters {
    78210      get { return algorithmParameters; }
    79211      set { algorithmParameters = value; }
    80212    }
     213
    81214  }
    82215}
Note: See TracChangeset for help on using the changeset viewer.