#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.Drawing;
using System.Linq;
using HeuristicLab.Analysis.QualityAnalysis;
using HeuristicLab.Common;
using HeuristicLab.Core;
using HeuristicLab.Data;
using HeuristicLab.Encodings.IntegerVectorEncoding;
using HeuristicLab.Optimization;
using HeuristicLab.Parameters;
using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
using HeuristicLab.PluginInfrastructure;
using HeuristicLab.Problems.Instances;
namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment {
[Item("Generalized Quadratic Assignment Problem", "The Generalized Quadratic Assignment Problem (GQAP) is a generalization of the QAP in that it allows to assign multiple facilities (here called equipment) to a single location. The problem is described in Lee, C.G., and Ma, Z. 2003. The Generalized Quadratic Assignment Problem. Technical Report M5S 3G8, University of Toronto, Canada.")]
[Creatable("Problems")]
[StorableClass]
public sealed class GeneralizedQuadraticAssignmentProblem : SingleObjectiveHeuristicOptimizationProblem, IStorableContent,
IProblemInstanceConsumer,
IProblemInstanceConsumer,
IProblemInstanceConsumer,
IProblemInstanceConsumer,
IProblemInstanceConsumer {
public override Image ItemImage {
get { return HeuristicLab.Common.Resources.VSImageLibrary.Type; }
}
public string Filename { get; set; }
#region Parameter Descriptions
public static readonly string MaximizationDescription = "False if the fitness function should be minimized (default) or otherwise True if it should be maximized.";
public static readonly string WeightsDescription = "The weights matrix describes the flows between the equipments.";
public static readonly string DistancesDescription = "The distances matrix describes the distances between the locations at which the equipment can be installed.";
public static readonly string InstallationCostsDescription = "The installation costs matrix describes the installation costs of installing equipment i at location j";
public static readonly string DemandsDescription = "The demands vector describes the space requirements of the equipments.";
public static readonly string CapacitiesDescription = "The capacities vector describes the available space at the locations.";
public static readonly string TransportationCostsDescription = "The transportation cost represents the flow-unit per distance-unit cost factor. This value can also be set to 1 if these costs are factored into the weights matrix already.";
public static readonly string BestKnownQualityDescription = "The best known quality (if available).";
public static readonly string BestKnownSolutionDescription = "The best known solution (if available).";
public static readonly string BestKnownSolutionsDescription = "Contains an archive of best-known solutions regarding flow-distance quality and installation quality.";
public static readonly string EquipmentNamesDescription = "Optional: A list of names that describes the equipments.";
public static readonly string LocationNamesDescription = "Optional: A list of names that describes the locations.";
public static readonly string ExpectedRandomQualityDescription = "The expected quality value of a random solution.";
#endregion
#region Parameter Properties
public ValueParameter WeightsParameter {
get { return (ValueParameter)Parameters["Weights"]; }
}
public ValueParameter DistancesParameter {
get { return (ValueParameter)Parameters["Distances"]; }
}
public ValueParameter InstallationCostsParameter {
get { return (ValueParameter)Parameters["InstallationCosts"]; }
}
public ValueParameter DemandsParameter {
get { return (ValueParameter)Parameters["Demands"]; }
}
public ValueParameter CapacitiesParameter {
get { return (ValueParameter)Parameters["Capacities"]; }
}
public FixedValueParameter TransportationCostsParameter {
get { return (FixedValueParameter)Parameters["TransportationCosts"]; }
}
public FixedValueParameter ExpectedRandomQualityParameter {
get { return (FixedValueParameter)Parameters["ExpectedRandomQuality"]; }
}
public OptionalValueParameter BestKnownSolutionParameter {
get { return (OptionalValueParameter)Parameters["BestKnownSolution"]; }
}
public OptionalValueParameter BestKnownSolutionsParameter {
get { return (OptionalValueParameter)Parameters["BestKnownSolutions"]; }
}
public OptionalValueParameter EquipmentNamesParameter {
get { return (OptionalValueParameter)Parameters["EquipmentNames"]; }
}
public OptionalValueParameter LocationNamesParameter {
get { return (OptionalValueParameter)Parameters["LocationNames"]; }
}
#endregion
#region Properties
public DoubleMatrix Weights {
get { return WeightsParameter.Value; }
set { WeightsParameter.Value = value; }
}
public DoubleMatrix Distances {
get { return DistancesParameter.Value; }
set { DistancesParameter.Value = value; }
}
public DoubleMatrix InstallationCosts {
get { return InstallationCostsParameter.Value; }
set { InstallationCostsParameter.Value = value; }
}
public DoubleArray Demands {
get { return DemandsParameter.Value; }
set { DemandsParameter.Value = value; }
}
public DoubleArray Capacities {
get { return CapacitiesParameter.Value; }
set { CapacitiesParameter.Value = value; }
}
public double TransportationCosts {
get { return TransportationCostsParameter.Value.Value; }
set { TransportationCostsParameter.Value.Value = value; }
}
public double ExpectedRandomQuality {
get { return ExpectedRandomQualityParameter.Value.Value; }
set { ExpectedRandomQualityParameter.Value.Value = value; }
}
public StringArray EquipmentNames {
get { return EquipmentNamesParameter.Value; }
set { EquipmentNamesParameter.Value = value; }
}
public StringArray LocationNames {
get { return LocationNamesParameter.Value; }
set { LocationNamesParameter.Value = value; }
}
public GQAPAssignment BestKnownSolution {
get { return BestKnownSolutionParameter.Value; }
set { BestKnownSolutionParameter.Value = value; }
}
public GQAPAssignmentArchive BestKnownSolutions {
get { return BestKnownSolutionsParameter.Value; }
set { BestKnownSolutionsParameter.Value = value; }
}
#endregion
public BestGQAPSolutionAnalyzer BestSolutionAnalyzer {
get { return Operators.OfType().FirstOrDefault(); }
}
public GQAPSolutionArchiveAnalyzer SolutionArchiveAnalyzer {
get { return Operators.OfType().FirstOrDefault(); }
}
[StorableConstructor]
private GeneralizedQuadraticAssignmentProblem(bool deserializing) : base(deserializing) { }
private GeneralizedQuadraticAssignmentProblem(GeneralizedQuadraticAssignmentProblem original, Cloner cloner)
: base(original, cloner) {
RegisterEventHandlers();
}
public GeneralizedQuadraticAssignmentProblem()
: base(new GQAPAdditivePenaltyEvaluator(), new RandomSolutionCreator()) {
Parameters.Add(new ValueParameter("Weights", WeightsDescription, new DoubleMatrix(), false));
Parameters.Add(new ValueParameter("Distances", DistancesDescription, new DoubleMatrix(), false));
Parameters.Add(new ValueParameter("InstallationCosts", InstallationCostsDescription, new DoubleMatrix(), false));
Parameters.Add(new FixedValueParameter("TransportationCosts", TransportationCostsDescription, new DoubleValue(1)));
Parameters.Add(new FixedValueParameter("ExpectedRandomQuality", ExpectedRandomQualityDescription, new DoubleValue(0), true));
Parameters.Add(new ValueParameter("Demands", DemandsDescription, new DoubleArray(), false));
Parameters.Add(new ValueParameter("Capacities", CapacitiesDescription, new DoubleArray(), false));
Parameters.Add(new OptionalValueParameter("BestKnownSolution", BestKnownSolutionDescription, null, false));
Parameters.Add(new OptionalValueParameter("BestKnownSolutions", BestKnownSolutionsDescription, null, false));
Parameters.Add(new OptionalValueParameter("EquipmentNames", EquipmentNamesDescription, null, false));
Parameters.Add(new OptionalValueParameter("LocationNames", LocationNamesDescription, null, false));
WeightsParameter.ReactOnValueToStringChangedAndValueItemImageChanged = false;
DistancesParameter.ReactOnValueToStringChangedAndValueItemImageChanged = false;
InstallationCostsParameter.ReactOnValueToStringChangedAndValueItemImageChanged = false;
DemandsParameter.ReactOnValueToStringChangedAndValueItemImageChanged = false;
CapacitiesParameter.ReactOnValueToStringChangedAndValueItemImageChanged = false;
Weights = new DoubleMatrix(5, 5);
Weights[0, 0] = Weights[1, 1] = Weights[2, 2] = Weights[3, 3] = Weights[4, 4] = 0;
Weights[0, 1] = Weights[1, 0] = Weights[0, 2] = Weights[2, 0] = Weights[0, 3] = Weights[3, 0] = Weights[0, 4] = Weights[4, 0] = 10;
Weights[1, 2] = Weights[2, 1] = Weights[1, 3] = Weights[3, 1] = Weights[1, 4] = Weights[4, 1] = 5;
Weights[2, 3] = Weights[3, 2] = Weights[2, 4] = Weights[4, 2] = 7.5;
Weights[3, 4] = Weights[4, 3] = 2.5;
Distances = new DoubleMatrix(3, 3);
Distances[0, 0] = Distances[1, 1] = Distances[2, 2] = 0;
Distances[0, 1] = Distances[1, 0] = Distances[1, 2] = Distances[2, 1] = 1;
Distances[0, 2] = Distances[2, 0] = 2;
InstallationCosts = new DoubleMatrix(5, 3);
Demands = new DoubleArray(5);
Demands[0] = 2; Demands[1] = 1; Demands[2] = 3; Demands[3] = 1; Demands[4] = 1;
Capacities = new DoubleArray(3);
Capacities[0] = 4; Capacities[1] = 1; Capacities[2] = 4;
SolutionCreator.AssignmentParameter.ActualName = "Assignment";
InitializeOperators();
RegisterEventHandlers();
}
public override IDeepCloneable Clone(Cloner cloner) {
return new GeneralizedQuadraticAssignmentProblem(this, cloner);
}
#region Problem Instance Loading
public void Load(QAPData data) {
Name = data.Name;
Description = data.Description;
var weights = new DoubleMatrix(data.Weights);
var distances = new DoubleMatrix(data.Distances);
var installationCosts = new DoubleMatrix(weights.Rows, distances.Columns); // all zero
var capacities = new DoubleArray(Enumerable.Range(0, distances.Rows).Select(x => 1.0).ToArray());
var demands = new DoubleArray(Enumerable.Range(0, weights.Rows).Select(x => 1.0).ToArray());
Load(demands, capacities, weights, distances, installationCosts, new DoubleValue(1));
EvaluateAndLoadAssignment(data.BestKnownAssignment);
}
public void Load(CTAPData data) {
Name = data.Name;
Description = data.Description;
var capacities = new DoubleArray(data.MemoryCapacities);
var demands = new DoubleArray(data.MemoryRequirements);
var weights = new DoubleMatrix(data.CommunicationCosts);
var installationCosts = new DoubleMatrix(data.ExecutionCosts.Transpose());
var distances = new DoubleMatrix(capacities.Length, capacities.Length);
for (int i = 0; i < capacities.Length - 1; i++)
for (int j = i + 1; j < capacities.Length; j++) {
distances[i, j] = 1;
}
Load(demands, capacities, weights, distances, installationCosts, new DoubleValue(1));
EvaluateAndLoadAssignment(data.BestKnownAssignment);
}
public void Load(TSPData data) {
if (data.Dimension > 1000)
throw new System.IO.InvalidDataException("Instances with more than 1000 cities are not supported.");
Name = data.Name;
Description = data.Description;
var capacities = new DoubleArray(data.Dimension);
var demands = new DoubleArray(data.Dimension);
for (int i = 0; i < data.Dimension; i++) {
capacities[i] = 1;
demands[i] = 1;
}
var installationCosts = new DoubleMatrix(data.Dimension, data.Dimension);
var weights = new DoubleMatrix(data.Dimension, data.Dimension);
for (int i = 0; i < data.Dimension; i++)
weights[i, (i + 1) % data.Dimension] = 1;
var distances = new DoubleMatrix(data.GetDistanceMatrix());
Load(demands, capacities, weights, distances, installationCosts, new DoubleValue(1));
EvaluateAndLoadAssignment(data.BestKnownTour);
}
public void Load(ATSPData data) {
Name = data.Name;
Description = data.Description;
var capacities = new DoubleArray(data.Dimension);
var demands = new DoubleArray(data.Dimension);
for (int i = 0; i < data.Dimension; i++) {
capacities[i] = 1;
demands[i] = 1;
}
var installationCosts = new DoubleMatrix(data.Dimension, data.Dimension);
var weights = new DoubleMatrix(data.Dimension, data.Dimension);
for (int i = 0; i < data.Dimension; i++)
weights[i, (i + 1) % data.Dimension] = 1;
var distances = new DoubleMatrix(data.Distances);
Load(demands, capacities, weights, distances, installationCosts, new DoubleValue(1));
EvaluateAndLoadAssignment(data.BestKnownTour);
}
public void Load(GQAPData data) {
Name = data.Name;
Description = data.Description;
var capacities = new DoubleArray(data.Capacities);
var demands = new DoubleArray(data.Demands);
var installationCosts = new DoubleMatrix(data.InstallationCosts);
var weights = new DoubleMatrix(data.Weights);
var distances = new DoubleMatrix(data.Distances);
var transportationCosts = new DoubleValue(data.TransportationCosts);
Load(demands, capacities, weights, distances, installationCosts, transportationCosts);
EvaluateAndLoadAssignment(data.BestKnownAssignment);
if (data.BestKnownAssignment == null && data.BestKnownQuality.HasValue) {
BestKnownQuality = new DoubleValue(data.BestKnownQuality.Value);
}
}
public void Load(DoubleArray demands, DoubleArray capacities,
DoubleMatrix weights, DoubleMatrix distances, DoubleMatrix installationCosts,
DoubleValue transportationCosts) {
if (weights == null || weights.Rows == 0)
throw new System.IO.InvalidDataException(
@"The given instance does not contain weights!");
if (weights.Rows != weights.Columns)
throw new System.IO.InvalidDataException(
@"The weights matrix of the given instance contains
an unequal number of rows and columns.");
Weights = weights;
if (distances == null || distances.Rows == 0)
throw new System.IO.InvalidDataException(
@"The given instance does not contain distances!");
if (distances.Rows != distances.Columns)
throw new System.IO.InvalidDataException(
@"The distances matrix of the given instance contains
an unequal number of rows and columns.");
Distances = distances;
if (installationCosts == null || installationCosts.Rows == 0)
throw new System.IO.InvalidDataException(
@"The given instance does not contain installation costs!");
if (installationCosts.Rows != weights.Rows
|| installationCosts.Columns != distances.Columns)
throw new System.IO.InvalidDataException(
@"The installation costs matrix of the given instance
contains different number of rows than given in the
weights matrix and a different number of columns than
given in the distances matrix.");
InstallationCosts = installationCosts;
if (capacities == null || capacities.Length == 0)
throw new System.IO.InvalidDataException(
@"The given instance does not contain capacities!");
if (capacities.Length != distances.Rows)
throw new System.IO.InvalidDataException(
@"The given instance contains a different number of
capacities than rows given in the distances matrix.");
Capacities = capacities;
if (demands == null || demands.Length == 0)
throw new System.IO.InvalidDataException(
@"The given instance does not contain demands!");
if (demands.Length != weights.Rows)
throw new System.IO.InvalidDataException(
@"The given instance contains a different number of
demands than rows given in the weights matrix.");
Demands = demands;
if (transportationCosts == null)
throw new System.IO.InvalidDataException(
@"The given instance does not contain transportation costs.");
TransportationCosts = transportationCosts.Value;
BestKnownQuality = null;
BestKnownSolution = null;
BestKnownSolutions = null;
CalculateExpectedRandomQuality();
}
private void CalculateExpectedRandomQuality() {
if (IsConfigurationValid()) {
double[] avgDistances = new double[Capacities.Length];
for (int i = 0; i < Capacities.Length; i++) {
for (int j = 0; j < Capacities.Length; j++)
avgDistances[i] += Distances[i, j];
avgDistances[i] /= Capacities.Length;
}
double[] avgWeight = new double[Demands.Length];
for (int i = 0; i < Demands.Length; i++) {
for (int j = 0; j < Demands.Length; j++)
avgWeight[i] += Weights[i, j];
avgWeight[i] /= Demands.Length;
}
double avgCosts = InstallationCosts.Average();
double quality = 0;
for (int i = 0; i < Demands.Length; i++) {
double equipmentInfluence = 0;
for (int j = 0; j < Capacities.Length; j++)
equipmentInfluence += avgWeight[i] * avgDistances[j];
quality += equipmentInfluence * Demands.Length / (double)Capacities.Length;
}
quality *= TransportationCosts;
quality += avgCosts * Demands.Length;
ExpectedRandomQuality = quality;
}
}
private void EvaluateAndLoadAssignment(int[] vector) {
if (vector == null || vector.Length == 0) return;
EvaluateAndLoadAssignment(new IntegerVector(vector));
}
public void EvaluateAndLoadAssignment(IntegerVector assignment) {
if (!IsConfigurationValid()) {
BestKnownQuality = null;
BestKnownSolution = null;
BestKnownSolutions = null;
}
double flowDistanceQuality, installationQuality, overbookedCapacity;
Evaluator.Evaluate(assignment, Weights, Distances, InstallationCosts, Demands, Capacities,
out flowDistanceQuality, out installationQuality, out overbookedCapacity);
double quality = Evaluator.GetFitness(flowDistanceQuality, installationQuality, overbookedCapacity, TransportationCosts, ExpectedRandomQuality);
BestKnownSolution = new GQAPAssignment((IntegerVector)assignment.Clone(), new DoubleValue(quality),
new DoubleValue(flowDistanceQuality), new DoubleValue(installationQuality),
new DoubleValue(overbookedCapacity), EquipmentNames, LocationNames, Distances, Weights, InstallationCosts,
Demands, Capacities, new DoubleValue(TransportationCosts), new DoubleValue(ExpectedRandomQuality), Evaluator);
BestKnownQuality = new DoubleValue(quality);
BestKnownSolutions = new GQAPAssignmentArchive(EquipmentNames, LocationNames, Distances, Weights, InstallationCosts, Demands, Capacities, new DoubleValue(TransportationCosts), new DoubleValue(ExpectedRandomQuality), Evaluator);
BestKnownSolutions.Solutions.Add(new GQAPSolution((IntegerVector)assignment.Clone(), new DoubleValue(quality), new DoubleValue(flowDistanceQuality), new DoubleValue(installationQuality), new DoubleValue(overbookedCapacity)));
}
#endregion
#region Events
protected override void OnOperatorsChanged() {
base.OnOperatorsChanged();
Parameterize();
}
protected override void OnEvaluatorChanged() {
base.OnEvaluatorChanged();
Parameterize();
if (BestKnownSolution != null) EvaluateAndLoadAssignment(BestKnownSolution.Assignment);
Evaluator.QualityParameter.ActualNameChanged += new System.EventHandler(Evaluator_QualityParameter_ActualNameChanged);
}
protected override void OnSolutionCreatorChanged() {
base.OnSolutionCreatorChanged();
Parameterize();
SolutionCreator.AssignmentParameter.ActualNameChanged += new EventHandler(SolutionCreator_IntegerVectorParameter_ActualNameChanged);
}
private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
Parameterize();
}
private void SolutionCreator_IntegerVectorParameter_ActualNameChanged(object sender, EventArgs e) {
Parameterize();
}
#endregion
#region Helpers
[StorableHook(HookType.AfterDeserialization)]
private void AfterDeserialization() {
RegisterEventHandlers();
}
private void RegisterEventHandlers() {
Evaluator.QualityParameter.ActualNameChanged += new System.EventHandler(Evaluator_QualityParameter_ActualNameChanged);
SolutionCreator.AssignmentParameter.ActualNameChanged += new EventHandler(SolutionCreator_IntegerVectorParameter_ActualNameChanged);
}
private void InitializeOperators() {
Operators.Clear();
Operators.AddRange(ApplicationManager.Manager.GetInstances());
Operators.AddRange(ApplicationManager.Manager.GetInstances());
Operators.RemoveAll(x => x is ISingleObjectiveMoveEvaluator);
Operators.AddRange(ApplicationManager.Manager.GetInstances());
Operators.Add(new ScaledQualityDifferenceAnalyzer());
Parameterize();
}
private void Parameterize() {
var operators = Operators.Union(new IOperator[] { SolutionCreator, Evaluator }).ToArray();
foreach (var op in operators.OfType()) {
op.AssignmentParameter.ActualName = SolutionCreator.AssignmentParameter.ActualName;
op.AssignmentParameter.Hidden = true;
}
foreach (var op in operators.OfType()) {
op.BestKnownQualityParameter.ActualName = BestKnownQualityParameter.Name;
op.BestKnownQualityParameter.Hidden = true;
}
foreach (var op in operators.OfType()) {
op.BestKnownSolutionParameter.ActualName = BestKnownSolutionParameter.Name;
op.BestKnownSolutionParameter.Hidden = true;
}
foreach (var op in operators.OfType()) {
op.BestKnownSolutionsParameter.ActualName = BestKnownSolutionsParameter.Name;
op.BestKnownSolutionsParameter.Hidden = true;
}
foreach (var op in operators.OfType()) {
op.CapacitiesParameter.ActualName = CapacitiesParameter.Name;
op.CapacitiesParameter.Hidden = true;
}
foreach (var op in operators.OfType()) {
op.DemandsParameter.ActualName = DemandsParameter.Name;
op.DemandsParameter.Hidden = true;
}
foreach (var op in operators.OfType()) {
op.DistancesParameter.ActualName = DistancesParameter.Name;
op.DistancesParameter.Hidden = true;
}
foreach (var op in operators.OfType()) {
op.EquipmentNamesParameter.ActualName = EquipmentNamesParameter.Name;
op.EquipmentNamesParameter.Hidden = true;
}
foreach (var op in operators.OfType()) {
op.ParentsParameter.ActualName = SolutionCreator.AssignmentParameter.ActualName;
op.ParentsParameter.Hidden = true;
op.ChildParameter.ActualName = SolutionCreator.AssignmentParameter.ActualName;
op.ChildParameter.Hidden = true;
}
foreach (var op in operators.OfType()) {
op.InstallationCostsParameter.ActualName = InstallationCostsParameter.Name;
op.InstallationCostsParameter.Hidden = true;
}
foreach (var op in operators.OfType()) {
op.LocationNamesParameter.ActualName = LocationNamesParameter.Name;
op.LocationNamesParameter.Hidden = true;
}
var moveEvaluator = operators.OfType().FirstOrDefault();
foreach (var op in operators.OfType()) { // synchronize all move evaluators
if (moveEvaluator != null) {
op.MoveQualityParameter.ActualName = moveEvaluator.MoveQualityParameter.ActualName;
op.MoveQualityParameter.Hidden = true;
op.MoveFlowDistanceQualityParameter.ActualName = moveEvaluator.MoveFlowDistanceQualityParameter.ActualName;
op.MoveFlowDistanceQualityParameter.Hidden = true;
op.MoveInstallationQualityParameter.ActualName = moveEvaluator.MoveInstallationQualityParameter.ActualName;
op.MoveInstallationQualityParameter.Hidden = true;
op.MoveOverbookedCapacityParameter.ActualName = moveEvaluator.MoveOverbookedCapacityParameter.ActualName;
op.MoveOverbookedCapacityParameter.Hidden = true;
}
}
foreach (var op in operators.OfType()) {
if (moveEvaluator != null) {
op.MoveQualityParameter.ActualName = moveEvaluator.MoveQualityParameter.ActualName;
op.MoveQualityParameter.Hidden = true;
op.MoveFlowDistanceQualityParameter.ActualName = moveEvaluator.MoveFlowDistanceQualityParameter.ActualName;
op.MoveFlowDistanceQualityParameter.Hidden = true;
op.MoveInstallationQualityParameter.ActualName = moveEvaluator.MoveInstallationQualityParameter.ActualName;
op.MoveInstallationQualityParameter.Hidden = true;
op.MoveOverbookedCapacityParameter.ActualName = moveEvaluator.MoveOverbookedCapacityParameter.ActualName;
op.MoveOverbookedCapacityParameter.Hidden = true;
}
op.MaximizationParameter.ActualName = MaximizationParameter.Name;
op.MaximizationParameter.Hidden = true;
}
foreach (var op in operators.OfType()) {
op.ExpectedRandomQualityParameter.ActualName = ExpectedRandomQualityParameter.Name;
op.ExpectedRandomQualityParameter.Hidden = true;
}
foreach (var op in operators.OfType()) {
op.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
op.QualityParameter.Hidden = true;
op.FlowDistanceQualityParameter.ActualName = Evaluator.FlowDistanceQualityParameter.ActualName;
op.FlowDistanceQualityParameter.Hidden = true;
op.InstallationQualityParameter.ActualName = Evaluator.InstallationQualityParameter.ActualName;
op.InstallationQualityParameter.Hidden = true;
op.OverbookedCapacityParameter.ActualName = Evaluator.OverbookedCapacityParameter.ActualName;
op.OverbookedCapacityParameter.Hidden = true;
op.MaximizationParameter.ActualName = MaximizationParameter.Name;
op.MaximizationParameter.Hidden = true;
}
foreach (var op in operators.OfType()) {
op.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
op.QualityParameter.Hidden = true;
op.FlowDistanceQualityParameter.ActualName = Evaluator.FlowDistanceQualityParameter.ActualName;
op.FlowDistanceQualityParameter.Hidden = true;
op.InstallationQualityParameter.ActualName = Evaluator.InstallationQualityParameter.ActualName;
op.InstallationQualityParameter.Hidden = true;
op.OverbookedCapacityParameter.ActualName = Evaluator.OverbookedCapacityParameter.ActualName;
op.OverbookedCapacityParameter.Hidden = true;
op.MaximizationParameter.ActualName = MaximizationParameter.Name;
op.MaximizationParameter.Hidden = true;
}
foreach (var op in operators.OfType()) {
op.TransportationCostsParameter.ActualName = TransportationCostsParameter.Name;
op.TransportationCostsParameter.Hidden = true;
}
foreach (var op in operators.OfType()) {
op.WeightsParameter.ActualName = WeightsParameter.Name;
op.WeightsParameter.Hidden = true;
}
foreach (var op in operators.OfType()) {
op.EvaluatorParameter.ActualName = EvaluatorParameter.Name;
op.EvaluatorParameter.Hidden = true;
}
foreach (var op in operators.OfType()) {
op.ParentsParameter.ActualName = SolutionCreator.AssignmentParameter.ActualName;
op.ParentsParameter.Hidden = true;
op.ChildParameter.ActualName = SolutionCreator.AssignmentParameter.ActualName;
op.ChildParameter.Hidden = true;
}
foreach (var op in operators.OfType()) {
op.IntegerVectorParameter.ActualName = SolutionCreator.AssignmentParameter.ActualName;
op.IntegerVectorParameter.Hidden = true;
}
foreach (var op in operators.OfType()) {
op.MinimumQualityParameter.ActualName = BestKnownQualityParameter.Name;
op.MinimumQualityParameter.Hidden = true;
op.MaximumQualityParameter.ActualName = ExpectedRandomQualityParameter.Name;
op.MaximumQualityParameter.Hidden = true;
op.QualityParameter.ActualName = "BestQuality";
op.QualityParameter.Hidden = true;
}
}
#endregion
public bool IsConfigurationValid() {
return Weights != null && Distances != null && Demands != null && Capacities != null && InstallationCosts != null
&& Weights.Rows == Weights.Columns && Weights.Rows == InstallationCosts.Rows
&& Distances.Rows == Distances.Columns && Distances.Rows == InstallationCosts.Columns
&& Demands.Length == Weights.Rows && Capacities.Length == Distances.Rows;
}
}
}