#region License Information /* HeuristicLab * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL) * * This file is part of HeuristicLab. * * HeuristicLab is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * HeuristicLab is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HeuristicLab. If not, see . */ #endregion using System; using System.Collections.Generic; using System.Linq; using System.Text; using HeuristicLab.Optimization; using HeuristicLab.Problems.BinPacking.Interfaces; using HeuristicLab.Problems.BinPacking.Shapes; using HeuristicLab.Core; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; using HeuristicLab.Common; using HeuristicLab.Parameters; using HeuristicLab.Problems.BinPacking.PackingPlans; using HeuristicLab.Problems.BinPacking.Evaluators; using HeuristicLab.Problems.BinPacking.Analyzers; using HeuristicLab.Encodings.PermutationEncoding; using HeuristicLab.PluginInfrastructure; using HeuristicLab.Data; namespace HeuristicLab.Problems.BinPacking.Problem { [Item("BinPackingProblem", "Abstract class that represents a BinPacking Problem")] [StorableClass] public abstract class BinPackingProblem : SingleObjectiveHeuristicOptimizationProblem where D : class, IPackingDimensions where B : PackingShape, IPackingBin, new() where I : PackingShape, IPackingItem, new () { #region Parameter Properties public OptionalValueParameter> BestKnownSolutionParameter { get { return (OptionalValueParameter>)Parameters["BestKnownSolution"]; } } public ValueParameter> PackingItemMeasuresParameter { get { return (ValueParameter>)Parameters["PackingItemMeasures"]; } } public IFixedValueParameter PackingItemsParameter { get { return (IFixedValueParameter)Parameters["PackingItems"]; } } public IFixedValueParameter LowerBoundParameter { get { return (IFixedValueParameter)Parameters["LowerBound"]; } } public ValueParameter PackingPlanEvaluatorParameter { get { return (ValueParameter)Parameters["PackingPlanEvaluator"]; } } #endregion #region Properties public PackingPlan BestKnownSolution { get { return BestKnownSolutionParameter.Value; } set { BestKnownSolutionParameter.Value = value; } } public ItemList PackingItemMeasures { get { return PackingItemMeasuresParameter.Value; } set { PackingItemMeasuresParameter.Value = value; } } public IPackingPlanEvaluator PackingPlanEvaluator { get { return PackingPlanEvaluatorParameter.Value; } set { PackingPlanEvaluatorParameter.Value = value; } } #endregion [StorableConstructor] protected BinPackingProblem(bool deserializing) : base(deserializing) { } protected BinPackingProblem(BinPackingProblem original, Cloner cloner) : base(original, cloner) { } protected BinPackingProblem(IPackingPlanEvaluationAlgorithm e, IPackingSolutionCreator c) : base (e, c){ Parameters.Add(new OptionalValueParameter>("BestKnownSolution", "The best known solution of this bin-packing instance.")); Parameters.Add(new ValueParameter>("PackingItemMeasures", "Packing-item data defining the measures of the different items that need to be packed.", new ItemList())); Parameters.Add(new FixedValueParameter("PackingItems", "The number of packing-items used in this bin packing instance.", new IntValue())); Parameters.Add(new FixedValueParameter("LowerBound", "The lower possible number of bins needed to solve this problem (taken from Dell'Amico, Martello and Vigo; 2002)", new IntValue())); } #region Helpers protected abstract void InitializeDecoder(); protected abstract void InitializeProblemInstance(); protected abstract void InitializeOperators(); protected abstract void InitializeEventHandlers(); #endregion } }