Last change
on this file since 14777 was
9350,
checked in by fschoepp, 12 years ago
|
#1888:
- Added input parameters to the run class. They will be populated by the back-end and returned to the web pages which renders them.
- Added a ParameterMapper class which converts HL specific model classes to OaaS independent classes. The conversion gets delegated to IParameterHandler which have to be implemented manually and registered for a certain Type before. All parameters which can be converted to IStringConvertible, IStringConvertibleMatrix, IString* will be converted into a OaaS-StringValue instance.
- Added IParameterHandlers for PathTSPTour and PermutationType (required for TSP).
- AlgorithmConverter now makes sure that the id of a run is unique. (All runs of a RunList will be shown now.)
- Web pages are capable of rendering both the results of a run and their input parameters (added a accordion to wrap their content).
- Renamed "Traveling Salesman Problem" to "Genetic Algorithm - TSP".
- Changed js-files to render both input and result parameters of a Run.
|
File size:
1.5 KB
|
Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using HeuristicLab.Services.Optimization.ControllerService.Model;
|
---|
6 |
|
---|
7 | namespace HeuristicLab.Services.Optimization.ControllerService.Parameters {
|
---|
8 | public interface IParameterHandler<I> {
|
---|
9 | Type HandledType { get; }
|
---|
10 | Parameter Map(I item);
|
---|
11 | };
|
---|
12 |
|
---|
13 | public class ParameterMappingException : Exception {
|
---|
14 | public ParameterMappingException(string message) : base(message) {
|
---|
15 | }
|
---|
16 | }
|
---|
17 |
|
---|
18 | public class ParameterMapper<I> {
|
---|
19 | Dictionary<Type, IParameterHandler<I>> handlers = new Dictionary<Type,IParameterHandler<I>>();
|
---|
20 |
|
---|
21 | public ParameterMapper() {
|
---|
22 | }
|
---|
23 |
|
---|
24 | public void Register(IParameterHandler<I> handler) {
|
---|
25 | handlers[handler.HandledType] = handler;
|
---|
26 | }
|
---|
27 |
|
---|
28 | public bool IsHandlerAvailable(I element) {
|
---|
29 | return handlers.ContainsKey(element.GetType());
|
---|
30 | }
|
---|
31 |
|
---|
32 | public Parameter Map(string name, I element) {
|
---|
33 | if (element == null)
|
---|
34 | throw new ArgumentNullException("Element parameter may not be null");
|
---|
35 | IParameterHandler<I> handler;
|
---|
36 | if (handlers.TryGetValue(element.GetType(), out handler)) {
|
---|
37 | var param = handler.Map(element);
|
---|
38 | if (param == null)
|
---|
39 | throw new ParameterMappingException("Handler '" + handler.GetType().FullName + "' returned null parameter for type " + element.GetType().FullName);
|
---|
40 | param.Value.Name = name;
|
---|
41 | return param;
|
---|
42 | }
|
---|
43 | throw new ParameterMappingException("No handler for type " + element.GetType().FullName);
|
---|
44 | }
|
---|
45 | }
|
---|
46 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.