1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2012 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 System;
|
---|
23 | using System.Collections.Generic;
|
---|
24 | using System.Linq;
|
---|
25 | using System.Text;
|
---|
26 | using HeuristicLab.Optimization;
|
---|
27 | using HeuristicLab.Problems.BinPacking.Interfaces;
|
---|
28 | using HeuristicLab.Problems.BinPacking.Shapes;
|
---|
29 | using HeuristicLab.Core;
|
---|
30 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
31 | using HeuristicLab.Common;
|
---|
32 | using HeuristicLab.Parameters;
|
---|
33 | using HeuristicLab.Problems.BinPacking.PackingPlans;
|
---|
34 | using HeuristicLab.Problems.BinPacking.Evaluators;
|
---|
35 | using HeuristicLab.Problems.BinPacking.Analyzers;
|
---|
36 | using HeuristicLab.Encodings.PermutationEncoding;
|
---|
37 | using HeuristicLab.PluginInfrastructure;
|
---|
38 | using HeuristicLab.Data;
|
---|
39 |
|
---|
40 | namespace HeuristicLab.Problems.BinPacking.Problem {
|
---|
41 | [Item("BinPackingProblem", "Abstract class that represents a BinPacking Problem")]
|
---|
42 | [StorableClass]
|
---|
43 | public abstract class BinPackingProblem<D, B, I> : SingleObjectiveHeuristicOptimizationProblem<IPackingPlanEvaluationAlgorithm, IPackingSolutionCreator>
|
---|
44 | where D : class, IPackingDimensions
|
---|
45 | where B : PackingShape<D>, IPackingBin, new()
|
---|
46 | where I : PackingShape<D>, IPackingItem, new () {
|
---|
47 |
|
---|
48 |
|
---|
49 | #region Parameter Properties
|
---|
50 | public OptionalValueParameter<PackingPlan<D,B,I>> BestKnownSolutionParameter {
|
---|
51 | get { return (OptionalValueParameter<PackingPlan<D, B, I>>)Parameters["BestKnownSolution"]; }
|
---|
52 | }
|
---|
53 | public ValueParameter<ItemList<I>> PackingItemMeasuresParameter {
|
---|
54 | get { return (ValueParameter<ItemList<I>>)Parameters["PackingItemMeasures"]; }
|
---|
55 | }
|
---|
56 | public IFixedValueParameter<IntValue> PackingItemsParameter {
|
---|
57 | get { return (IFixedValueParameter<IntValue>)Parameters["PackingItems"]; }
|
---|
58 | }
|
---|
59 | public IFixedValueParameter<IntValue> LowerBoundParameter {
|
---|
60 | get { return (IFixedValueParameter<IntValue>)Parameters["LowerBound"]; }
|
---|
61 | }
|
---|
62 | public ValueParameter<IPackingPlanEvaluator> PackingPlanEvaluatorParameter {
|
---|
63 | get { return (ValueParameter<IPackingPlanEvaluator>)Parameters["PackingPlanEvaluator"]; }
|
---|
64 | }
|
---|
65 | #endregion
|
---|
66 |
|
---|
67 | #region Properties
|
---|
68 | public PackingPlan<D, B, I> BestKnownSolution {
|
---|
69 | get { return BestKnownSolutionParameter.Value; }
|
---|
70 | set { BestKnownSolutionParameter.Value = value; }
|
---|
71 | }
|
---|
72 | public ItemList<I> PackingItemMeasures {
|
---|
73 | get { return PackingItemMeasuresParameter.Value; }
|
---|
74 | set { PackingItemMeasuresParameter.Value = value; }
|
---|
75 | }
|
---|
76 | public IPackingPlanEvaluator PackingPlanEvaluator {
|
---|
77 | get { return PackingPlanEvaluatorParameter.Value; }
|
---|
78 | set { PackingPlanEvaluatorParameter.Value = value; }
|
---|
79 | }
|
---|
80 | #endregion
|
---|
81 |
|
---|
82 |
|
---|
83 | [StorableConstructor]
|
---|
84 | protected BinPackingProblem(bool deserializing) : base(deserializing) { }
|
---|
85 | protected BinPackingProblem(BinPackingProblem<D,B,I> original, Cloner cloner)
|
---|
86 | : base(original, cloner) {
|
---|
87 | }
|
---|
88 | protected BinPackingProblem(IPackingPlanEvaluationAlgorithm e, IPackingSolutionCreator c) : base (e, c){
|
---|
89 | Parameters.Add(new OptionalValueParameter<PackingPlan<D, B, I>>("BestKnownSolution", "The best known solution of this bin-packing instance."));
|
---|
90 | Parameters.Add(new ValueParameter<ItemList<I>>("PackingItemMeasures", "Packing-item data defining the measures of the different items that need to be packed.", new ItemList<I>()));
|
---|
91 |
|
---|
92 | Parameters.Add(new FixedValueParameter<IntValue>("PackingItems", "The number of packing-items used in this bin packing instance.", new IntValue()));
|
---|
93 | Parameters.Add(new FixedValueParameter<IntValue>("LowerBound", "The lower possible number of bins needed to solve this problem (taken from Dell'Amico, Martello and Vigo; 2002)", new IntValue()));
|
---|
94 | }
|
---|
95 |
|
---|
96 |
|
---|
97 |
|
---|
98 |
|
---|
99 | #region Helpers
|
---|
100 | protected abstract void InitializeDecoder();
|
---|
101 | protected abstract void InitializeProblemInstance();
|
---|
102 | protected abstract void InitializeOperators();
|
---|
103 | protected abstract void InitializeEventHandlers();
|
---|
104 | #endregion
|
---|
105 | }
|
---|
106 | }
|
---|