1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
4 | *
|
---|
5 | * This file is part of HeuristicLab.
|
---|
6 | *
|
---|
7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
8 | * it under the terms of the GNU General Public License as published by
|
---|
9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
10 | * (at your option) any later version.
|
---|
11 | *
|
---|
12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
15 | * GNU General Public License for more details.
|
---|
16 | *
|
---|
17 | * You should have received a copy of the GNU General Public License
|
---|
18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
19 | */
|
---|
20 | #endregion
|
---|
21 |
|
---|
22 | using HeuristicLab.BioBoost.Analysis;
|
---|
23 | using HeuristicLab.BioBoost.Evaluators;
|
---|
24 | using HeuristicLab.BioBoost.Operators.Crossover;
|
---|
25 | using HeuristicLab.BioBoost.Operators.Mutation;
|
---|
26 | using HeuristicLab.BioBoost.ProblemDescription;
|
---|
27 | using HeuristicLab.BioBoost.SolutionCreation;
|
---|
28 | using HeuristicLab.Common;
|
---|
29 | using HeuristicLab.Core;
|
---|
30 | using HeuristicLab.Data;
|
---|
31 | using HeuristicLab.Optimization;
|
---|
32 | using HeuristicLab.Parameters;
|
---|
33 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
34 | using System;
|
---|
35 |
|
---|
36 | namespace HeuristicLab.BioBoost {
|
---|
37 |
|
---|
38 | [Item("Multiobjective BioBoost Problem", "EU-wide aggregate biomass logistics simulation (multiobjective).")]
|
---|
39 | [Creatable("Problems")]
|
---|
40 | [StorableClass]
|
---|
41 | public class MultiobjectiveBioBoostProblem : MultiObjectiveHeuristicOptimizationProblem<AggregateEvaluator, BioBoostSolutionCreator>, IStorableContent {
|
---|
42 |
|
---|
43 | #region IStorableContent Members
|
---|
44 | public string Filename { get; set; }
|
---|
45 | #endregion
|
---|
46 |
|
---|
47 | #region Parameters
|
---|
48 | public ValueParameter<BioBoostProblemData> ProblemDataParameter {
|
---|
49 | get { return (ValueParameter<BioBoostProblemData>) Parameters["ProblemData"]; }
|
---|
50 | }
|
---|
51 | public ValueParameter<IntMatrix> RegionBoundsParameter {
|
---|
52 | get { return (ValueParameter<IntMatrix>) Parameters["RegionBounds"]; }
|
---|
53 | }
|
---|
54 | public ValueParameter<IntValue> NRegionsParameter {
|
---|
55 | get { return (ValueParameter<IntValue>) Parameters["NRegions"]; }
|
---|
56 | }
|
---|
57 | public ValueParameter<BoolValue> RemoveIntermediateResultsParameter {
|
---|
58 | get { return (ValueParameter<BoolValue>) Parameters["RemoveIntermediateResults"]; }
|
---|
59 | }
|
---|
60 | #endregion
|
---|
61 |
|
---|
62 | #region Parameter Values
|
---|
63 | public BioBoostProblemData ProblemData {
|
---|
64 | get { return ProblemDataParameter.Value; }
|
---|
65 | }
|
---|
66 | public IntMatrix RegionBounds {
|
---|
67 | get { return RegionBoundsParameter.Value; }
|
---|
68 | set { RegionBoundsParameter.Value = value; }
|
---|
69 | }
|
---|
70 | public int NRegions {
|
---|
71 | get { return NRegionsParameter.Value.Value; }
|
---|
72 | set { NRegionsParameter.Value = new IntValue(value); }
|
---|
73 | }
|
---|
74 | public bool RemoveIntermediateResults {
|
---|
75 | get { return RemoveIntermediateResultsParameter.Value.Value; }
|
---|
76 | }
|
---|
77 | #endregion
|
---|
78 |
|
---|
79 | #region Construction & Cloning
|
---|
80 | [StorableConstructor]
|
---|
81 | protected MultiobjectiveBioBoostProblem(bool isDeserializing) : base(isDeserializing) {}
|
---|
82 | protected MultiobjectiveBioBoostProblem(MultiobjectiveBioBoostProblem orig, Cloner cloner) : base(orig, cloner) {
|
---|
83 | RegisterEvents();
|
---|
84 | }
|
---|
85 | public MultiobjectiveBioBoostProblem() {
|
---|
86 | Parameters.Add(new ValueParameter<BioBoostProblemData>("ProblemData", "Encapsulation of all data describing the problem instance."));
|
---|
87 | Parameters.Add(new ValueParameter<IntMatrix>("RegionBounds", "Bounds for valid region ids.", new IntMatrix(new int[,]{{0, 0}})));
|
---|
88 | Parameters.Add(new ValueParameter<IntValue>("NRegions", "Number of regions.", new IntValue(0)));
|
---|
89 | Parameters.Add(new ValueParameter<BoolValue>("RemoveIntermediateResults", "Whether to remove intermediate results created during evaluation.", new BoolValue(true)));
|
---|
90 | Maximization = new BoolArray(new [] {true, true});
|
---|
91 | RegionBoundsParameter.Hidden = true;
|
---|
92 | RegisterEvents();
|
---|
93 | Operators.Add(new CompoundCrossover());
|
---|
94 | Operators.Add(new MultiCrossover());
|
---|
95 | Operators.Add(new PlantBasedCrossover());
|
---|
96 | Operators.Add(new BoundaryToggleRealVectorMutator());
|
---|
97 | Operators.Add(new CompoundMutator());
|
---|
98 | Operators.Add(new EmptyMutator());
|
---|
99 | Operators.Add(new MultiMutator());
|
---|
100 | Operators.Add(new PlantKiller());
|
---|
101 | Operators.Add(new PlantMerger());
|
---|
102 | Operators.Add(new PlantMover());
|
---|
103 | Operators.Add(new PlantScalingMutator());
|
---|
104 | Operators.Add(new PlantSupplierEqualizer());
|
---|
105 | Operators.Add(new PlantSupplierRandomizer());
|
---|
106 | Operators.Add(new PlantSupplierToggler());
|
---|
107 | Operators.Add(new PlantSupplierUtilizationExchanger());
|
---|
108 | Operators.Add(new MultiObjectiveBioBoostSolutionAnalyzer());
|
---|
109 | }
|
---|
110 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
111 | return new MultiobjectiveBioBoostProblem(this, cloner);
|
---|
112 | }
|
---|
113 | [StorableHook(HookType.AfterDeserialization)]
|
---|
114 | private void AfterDeserialization() {
|
---|
115 | RegisterEvents();
|
---|
116 | }
|
---|
117 | #endregion
|
---|
118 |
|
---|
119 | #region events
|
---|
120 | private void RegisterEvents() {
|
---|
121 | NRegionsParameter.ToStringChanged += new EventHandler(NRegionsParameterChanged);
|
---|
122 | ProblemDataParameter.ValueChanged += UpdateEventRegistration;
|
---|
123 | UpdateEventRegistration(this, EventArgs.Empty);
|
---|
124 | }
|
---|
125 |
|
---|
126 | private BioBoostProblemData registeredProblemData = null;
|
---|
127 |
|
---|
128 | private void UpdateEventRegistration(object sender, EventArgs eventArgs) {
|
---|
129 | if (registeredProblemData == ProblemData) return;
|
---|
130 | if (registeredProblemData != null) {
|
---|
131 | registeredProblemData.LocationNamesParameter.ToStringChanged -= LocationNamesChanged;
|
---|
132 | }
|
---|
133 | ProblemData.LocationNamesParameter.ToStringChanged += LocationNamesChanged;
|
---|
134 | registeredProblemData = ProblemData;
|
---|
135 | }
|
---|
136 |
|
---|
137 | private void LocationNamesChanged(object sender, EventArgs e) {
|
---|
138 | NRegions = ProblemData.LocationNames.Length;
|
---|
139 | }
|
---|
140 |
|
---|
141 | private void NRegionsParameterChanged(object sender, EventArgs e) {
|
---|
142 | RegionBounds = new IntMatrix(new int[,] {{0, NRegions}});
|
---|
143 | }
|
---|
144 | #endregion
|
---|
145 | }
|
---|
146 | }
|
---|