#region License Information
/* HeuristicLab
* Copyright (C) 2002-2018 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 HeuristicLab.Common;
using HeuristicLab.Core;
using HeuristicLab.Data;
using HeuristicLab.Optimization;
using HeuristicLab.Parameters;
using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
namespace HeuristicLab.Selection {
///
/// A base class for selection operators which consider a single double quality value for selection.
///
[Item("SingleObjectiveSelector", "A base class for selection operators which consider a single double quality value for selection.")]
[StorableClass]
public abstract class SingleObjectiveSelector : Selector, ISingleObjectiveOperator {
protected IValueParameter CopySelectedParameter {
get { return (IValueParameter)Parameters["CopySelected"]; }
}
public IValueLookupParameter NumberOfSelectedSubScopesParameter {
get { return (IValueLookupParameter)Parameters["NumberOfSelectedSubScopes"]; }
}
public IValueLookupParameter MaximizationParameter {
get { return (IValueLookupParameter)Parameters["Maximization"]; }
}
public ILookupParameter> QualityParameter {
get { return (ILookupParameter>)Parameters["Quality"]; }
}
public BoolValue CopySelected {
get { return CopySelectedParameter.Value; }
set { CopySelectedParameter.Value = value; }
}
[StorableConstructor]
protected SingleObjectiveSelector(bool deserializing) : base(deserializing) { }
protected SingleObjectiveSelector(SingleObjectiveSelector original, Cloner cloner) : base(original, cloner) { }
protected SingleObjectiveSelector()
: base() {
Parameters.Add(new ValueParameter("CopySelected", "True if the selected sub-scopes should be copied, otherwise false.", new BoolValue(true)));
Parameters.Add(new ValueLookupParameter("NumberOfSelectedSubScopes", "The number of sub-scopes which should be selected."));
Parameters.Add(new ValueLookupParameter("Maximization", "True if the current problem is a maximization problem, otherwise false."));
Parameters.Add(new ScopeTreeLookupParameter("Quality", "The quality value contained in each sub-scope which is used for selection."));
CopySelectedParameter.Hidden = true;
}
protected bool IsValidQuality(double quality) {
return !double.IsNaN(quality) && !double.IsInfinity(quality);
}
}
}