[9334] | 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.Linq;
|
---|
| 23 | using HeuristicLab.Common;
|
---|
| 24 | using HeuristicLab.Core;
|
---|
| 25 | using HeuristicLab.Data;
|
---|
| 26 | using HeuristicLab.Encodings.DecisionList;
|
---|
| 27 | using HeuristicLab.Encodings.DecisionList.Interfaces;
|
---|
| 28 | using HeuristicLab.Optimization;
|
---|
| 29 | using HeuristicLab.Parameters;
|
---|
| 30 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 31 | using HeuristicLab.Problems.DataAnalysis;
|
---|
| 32 |
|
---|
| 33 | namespace HeuristicLab.Problems.DecisionListClassification {
|
---|
| 34 | [Item("DecisionListClassificationProblem", "")]
|
---|
| 35 | [StorableClass]
|
---|
| 36 | [Creatable("Problems")]
|
---|
| 37 | public class DecisionListClassificationProblem : HeuristicOptimizationProblem<IDecisionListEvaluator, IDecisionListCreator>, IDecisionListClassificationProblem {
|
---|
| 38 |
|
---|
| 39 | #region parameter properties
|
---|
| 40 | public IFixedValueParameter<BoolValue> MaximizationParameter {
|
---|
| 41 | get { return (IFixedValueParameter<BoolValue>)Parameters["Maximization"]; }
|
---|
| 42 | }
|
---|
| 43 | IParameter ISingleObjectiveHeuristicOptimizationProblem.MaximizationParameter {
|
---|
| 44 | get { return MaximizationParameter; }
|
---|
| 45 | }
|
---|
| 46 | public IFixedValueParameter<DoubleValue> BestKnownQualityParameter {
|
---|
| 47 | get { return (IFixedValueParameter<DoubleValue>)Parameters["BestKnownQuality"]; }
|
---|
| 48 | }
|
---|
| 49 | IParameter ISingleObjectiveHeuristicOptimizationProblem.BestKnownQualityParameter {
|
---|
| 50 | get { return BestKnownQualityParameter; }
|
---|
| 51 | }
|
---|
| 52 | public IValueParameter<IDecisionListClassificationProblemData> ProblemDataParameter {
|
---|
| 53 | get { return (IValueParameter<IDecisionListClassificationProblemData>)Parameters["ProblemData"]; }
|
---|
| 54 | }
|
---|
| 55 | public IFixedValueParameter<IntValue> SizePenaltyMinRulesParameter {
|
---|
| 56 | get { return (IFixedValueParameter<IntValue>)Parameters["SizePenaltyMinRules"]; }
|
---|
| 57 | }
|
---|
| 58 | public IFixedValueParameter<IntValue> ActivationIterationParameter {
|
---|
| 59 | get { return (IFixedValueParameter<IntValue>)Parameters["ActivationIteration"]; }
|
---|
| 60 | }
|
---|
| 61 | public IFixedValueParameter<DoubleValue> InitialTheoryLengthRatioParameter {
|
---|
| 62 | get { return (IFixedValueParameter<DoubleValue>)Parameters["InitialTheoryLengthRatio"]; }
|
---|
| 63 | }
|
---|
| 64 | public IFixedValueParameter<DoubleValue> WeightRelaxFactorParameter {
|
---|
| 65 | get { return (IFixedValueParameter<DoubleValue>)Parameters["WeightRelaxFactor"]; }
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | public IDecisionListClassificationProblemData ProblemData {
|
---|
| 69 | get { return ProblemDataParameter.Value; }
|
---|
| 70 | protected set {
|
---|
| 71 | ProblemDataParameter.Value = value;
|
---|
| 72 | }
|
---|
| 73 | }
|
---|
| 74 | IParameter IDecisionListClassificationProblem.ProblemDataParameter {
|
---|
| 75 | get { return ProblemDataParameter; }
|
---|
| 76 | }
|
---|
| 77 | IDecisionListClassificationProblemData IDecisionListClassificationProblem.ProblemData {
|
---|
| 78 | get { return ProblemData; }
|
---|
| 79 | }
|
---|
| 80 |
|
---|
| 81 | IDecisionListEvaluator IDecisionListClassificationProblem.Evaluator {
|
---|
| 82 | get { return Evaluator; }
|
---|
| 83 | }
|
---|
| 84 | ISingleObjectiveEvaluator ISingleObjectiveHeuristicOptimizationProblem.Evaluator {
|
---|
| 85 | get { return Evaluator; }
|
---|
| 86 | }
|
---|
| 87 | #endregion
|
---|
| 88 |
|
---|
| 89 | [StorableConstructor]
|
---|
| 90 | protected DecisionListClassificationProblem(bool deserializing) : base(deserializing) { }
|
---|
| 91 | protected DecisionListClassificationProblem(DecisionListClassificationProblem original, Cloner cloner)
|
---|
| 92 | : base(original, cloner) {
|
---|
| 93 | }
|
---|
| 94 |
|
---|
| 95 | public DecisionListClassificationProblem()
|
---|
| 96 | : this(new DecisionListClassificationProblemData(new Dataset(DecisionListClassificationProblemData.defaultVariableNames, DecisionListClassificationProblemData.defaultData),
|
---|
| 97 | DecisionListClassificationProblemData.defaultVariableNames.Take(DecisionListClassificationProblemData.defaultVariableNames.Length - 1), DecisionListClassificationProblemData.defaultVariableNames.Last()),
|
---|
| 98 | new MDLEvaluator(), new UniformRandomDecisionListCreator()) { }
|
---|
| 99 |
|
---|
| 100 | public DecisionListClassificationProblem(IDecisionListClassificationProblemData problemData, IDecisionListEvaluator decisionlistEvaluator, IDecisionListCreator decisionListCreator)
|
---|
| 101 | : base(decisionlistEvaluator, decisionListCreator) {
|
---|
| 102 | Parameters.Add(new ValueParameter<IDecisionListClassificationProblemData>("ProblemData", "", problemData));
|
---|
| 103 | Parameters.Add(new FixedValueParameter<BoolValue>("Maximization", "", new BoolValue(true)));
|
---|
| 104 | Parameters.Add(new FixedValueParameter<DoubleValue>("BestKnownQuality", "", new DoubleValue(0.5)));
|
---|
| 105 | Parameters.Add(new FixedValueParameter<IntValue>("SizePenaltyMinRules", "", new IntValue(4)));
|
---|
| 106 | Parameters.Add(new FixedValueParameter<IntValue>("ActivationIteration", "", new IntValue(25)));
|
---|
| 107 | Parameters.Add(new FixedValueParameter<DoubleValue>("InitialTheoryLengthRatio", "", new DoubleValue(0.075)));
|
---|
| 108 | Parameters.Add(new FixedValueParameter<DoubleValue>("WeightRelaxFactor", "", new DoubleValue(0.9)));
|
---|
| 109 |
|
---|
| 110 | Evaluator.SizePenaltyMinRulesParameter.ActualName = "SizePenaltyMinRules";
|
---|
| 111 | // do differently
|
---|
| 112 | ((MDLEvaluator)Evaluator).MDLCalculatorParameter.Value = new MDLCalculator(ActivationIterationParameter.Value.Value, InitialTheoryLengthRatioParameter.Value.Value, WeightRelaxFactorParameter.Value.Value);
|
---|
| 113 | }
|
---|
| 114 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
| 115 | return new DecisionListClassificationProblem(this, cloner);
|
---|
| 116 | }
|
---|
| 117 | }
|
---|
| 118 | }
|
---|