Free cookie consent management tool by TermsFeed Policy Generator

Changeset 14040


Ignore:
Timestamp:
07/12/16 17:51:37 (8 years ago)
Author:
gkronber
Message:

#1966:

  • removed separation of general bin packing problems and 'regular' (=rectangular or cuboid) bin packing problems (=> all our bin packing problems are regular)
  • removed ISOContainer BinPacking problem (seems to be just a minor variant for generic 3d bin packing)
Location:
branches/HeuristicLab.BinPacking
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/BinPacking2D.cs

    r14038 r14040  
    6666        ExtremePoints.Add(new TwoDimensionalPacking(0, sourcePointX.X, sourcePointX.Y));
    6767      }
    68 
    69 
    70 
    7168
    7269      //Find ExtremePoints beginning from sourcepointY
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.2D/3.3/RectangularIdenticalBinPackingProblem.cs

    r14039 r14040  
    4141  [StorableClass]
    4242  [Creatable(CreatableAttribute.Categories.CombinatorialProblems, Priority = 300)]
    43   public class RectangularIdenticalBinPackingProblem : RegularIdenticalBinPackingProblem<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem> {
     43  // TODO: only support 2d BPPData
     44  public class RectangularIdenticalBinPackingProblem : BinPackingProblem<TwoDimensionalPacking, RectangularPackingBin, RectangularPackingItem>, IProblemInstanceConsumer<BPPData>, IProblemInstanceExporter<BPPData> {
    4445
    4546    #region Default Instance
     
    104105
    105106    #region Problem instance handling
    106     public override void Load(BPPData data) {
     107    public void Load(BPPData data) {
    107108      var realData = data as RealBPPData;
    108109      var binData = new RectangularPackingBin(data.BinMeasures[0], data.BinMeasures[1]);
     
    131132
    132133
    133     public override BPPData Export() {
     134    public BPPData Export() {
    134135      var result = new BPPData {
    135136        Name = Name,
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/CuboidIdenticalBinPackingProblem.cs

    r14039 r14040  
    4141  [StorableClass]
    4242  [Creatable(CreatableAttribute.Categories.CombinatorialProblems, Priority = 310)]
    43   public class CuboidIdenticalBinPackingProblem : RegularIdenticalBinPackingProblem<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem> {
     43  // TODO don't support generic BPPData but only 3d BPPData
     44  public class CuboidIdenticalBinPackingProblem : BinPackingProblem<ThreeDimensionalPacking, CuboidPackingBin, CuboidPackingItem>, IProblemInstanceConsumer<BPPData>, IProblemInstanceExporter<BPPData> {
     45
    4446
    4547    #region Default Instance
     
    109111
    110112
    111     public override void Load(BPPData data) {
     113    public void Load(BPPData data) {
    112114      var realData = data as RealBPPData;
    113115      var binData = new CuboidPackingBin(data.BinMeasures[0], data.BinMeasures[1], data.BinMeasures[2]);
     
    135137    }
    136138
    137     public override BPPData Export() {
     139    public BPPData Export() {
    138140      var result = new BPPData {
    139141        Name = Name,
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking.3D/3.3/HeuristicLab.Problems.BinPacking3D-3.3.csproj

    r13611 r14040  
    172172    <Compile Include="Decoders\EP\ExtremePointMultiComponentVectorDecoder3D.cs" />
    173173    <Compile Include="Decoders\EP\ExtremePointPackingSequenceDecoder3D.cs" />
    174     <Compile Include="Decoders\EP\ISOContainerMultiComponentVectorDecoder3D.cs" />
    175174    <Compile Include="I3DOperator.cs" />
    176     <Compile Include="ISOContainerBinPackingProblem.cs" />
    177175    <Compile Include="MoveEvaluators\PackingMoveEvaluator3DGV.cs" />
    178176    <Compile Include="MoveEvaluators\PackingMoveEvaluator3DMCV.cs" />
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/BinPackingProblem.cs

    r13608 r14040  
    2929using HeuristicLab.Encodings.PackingEncoding.PackingPlan;
    3030using HeuristicLab.Data;
     31using HeuristicLab.Encodings.PackingEncoding.MultiComponentVector;
     32using HeuristicLab.Problems.BinPacking.Decoders;
     33using HeuristicLab.PluginInfrastructure;
     34using System.Linq;
     35using HeuristicLab.Problems.BinPacking.Analyzers;
     36using System;
     37using HeuristicLab.Encodings.PackingEncoding.PackingSequence;
     38using HeuristicLab.Encodings.PackingEncoding.GroupingVector;
    3139
    3240namespace HeuristicLab.Problems.BinPacking.Problem {
     
    3543  public abstract class BinPackingProblem<D, B, I> : SingleObjectiveHeuristicOptimizationProblem<IPackingPlanEvaluationAlgorithm, IPackingSolutionCreator>
    3644    where D : class, IPackingDimensions
    37     where B : PackingShape<D>, IPackingBin, new()
    38     where I : PackingShape<D>, IPackingItem, new () {
     45    where B : PackingShape<D>, IPackingBin, IRegularPackingShape, new()
     46    where I : PackingShape<D>, IPackingItem, IRegularPackingShape, new () {
    3947
    4048
     
    5462    public ValueParameter<IPackingPlanEvaluator> PackingPlanEvaluatorParameter {
    5563      get { return (ValueParameter<IPackingPlanEvaluator>)Parameters["PackingPlanEvaluator"]; }
     64    }
     65    public IValueParameter<B> PackingBinMeasuresParameter {
     66      get { return (IValueParameter<B>)Parameters["PackingBinMeasures"]; }
     67    }
     68    public IConstrainedValueParameter<IPackingSolutionDecoder> PackingSolutionDecoderParameter {
     69      get { return (IConstrainedValueParameter<IPackingSolutionDecoder>)Parameters["PackingSolutionDecoder"]; }
    5670    }
    5771    #endregion
     
    7084      set { PackingPlanEvaluatorParameter.Value = value; }
    7185    }
     86    public B PackingBinMeasures {
     87      get { return PackingBinMeasuresParameter.Value; }
     88      set { PackingBinMeasuresParameter.Value = value; }
     89    }
     90    public PackingSolutionDecoder<D, B, I> PackingSolutionDecoder {
     91      get { return PackingSolutionDecoderParameter.Value as PackingSolutionDecoder<D, B, I>; }
     92      set { PackingSolutionDecoderParameter.Value = value; }
     93    }
    7294    #endregion
    7395
     
    7799    protected BinPackingProblem(BinPackingProblem<D,B,I> original, Cloner cloner)
    78100      : base(original, cloner) {
    79     }                 
     101      InitializeEventHandlers();
     102    }
     103
     104    protected BinPackingProblem(IPackingPlanEvaluationAlgorithm e) : this(e, new MultiComponentVectorRandomCreator()) { }
     105
    80106    protected BinPackingProblem(IPackingPlanEvaluationAlgorithm e, IPackingSolutionCreator c) : base (e, c){
    81107      Parameters.Add(new OptionalValueParameter<PackingPlan<D, B, I>>("BestKnownSolution", "The best known solution of this bin-packing instance."));
     
    84110      Parameters.Add(new FixedValueParameter<IntValue>("PackingItems", "The number of packing-items used in this bin packing instance.", new IntValue()));
    85111      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()));
    86     }
    87 
    88     protected abstract void InitializeDecoder();
    89     protected abstract void InitializeProblemInstance();
    90     protected abstract void InitializeOperators();
    91     protected abstract void InitializeEventHandlers();
     112      Parameters.Add(new ValueParameter<B>("PackingBinMeasures", "Packing-bin data defining the measures of the used bins.", new B()));
     113      Parameters.Add(new ValueParameter<IPackingPlanEvaluator>("PackingPlanEvaluator", "The evaluator is used to determine the quality of a solution.", CreateDefaultEvaluator()));
     114      Parameters.Add(new ConstrainedValueParameter<IPackingSolutionDecoder>("PackingSolutionDecoder", "The operator that decodes the representation and creates a packing plan."));
     115      this.Maximization.Value = true;
     116      InitializeProblemInstance();
     117      InitializeOperators();
     118      InitializeEventHandlers();
     119    }
     120
     121    protected abstract void InitializeDecoder();
     122    protected virtual void InitializeProblemInstance() {
     123      InitializeProblemData();
     124      ApplyHorizontalOrientation();
     125      SortItems();
     126      RemoveTooBigItems();
     127      PackingItemsParameter.Value.Value = PackingItemMeasures.Count;
     128      LowerBoundParameter.Value.Value = CalculateLowerBound();
     129    }
     130    protected virtual void InitializeOperators() {
     131      Operators.Clear();
     132      Operators.Add(new BestBinPackingSolutionAnalyzer<D, B, I>());
     133
     134      ApplyEncoding();
     135      ParameterizeOperators();
     136    }
     137    protected virtual void InitializeEventHandlers() {
     138      PackingPlanEvaluatorParameter.ValueChanged += PackingPlanEvaluatorParameter_ValueChanged;
     139      PackingPlanEvaluator.QualityParameter.ActualNameChanged += PackingPlanEvaluator_QualityParameter_ActualNameChanged;
     140      SolutionCreatorParameter.ValueChanged += SolutionCreatorParameter_ValueChanged;
     141      SolutionCreator.EncodedSolutionParameter.ActualNameChanged += SolutionCreator_EncodedSolutionParameter_ActualNameChanged;
     142      PackingSolutionDecoderParameter.ValueChanged += PackingSolutionDecoderParameter_ValueChanged;
     143      if (PackingSolutionDecoder != null) PackingSolutionDecoder.PackingPlanParameter.ActualNameChanged += PackingSolutionDecoder_PackingPlanParameter_ActualNameChanged;
     144    }
     145
     146
     147    protected abstract void RemoveTooBigItems();
     148    protected abstract void InitializeProblemData();
     149    protected abstract IPackingPlanEvaluator CreateDefaultEvaluator();
     150    protected void ApplyHorizontalOrientation() {
     151      PackingBinMeasures.ApplyHorizontalOrientation();
     152      foreach (IRegularPackingShape shape in PackingItemMeasures) {
     153        shape.ApplyHorizontalOrientation();
     154      }
     155    }
     156    protected void SortItems() {
     157      PackingItemMeasures.Sort((x, y) => y.CompareTo(x));
     158    }
     159    protected int CalculateLowerBound() {
     160      //This is the obvious continuous lower bound calculation; Martello and Vigo proposed a better way but it has not been implemented yet;
     161      int items = PackingItemMeasures.Select(x => x.Volume).Sum();
     162      int bin = PackingBinMeasures.Volume;
     163      return (items + bin - 1) / (bin);
     164    }
     165
     166    private void ApplyEncoding() {
     167      if (SolutionCreator.GetType() == typeof(PackingSequenceRandomCreator)) {
     168        Operators.AddRange(ApplicationManager.Manager.GetInstances<IPackingSequenceOperator>());
     169        InitializeDecoder();
     170      } else if (SolutionCreator.GetType() == typeof(GroupingVectorRandomCreator)) {
     171        Operators.AddRange(ApplicationManager.Manager.GetInstances<IGroupingVectorOperator>());
     172        InitializeDecoder();
     173      } else if (SolutionCreator.GetType() == typeof(MultiComponentVectorRandomCreator)) {
     174        Operators.AddRange(ApplicationManager.Manager.GetInstances<IMultiComponentVectorOperator>());
     175        InitializeDecoder();
     176      }
     177    }
     178    private void ParameterizeOperators() {
     179      foreach (var op in Operators.OfType<BestBinPackingSolutionAnalyzer<D, B, I>>()) {
     180        op.QualityParameter.ActualName = PackingPlanEvaluator.QualityParameter.ActualName;
     181      }
     182
     183      Evaluator.PackingSolutionDecoderParameter.ActualName = PackingSolutionDecoderParameter.Name;
     184      Evaluator.PackingSolutionDecoderParameter.Hidden = true;
     185      Evaluator.PackingPlanEvaluatorParameter.ActualName = PackingPlanEvaluatorParameter.Name;
     186      Evaluator.PackingPlanEvaluatorParameter.Hidden = true;
     187      Evaluator.QualityParameter.ActualName = PackingPlanEvaluator.QualityParameter.ActualName;
     188      Evaluator.QualityParameter.Hidden = true;
     189
     190      if (PackingSolutionDecoder != null)
     191        PackingSolutionDecoder.EncodedSolutionParameter.ActualName = SolutionCreator.EncodedSolutionParameter.ActualName;
     192
     193      if (PackingSolutionDecoder != null) {
     194        PackingPlanEvaluator.PackingPlanParameter.ActualName = PackingSolutionDecoder.PackingPlanParameter.ActualName;
     195        PackingPlanEvaluator.PackingPlanParameter.Hidden = true;
     196      } else {
     197        PackingPlanEvaluator.PackingPlanParameter.ActualName = PackingPlanEvaluator.PackingPlanParameter.Name;
     198        PackingPlanEvaluator.PackingPlanParameter.Hidden = false;
     199      }
     200
     201      foreach (var op in Operators.OfType<IPackingSolutionManipulator>()) {
     202        op.EncodedSolutionParameter.ActualName = SolutionCreator.EncodedSolutionParameter.ActualName;
     203        op.EncodedSolutionParameter.Hidden = true;
     204      }
     205
     206      foreach (var op in Operators.OfType<IPackingSolutionCrossover>()) {
     207        op.ChildParameter.ActualName = SolutionCreator.EncodedSolutionParameter.ActualName;
     208        op.ChildParameter.Hidden = true;
     209        op.ParentsParameter.ActualName = SolutionCreator.EncodedSolutionParameter.ActualName;
     210        op.ParentsParameter.Hidden = true;
     211      }
     212
     213      foreach (var op in Operators.OfType<BestBinPackingSolutionAnalyzer<D, B, I>>()) {
     214        op.QualityParameter.ActualName = PackingPlanEvaluator.QualityParameter.ActualName;
     215        if (PackingSolutionDecoder != null) {
     216          op.PackingPlanParameter.ActualName = PackingSolutionDecoder.PackingPlanParameter.ActualName;
     217          op.PackingPlanParameter.Hidden = true;
     218        } else {
     219          op.PackingPlanParameter.ActualName = op.PackingPlanParameter.Name;
     220          op.PackingPlanParameter.Hidden = false;
     221        }
     222      }
     223
     224    }
     225
     226    #region Events
     227    protected override void OnSolutionCreatorChanged() {
     228      InitializeOperators();
     229    }
     230    protected override void OnEvaluatorChanged() {
     231      base.OnEvaluatorChanged();
     232      ParameterizeOperators();
     233    }
     234    private void PackingPlanEvaluatorParameter_ValueChanged(object sender, EventArgs eventArgs) {
     235      PackingPlanEvaluator.QualityParameter.ActualNameChanged += PackingPlanEvaluator_QualityParameter_ActualNameChanged;
     236      ParameterizeOperators();
     237    }
     238    private void PackingPlanEvaluator_QualityParameter_ActualNameChanged(object sender, EventArgs eventArgs) {
     239      ParameterizeOperators();
     240    }
     241    private void SolutionCreatorParameter_ValueChanged(object sender, EventArgs eventArgs) {
     242      SolutionCreator.EncodedSolutionParameter.ActualNameChanged += SolutionCreator_EncodedSolutionParameter_ActualNameChanged;
     243      ParameterizeOperators();
     244    }
     245    private void SolutionCreator_EncodedSolutionParameter_ActualNameChanged(object sender, EventArgs eventArgs) {
     246      ParameterizeOperators();
     247    }
     248    private void PackingSolutionDecoderParameter_ValueChanged(object sender, EventArgs eventArgs) {
     249      if (PackingSolutionDecoder != null) PackingSolutionDecoder.PackingPlanParameter.ActualNameChanged += PackingSolutionDecoder_PackingPlanParameter_ActualNameChanged;
     250      ParameterizeOperators();
     251    }
     252    private void PackingSolutionDecoder_PackingPlanParameter_ActualNameChanged(object sender, EventArgs eventArgs) {
     253      ParameterizeOperators();
     254    }
     255    #endregion
    92256  }
    93257}
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/HeuristicLab.Problems.BinPacking-3.3.csproj

    r13613 r14040  
    290290    <Compile Include="Plugin.cs" />
    291291    <Compile Include="Properties\AssemblyInfo.cs" />
    292     <Compile Include="RegularIdenticalBinPackingProblem.cs" />
    293292  </ItemGroup>
    294293  <ItemGroup>
  • branches/HeuristicLab.BinPacking/HeuristicLab.Problems.BinPacking/3.3/RegularIdenticalBinPackingProblem.cs

    r14039 r14040  
    4747
    4848    #region Parameter Properties
    49     public IValueParameter<B> PackingBinMeasuresParameter {
    50       get { return (IValueParameter<B>)Parameters["PackingBinMeasures"]; }
    51     }
    52     public IConstrainedValueParameter<IPackingSolutionDecoder> PackingSolutionDecoderParameter {
    53       get { return (IConstrainedValueParameter<IPackingSolutionDecoder>)Parameters["PackingSolutionDecoder"]; }
    54     }
     49
    5550    #endregion
    5651
    5752    #region Properties
    58     public B PackingBinMeasures {
    59       get { return PackingBinMeasuresParameter.Value; }
    60       set { PackingBinMeasuresParameter.Value = value; }
    61     }
    62     public PackingSolutionDecoder<D, B, I> PackingSolutionDecoder {
    63       get { return PackingSolutionDecoderParameter.Value as PackingSolutionDecoder<D, B, I>; }
    64       set { PackingSolutionDecoderParameter.Value = value; }
    65     }
     53
    6654    #endregion
    6755
Note: See TracChangeset for help on using the changeset viewer.