Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/15/13 15:50:53 (12 years ago)
Author:
fschoepp
Message:

#1888:

  • Model: OptimizationScenario may be a tree of algorithms (and problems)
  • Model: Renamed InputParameters to ProblemParameters (as they are the parameters of a problem)
  • Model: Added JobExecutionDetails which contain Repetitions + Group (resource to use)
  • ScenarioParser parses the new XML scenario files
  • Website + Model: You are now able to add/remove rows from a table (no JavaScript involved yet)
  • Website + Controller: Added repetitions (enables batch jobs) and group (resource to use) to OaaS which will be used by the controller to schedule the job
  • Website: Updated templates to use new model structure
  • Website + Scenarios: Added the new algorithm Benchmark Algorithm
  • Controller: Added a singleton to make the (Azure/Mockup)-DAL exchangeable
  • Controller: Added mockup classes for DAL + IScenarioManager
  • Website/Result Page: Line Diagrams will be added via JavaScript, crawling their data using AJAX
  • Website: Most configuration parameters can be set in the ServiceDefinition directly
  • Added a mockup for the Membership classes: These can be used if no network connection is available or if other parts of the app shall be tested
  • Scenarios: Updated TSP mappings to new xsd
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/OaaS/HeuristicLab.Services.Optimization.Web/Mappings/tsp.cs

    r8958 r9166  
    44using System.Text;
    55using HeuristicLab.Data;
    6 using HeuristicLab.Services.Optimization.ControllerService.Model; 
     6using HeuristicLab.Services.Optimization.ControllerService.Model;
    77using HeuristicLab.Optimization;
    88using HeuristicLab.Services.Optimization.ControllerService;
    99using HeuristicLab.Algorithms.GeneticAlgorithm;
    1010using HeuristicLab.Problems.TravelingSalesman;
    11 public class TSPScenarioMapper : IScenarioMapper {
    12   public void MapScenario(OptimizationScenario scenario, IAlgorithm algorithm) {
    13     Console.WriteLine("Mapping scenario!");
    14     var ga = algorithm as GeneticAlgorithm;
    15     var problem = algorithm.Problem as TravelingSalesmanProblem;
    16                  
    17     problem.BestKnownQuality = HLMapper.ConvertToDoubleValue(scenario.InputParameters.FindByName("BestKnownQuality"));
    18     problem.BestKnownSolution = HLMapper.ConvertToPermutation(scenario.InputParameters.FindByName("BestKnownSolution"));
    19     problem.Coordinates = HLMapper.ConvertToDoubleMatrix(scenario.InputParameters.FindByName("Coordinates"));
    20     var evalParam = HLMapper.GetStringValue(scenario.InputParameters.FindByName("EvaluatorParameter"));
    21     if (evalParam == "HeuristicLab.Problems.TravelingSalesman.TSPRoundedEuclideanPathEvaluator") {
    22       problem.EvaluatorParameter.Value = new TSPRoundedEuclideanPathEvaluator();
     11namespace HeuristicLab.Mappers {
     12  public class TSPScenarioMapper : IScenarioMapper {
     13    public void MapScenario(OptimizationScenario scenario, out IAlgorithm algorithm) {
     14      Console.WriteLine("Mapping scenario!");
     15      var ga = new GeneticAlgorithm();
     16      var problem = new TravelingSalesmanProblem();
     17      ga.Problem = problem;
     18      algorithm = ga;
     19
     20      problem.BestKnownQuality = HLMapper.ConvertToDoubleValue(scenario.FirstAlgorithm.Problem.Parameters.FindByName("BestKnownQuality"));
     21      problem.BestKnownSolution = HLMapper.ConvertToPermutation(scenario.FirstAlgorithm.Problem.Parameters.FindByName("BestKnownSolution"));
     22      problem.Coordinates = HLMapper.ConvertToDoubleMatrix(scenario.FirstAlgorithm.Problem.Parameters.FindByName("Coordinates"));
     23      var evalParam = HLMapper.GetStringValue(scenario.FirstAlgorithm.Problem.Parameters.FindByName("EvaluatorParameter"));
     24      if (evalParam == "HeuristicLab.Problems.TravelingSalesman.TSPRoundedEuclideanPathEvaluator") {
     25        problem.EvaluatorParameter.Value = new TSPRoundedEuclideanPathEvaluator();
     26      }
     27      else if (evalParam == "HeuristicLab.Problems.TravelingSalesman.TSPGeoPathEvaluator") {
     28        problem.EvaluatorParameter.Value = new TSPGeoPathEvaluator();
     29      }
     30      else {
     31        problem.EvaluatorParameter.Value = new TSPEuclideanPathEvaluator();
     32      }
     33      problem.UseDistanceMatrix = HLMapper.ConvertToBoolValue(scenario.FirstAlgorithm.Problem.Parameters.FindByName("UseDistanceMatrix"));
     34      Console.WriteLine("Mapping algorithm...");
     35      ga.Mutator = HLMapper.FindInItemSet<HeuristicLab.Optimization.IManipulator>(ga.MutatorParameter.ValidValues, scenario.FirstAlgorithm.Parameters.FindByName("Mutator"));
     36      ga.CrossoverParameter.Value = HLMapper.FindOperator<HeuristicLab.Optimization.ICrossover>(problem, scenario.FirstAlgorithm.Parameters.FindByName("CrossoverParameter"));
     37      ga.Elites = HLMapper.ConvertToIntValue(scenario.FirstAlgorithm.Parameters.FindByName("Elites"));
     38      ga.MaximumGenerations = HLMapper.ConvertToIntValue(scenario.FirstAlgorithm.Parameters.FindByName("MaximumGenerations"));
     39      ga.MutationProbability = HLMapper.ConvertToPercentValue(scenario.FirstAlgorithm.Parameters.FindByName("MutationProbability"));
     40      ga.PopulationSize = HLMapper.ConvertToIntValue(scenario.FirstAlgorithm.Parameters.FindByName("PopulationSize"));
     41      ga.Seed = HLMapper.ConvertToIntValue(scenario.FirstAlgorithm.Parameters.FindByName("Seed"));
     42      ga.Selector = HLMapper.FindInItemSet<HeuristicLab.Optimization.ISelector>(ga.SelectorParameter.ValidValues, scenario.FirstAlgorithm.Parameters.FindByName("Selector"));
     43      ga.SetSeedRandomly = HLMapper.ConvertToBoolValue(scenario.FirstAlgorithm.Parameters.FindByName("SetSeedRandomly"));
    2344    }
    24     else if (evalParam == "HeuristicLab.Problems.TravelingSalesman.TSPGeoPathEvaluator") {
    25       problem.EvaluatorParameter.Value = new TSPGeoPathEvaluator();
    26     }
    27     else {
    28       problem.EvaluatorParameter.Value = new TSPEuclideanPathEvaluator();
    29     }
    30     problem.UseDistanceMatrix = HLMapper.ConvertToBoolValue(scenario.InputParameters.FindByName("UseDistanceMatrix"));
    31     Console.WriteLine("Mapping algorithm...");
    32     ga.Mutator = HLMapper.FindInItemSet<HeuristicLab.Optimization.IManipulator>(ga.MutatorParameter.ValidValues, scenario.AlgorithmParameters.FindByName("Mutator"));
    33     ga.CrossoverParameter.Value = HLMapper.FindOperator<HeuristicLab.Optimization.ICrossover>(problem, scenario.AlgorithmParameters.FindByName("CrossoverParameter"));
    34     ga.Elites = HLMapper.ConvertToIntValue(scenario.AlgorithmParameters.FindByName("Elites"));
    35     ga.MaximumGenerations = HLMapper.ConvertToIntValue(scenario.AlgorithmParameters.FindByName("MaximumGenerations"));
    36     ga.MutationProbability = HLMapper.ConvertToPercentValue(scenario.AlgorithmParameters.FindByName("MutationProbability"));               
    37     ga.PopulationSize = HLMapper.ConvertToIntValue(scenario.AlgorithmParameters.FindByName("PopulationSize"));
    38     ga.Seed = HLMapper.ConvertToIntValue(scenario.AlgorithmParameters.FindByName("Seed"));
    39     ga.Selector = HLMapper.FindInItemSet<HeuristicLab.Optimization.ISelector>(ga.SelectorParameter.ValidValues, scenario.AlgorithmParameters.FindByName("Selector"));
    40     ga.SetSeedRandomly = HLMapper.ConvertToBoolValue(scenario.AlgorithmParameters.FindByName("SetSeedRandomly"));
    4145  }
    4246}
Note: See TracChangeset for help on using the changeset viewer.