Last change
on this file since 17540 was
17540,
checked in by dpiringe, 4 years ago
|
#3026:
- added new converter: BatchRunConverter, ExperimentConverter
- fixed a bug with the path of the .hl file in JCGenerator
- fixed a bug with a redundant search for a suitable converter in JsonItemConverter
- added a restriction for TargetVariable and AllowedInputVariables in RegressionProblemDataConverter
- removed unnecessary code in Runner
|
File size:
1.6 KB
|
Rev | Line | |
---|
[17540] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Linq;
|
---|
| 4 | using System.Text;
|
---|
| 5 | using System.Threading.Tasks;
|
---|
| 6 | using HeuristicLab.Core;
|
---|
| 7 |
|
---|
| 8 | namespace HeuristicLab.JsonInterface {
|
---|
| 9 | public class BatchRunConverter : BaseConverter {
|
---|
| 10 | public override int Priority => 10;
|
---|
| 11 | public override Type ConvertableType => HEAL.Attic.Mapper.StaticCache.GetType(new Guid("E85407E0-18EC-4198-8321-9CF030FDF6D7"));
|
---|
| 12 |
|
---|
| 13 | public override IJsonItem Extract(IItem value, IJsonItemConverter root) {
|
---|
| 14 | dynamic batchRun = (dynamic)value;
|
---|
| 15 | EmptyJsonItem batchRunJI = new EmptyJsonItem() {
|
---|
| 16 | Name = batchRun.Name,
|
---|
| 17 | Description = value.ItemDescription
|
---|
| 18 | };
|
---|
| 19 |
|
---|
| 20 | var optimizerJI = root.Extract((IItem)batchRun.Optimizer, root);
|
---|
| 21 | if(!(optimizerJI is UnsupportedJsonItem)) {
|
---|
| 22 | batchRunJI.AddChildren(optimizerJI);
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | int reps = (int)batchRun.Repetitions;
|
---|
| 26 | batchRunJI.AddChildren(new IntJsonItem() {
|
---|
| 27 | Name = "Repetitions",
|
---|
| 28 | Description = "The repetitions for this batch run.",
|
---|
| 29 | Value = reps,
|
---|
| 30 | Minimum = 0,
|
---|
| 31 | Maximum = int.MaxValue
|
---|
| 32 | });
|
---|
| 33 |
|
---|
| 34 | return batchRunJI;
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | public override void Inject(IItem item, IJsonItem data, IJsonItemConverter root) {
|
---|
| 38 | dynamic batchRun = (dynamic)item;
|
---|
| 39 | if(data.Children != null) {
|
---|
| 40 | foreach(var i in data.Children) {
|
---|
| 41 | if(i.Path.EndsWith("Repetitions") && i is IntJsonItem reps ) {
|
---|
| 42 | batchRun.Repetitions = reps.Value;
|
---|
| 43 | } else {
|
---|
| 44 | root.Inject((IItem)batchRun.Optimizer, i, root);
|
---|
| 45 | }
|
---|
| 46 | }
|
---|
| 47 | }
|
---|
| 48 | }
|
---|
| 49 | }
|
---|
| 50 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.