Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/29/20 14:44:19 (4 years ago)
Author:
abeham
Message:

#2521: working on refactoring

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.GraphColoring/3.3/GraphColoringProblem.cs

    r17745 r17778  
    4343    IProblemInstanceConsumer<GCPData>, IProblemInstanceExporter<GCPData> {
    4444
    45     [Storable]
    46     private IValueParameter<IntMatrix> adjacencyListParameter;
    47     public IValueParameter<IntMatrix> AdjacencyListParameter {
    48       get { return adjacencyListParameter; }
    49     }
    50     [Storable]
    51     private IValueParameter<EnumValue<FitnessFunction>> fitnessFunctionParameter;
    52     public IValueParameter<EnumValue<FitnessFunction>> FitnessFunctionParameter {
    53       get { return fitnessFunctionParameter; }
    54     }
     45    [Storable] public IValueParameter<IntMatrix> AdjacencyListParameter { get; private set; }
     46    [Storable] public IValueParameter<EnumValue<FitnessFunction>> FitnessFunctionParameter { get; private set; }
     47    [Storable] public IValueParameter<IntValue> BestKnownColorsParameter { get; private set; }
     48    [Storable] public IResult<IntValue> BestSolutionColorsResult { get; private set; }
     49    [Storable] public IResult<IntValue> BestSolutionConflicts { get; private set; }
     50
    5551    public FitnessFunction FitnessFunction {
    56       get { return fitnessFunctionParameter.Value.Value; }
    57       set { fitnessFunctionParameter.Value.Value = value; }
    58     }
    59     [Storable]
    60     private IValueParameter<IntValue> bestKnownColorsParameter;
    61     public IValueParameter<IntValue> BestKnownColorsParameter {
    62       get { return bestKnownColorsParameter; }
     52      get { return FitnessFunctionParameter.Value.Value; }
     53      set { FitnessFunctionParameter.Value.Value = value; }
    6354    }
    6455
     
    6758    private GraphColoringProblem(GraphColoringProblem original, Cloner cloner)
    6859      : base(original, cloner) {
    69       adjacencyListParameter = cloner.Clone(original.adjacencyListParameter);
    70       fitnessFunctionParameter = cloner.Clone(original.fitnessFunctionParameter);
    71       bestKnownColorsParameter = cloner.Clone(original.bestKnownColorsParameter);
     60      AdjacencyListParameter = cloner.Clone(original.AdjacencyListParameter);
     61      FitnessFunctionParameter = cloner.Clone(original.FitnessFunctionParameter);
     62      BestKnownColorsParameter = cloner.Clone(original.BestKnownColorsParameter);
    7263      RegisterEventHandlers();
    7364    }
    7465    public GraphColoringProblem() {
    7566      Maximization = false;
    76       Parameters.Add(adjacencyListParameter = new ValueParameter<IntMatrix>("Adjacency List", "The adjacency list that describes the (symmetric) edges in the graph with nodes from 0 to N-1.") { ReadOnly = true });
    77       Parameters.Add(fitnessFunctionParameter = new ValueParameter<EnumValue<FitnessFunction>>("Fitness Function", "The function to use for evaluating the quality of a solution.", new EnumValue<FitnessFunction>(FitnessFunction.Penalized)));
    78       Parameters.Add(bestKnownColorsParameter = new OptionalValueParameter<IntValue>("BestKnownColors", "The least amount of colors in a valid coloring.") { ReadOnly = true });
     67      Parameters.Add(AdjacencyListParameter = new ValueParameter<IntMatrix>("Adjacency List", "The adjacency list that describes the (symmetric) edges in the graph with nodes from 0 to N-1.") { ReadOnly = true });
     68      Parameters.Add(FitnessFunctionParameter = new ValueParameter<EnumValue<FitnessFunction>>("Fitness Function", "The function to use for evaluating the quality of a solution.", new EnumValue<FitnessFunction>(FitnessFunction.Penalized)));
     69      Parameters.Add(BestKnownColorsParameter = new OptionalValueParameter<IntValue>("BestKnownColors", "The least amount of colors in a valid coloring.") { ReadOnly = true });
     70      Results.Add(BestSolutionColorsResult = new Result<IntValue>("Best Solution Colors", "The number of best solution found so far."));
    7971
    8072      var imat = new IntMatrix(defaultInstance.Length, 2);
     
    10496
    10597    private void RegisterEventHandlers() {
    106       fitnessFunctionParameter.ValueChanged += FitnessFunctionParameterOnValueChanged;
    107       fitnessFunctionParameter.Value.ValueChanged += FitnessFunctionOnValueChanged;
     98      FitnessFunctionParameter.ValueChanged += FitnessFunctionParameterOnValueChanged;
     99      FitnessFunctionParameter.Value.ValueChanged += FitnessFunctionOnValueChanged;
    108100    }
    109101
    110102    private void FitnessFunctionParameterOnValueChanged(object sender, EventArgs eventArgs) {
    111       fitnessFunctionParameter.Value.ValueChanged += FitnessFunctionOnValueChanged;
     103      FitnessFunctionParameter.Value.ValueChanged += FitnessFunctionOnValueChanged;
    112104      FitnessFunctionOnValueChanged(sender, eventArgs);
    113105    }
     
    126118
    127119    public override ISingleObjectiveEvaluationResult Evaluate(LinearLinkage lle, IRandom random, CancellationToken cancellationToken) {
    128       var adjList = adjacencyListParameter.Value;
     120      var adjList = AdjacencyListParameter.Value;
    129121      var llee = lle.ToEndLinks(); // LLE-e encoding uses the highest indexed member as group number
    130122
Note: See TracChangeset for help on using the changeset viewer.