Free cookie consent management tool by TermsFeed Policy Generator

Changeset 4860


Ignore:
Timestamp:
11/19/10 15:43:21 (13 years ago)
Author:
svonolfe
Message:

Merged changes from trunk into branch (#1177)

Location:
branches/VRP
Files:
3 added
10 edited

Legend:

Unmodified
Added
Removed
  • branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.4/HeuristicLab.Problems.VehicleRouting.Views-3.4.csproj

    r4374 r4860  
    125125      <DependentUpon>SingleDepotVRPView.cs</DependentUpon>
    126126    </Compile>
     127    <Compile Include="VRPImportDialog.cs">
     128      <SubType>Form</SubType>
     129    </Compile>
     130    <Compile Include="VRPImportDialog.Designer.cs">
     131      <DependentUpon>VRPImportDialog.cs</DependentUpon>
     132    </Compile>
    127133    <Compile Include="VRPProblemInstanceView.cs">
    128134      <SubType>UserControl</SubType>
  • branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.4/VehicleRoutingProblemView.Designer.cs

    r4362 r4860  
    2525    private void InitializeComponent() {
    2626      this.importButton = new System.Windows.Forms.Button();
    27       this.importButton2 = new System.Windows.Forms.Button();
    28       this.importButton3 = new System.Windows.Forms.Button();
    2927      this.parameterCollectionView = new HeuristicLab.Core.Views.ParameterCollectionView();
    3028      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
     
    3836      // importButton
    3937      //
     38      this.importButton.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     39                  | System.Windows.Forms.AnchorStyles.Right)));
    4040      this.importButton.Location = new System.Drawing.Point(0, 55);
    4141      this.importButton.Name = "importButton";
    42       this.importButton.Size = new System.Drawing.Size(139, 23);
     42      this.importButton.Size = new System.Drawing.Size(490, 23);
    4343      this.importButton.TabIndex = 5;
    44       this.importButton.Text = "Import from Solomon";
     44      this.importButton.Text = "Import";
    4545      this.importButton.UseVisualStyleBackColor = true;
    4646      this.importButton.Click += new System.EventHandler(this.importButton_Click);
    47       //
    48       // importButton2
    49       //
    50       this.importButton2.Location = new System.Drawing.Point(145, 55);
    51       this.importButton2.Name = "importButton2";
    52       this.importButton2.Size = new System.Drawing.Size(126, 23);
    53       this.importButton2.TabIndex = 7;
    54       this.importButton2.Text = "Import from TSPLib";
    55       this.importButton2.UseVisualStyleBackColor = true;
    56       this.importButton2.Click += new System.EventHandler(this.importButton2_Click);
    57       //
    58       // importButton3
    59       //
    60       this.importButton3.Location = new System.Drawing.Point(277, 55);
    61       this.importButton3.Name = "importButton3";
    62       this.importButton3.Size = new System.Drawing.Size(131, 23);
    63       this.importButton3.TabIndex = 8;
    64       this.importButton3.Text = "Import from ORLib";
    65       this.importButton3.UseVisualStyleBackColor = true;
    66       this.importButton3.Click += new System.EventHandler(this.importButton3_Click);
    6747      //
    6848      // parameterCollectionView
     
    8363      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    8464      this.Controls.Add(this.parameterCollectionView);
    85       this.Controls.Add(this.importButton3);
    86       this.Controls.Add(this.importButton2);
    8765      this.Controls.Add(this.importButton);
    8866      this.Name = "VehicleRoutingProblemView";
    8967      this.Size = new System.Drawing.Size(490, 352);
    9068      this.Controls.SetChildIndex(this.importButton, 0);
    91       this.Controls.SetChildIndex(this.importButton2, 0);
    92       this.Controls.SetChildIndex(this.importButton3, 0);
     69      this.Controls.SetChildIndex(this.parameterCollectionView, 0);
    9370      this.Controls.SetChildIndex(this.nameTextBox, 0);
    9471      this.Controls.SetChildIndex(this.nameLabel, 0);
    9572      this.Controls.SetChildIndex(this.descriptionLabel, 0);
    9673      this.Controls.SetChildIndex(this.descriptionTextBox, 0);
    97       this.Controls.SetChildIndex(this.parameterCollectionView, 0);
    9874      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    9975      this.ResumeLayout(false);
     
    10581
    10682    private System.Windows.Forms.Button importButton;
    107     private System.Windows.Forms.Button importButton2;
    108     private System.Windows.Forms.Button importButton3;
    10983    private Core.Views.ParameterCollectionView parameterCollectionView;
    11084  }
  • branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.4/VehicleRoutingProblemView.cs

    r4362 r4860  
    2626using HeuristicLab.Core.Views;
    2727using HeuristicLab.Core;
     28using HeuristicLab.PluginInfrastructure;
    2829
    2930namespace HeuristicLab.Problems.VehicleRouting.Views {
     
    3132  [Content(typeof(VehicleRoutingProblem), true)]
    3233  public partial class VehicleRoutingProblemView : NamedItemView {
     34    private VRPImportDialog vrpImportDialog;
     35
    3336    public new VehicleRoutingProblem Content {
    3437      get { return (VehicleRoutingProblem)base.Content; }
     
    5962      base.SetEnabledStateOfControls();
    6063      parameterCollectionView.Enabled = Content != null;
    61       importButton.Enabled = importButton2.Enabled = importButton3.Enabled = Content != null && !ReadOnly;
     64      importButton.Enabled = Content != null && !ReadOnly;
    6265    }
    6366
    6467    private void importButton_Click(object sender, EventArgs e) {
    65       OpenFileDialog dialog = new OpenFileDialog();
    66       dialog.Filter = "Solomon files (*.txt)|*.txt";
     68      if (vrpImportDialog == null) vrpImportDialog = new VRPImportDialog();
    6769
    68       if (dialog.ShowDialog() == DialogResult.OK) {
    69         Content.ImportFromSolomon(dialog.FileName);
     70      if (vrpImportDialog.ShowDialog(this) == DialogResult.OK) {
     71        try {
     72          switch (vrpImportDialog.Format) {
     73            case VRPFormat.TSPLib:
     74              Content.ImportFromTSPLib(vrpImportDialog.VRPFileName);
     75              break;
     76
     77            case VRPFormat.Solomon:
     78              Content.ImportFromSolomon(vrpImportDialog.VRPFileName);
     79              break;
     80
     81            case VRPFormat.ORLib:
     82              Content.ImportFromORLib(vrpImportDialog.VRPFileName);
     83              break;
     84          }
     85
     86          if (!string.IsNullOrEmpty(vrpImportDialog.TourFileName))
     87            Content.ImportSolution(vrpImportDialog.TourFileName);
     88        }
     89        catch (Exception ex) {
     90          ErrorHandling.ShowErrorDialog(this, ex);
     91        }
    7092      }
    71     }
    72 
    73     private void importButton2_Click(object sender, EventArgs e) {
    74       OpenFileDialog dialog = new OpenFileDialog();
    75       dialog.Filter = "TSPLib files (*.vrp)|*.vrp";
    76 
    77       if (dialog.ShowDialog() == DialogResult.OK) {
    78         Content.ImportFromTSPLib(dialog.FileName);
    79       }
    80     }
    81 
    82     private void importButton3_Click(object sender, EventArgs e) {
    83       OpenFileDialog dialog = new OpenFileDialog();
    84       dialog.Filter = "ORLib files (*.txt)|*.txt";
    85 
    86       if (dialog.ShowDialog() == DialogResult.OK) {
    87         Content.ImportFromORLib(dialog.FileName);
    88       }
    89     }   
     93    } 
    9094  }
    9195}
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Analyzer/BestSolution/BestVRPSolutionAnalyzer.cs

    r4752 r4860  
    6262    }
    6363
     64    public LookupParameter<DoubleValue> BestKnownQualityParameter {
     65      get { return (LookupParameter<DoubleValue>)Parameters["BestKnownQuality"]; }
     66    }
     67    public LookupParameter<VRPSolution> BestKnownSolutionParameter {
     68      get { return (LookupParameter<VRPSolution>)Parameters["BestKnownSolution"]; }
     69    }
     70
    6471    [StorableConstructor]
    6572    private BestVRPSolutionAnalyzer(bool deserializing) : base(deserializing) { }
     
    6976        Parameters.Add(new LookupParameter<IVRPProblemInstance>("ProblemInstance", "The problem instance."));
    7077        Parameters.Add(new ScopeTreeLookupParameter<IVRPEncoding>("VRPTours", "The VRP tours which should be evaluated."));
     78
     79        Parameters.Add(new LookupParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this VRP instance."));
     80        Parameters.Add(new LookupParameter<VRPSolution>("BestKnownSolution", "The best known solution of this VRP instance."));
    7181
    7282        Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The qualities of the VRP solutions which should be analyzed."));
     
    8696    }
    8797
     98    [StorableHook(HookType.AfterDeserialization)]
     99    private void AfterDeserializationHook() {
     100      #region Backwards Compatibility
     101      if (!Parameters.ContainsKey("BestKnownQuality")) {
     102        Parameters.Add(new LookupParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this VRP instance."));
     103      }
     104      if (!Parameters.ContainsKey("BestKnownSolution")) {
     105        Parameters.Add(new LookupParameter<VRPSolution>("BestKnownSolution", "The best known solution of this VRP instance."));
     106      }
     107      #endregion
     108    }
     109
    88110    public override IOperation Apply() {
    89111      IVRPProblemInstance problemInstance = ProblemInstanceParameter.ActualValue;
     
    96118
    97119      int i = qualities.Select((x, index) => new { index, x.Value }).OrderBy(x => x.Value).First().index;
     120
     121      DoubleValue bestKnownQuality = BestKnownQualityParameter.ActualValue;
    98122
    99123      IVRPEncoding best = solutions[i].Clone() as IVRPEncoding;
     
    116140      }
    117141
     142      if (bestKnownQuality == null ||
     143          qualities[i].Value < bestKnownQuality.Value) {
     144        BestKnownQualityParameter.ActualValue = new DoubleValue(qualities[i].Value);
     145        BestKnownSolutionParameter.ActualValue = (VRPSolution)solution.Clone();
     146      }
     147
    118148      return base.Apply();
    119149    }
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/HeuristicLab.Problems.VehicleRouting-3.4.csproj

    r4383 r4860  
    227227    <Compile Include="Interfaces\IVRPEncoding.cs" />
    228228    <Compile Include="Interfaces\IVRPProblemInstance.cs" />
     229    <Compile Include="SolutionParser.cs" />
    229230    <Compile Include="Variants\Capacitated\Heterogenous\IHeterogenousCapacitatedProblemInstance.cs" />
    230231    <Compile Include="Variants\Capacitated\Heterogenous\IHeterogenousCapacitatedOperator.cs" />
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/IVRPProblemInstance.cs

    r4363 r4860  
    3232    IValueParameter<IVRPEvaluator> EvaluatorParameter { get; }
    3333    IValueParameter<IVRPCreator> SolutionCreatorParameter { get; }
     34    IValueParameter<DoubleValue> BestKnownQualityParameter { get; }
     35    IValueParameter<VRPSolution> BestKnownSolutionParameter { get; }
    3436    IEnumerable<IOperator> Operators { get; }
    3537
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/SingleDepotVRP/CVRP/CVRPProblemInstance.cs

    r4752 r4860  
    7777      Parameters.Add(new ValueParameter<DoubleValue>("Capacity", "The capacity of each vehicle.", new DoubleValue(0)));
    7878      Parameters.Add(new ValueParameter<DoubleValue>("EvalOverloadPenalty", "The overload penalty considered in the evaluation.", new DoubleValue(100)));
     79
     80      AttachEventHandlers();
    7981    }
    8082
     
    8587    protected CVRPProblemInstance(CVRPProblemInstance original, Cloner cloner)
    8688      : base(original, cloner) {
     89        AttachEventHandlers();
    8790    }
     91
     92    [StorableHook(HookType.AfterDeserialization)]
     93    private void AfterDeserializationHook() {
     94      AttachEventHandlers();
     95    }
     96
     97    private void AttachEventHandlers() {
     98      CapacityParameter.ValueChanged += new EventHandler(CapacityParameter_ValueChanged);
     99      CapacityParameter.Value.ValueChanged += new EventHandler(Capacity_ValueChanged);
     100      OverloadPenaltyParameter.ValueChanged += new EventHandler(OverloadPenaltyParameter_ValueChanged);
     101      OverloadPenaltyParameter.Value.ValueChanged += new EventHandler(OverloadPenalty_ValueChanged);
     102    }
     103
     104    #region Event handlers
     105    void CapacityParameter_ValueChanged(object sender, EventArgs e) {
     106      CapacityParameter.Value.ValueChanged += new EventHandler(Capacity_ValueChanged);
     107      BestKnownSolution = null;
     108    }
     109    void Capacity_ValueChanged(object sender, EventArgs e) {
     110      BestKnownSolution = null;
     111    }
     112    void OverloadPenaltyParameter_ValueChanged(object sender, EventArgs e) {
     113      OverloadPenaltyParameter.Value.ValueChanged += new EventHandler(OverloadPenalty_ValueChanged);
     114      EvalBestKnownSolution();
     115    }
     116    void OverloadPenalty_ValueChanged(object sender, EventArgs e) {
     117      EvalBestKnownSolution();
     118    }
     119    #endregion
    88120  }
    89121}
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/SingleDepotVRP/CVRP/CVRPTW/CVRPTWProblemInstance.cs

    r4752 r4860  
    103103      Parameters.Add(new ValueParameter<DoubleValue>("EvalTimeFactor", "The time factor considered in the evaluation.", new DoubleValue(0)));
    104104      Parameters.Add(new ValueParameter<DoubleValue>("EvalTardinessPenalty", "The tardiness penalty considered in the evaluation.", new DoubleValue(100)));
     105
     106      AttachEventHandlers();
    105107    }
    106108
     
    111113    protected CVRPTWProblemInstance(CVRPTWProblemInstance original, Cloner cloner)
    112114      : base(original, cloner) {
     115        AttachEventHandlers();
    113116    }
     117
     118    [StorableHook(HookType.AfterDeserialization)]
     119    private void AfterDeserializationHook() {
     120      AttachEventHandlers();
     121    }
     122
     123    private void AttachEventHandlers() {
     124      TardinessPenaltyParameter.ValueChanged += new EventHandler(TardinessPenaltyParameter_ValueChanged);
     125      TardinessPenaltyParameter.Value.ValueChanged += new EventHandler(TardinessPenalty_ValueChanged);
     126      TimeFactorParameter.ValueChanged += new EventHandler(TimeFactorParameter_ValueChanged);
     127      TimeFactorParameter.Value.ValueChanged += new EventHandler(TimeFactor_ValueChanged);
     128    }
     129
     130    #region Event handlers
     131    void TardinessPenaltyParameter_ValueChanged(object sender, EventArgs e) {
     132      TardinessPenaltyParameter.Value.ValueChanged += new EventHandler(TardinessPenalty_ValueChanged);
     133      EvalBestKnownSolution();
     134    }
     135    void TardinessPenalty_ValueChanged(object sender, EventArgs e) {
     136      EvalBestKnownSolution();
     137    }
     138    void TimeFactorParameter_ValueChanged(object sender, EventArgs e) {
     139      TimeFactorParameter.Value.ValueChanged += new EventHandler(TimeFactor_ValueChanged);
     140      EvalBestKnownSolution();
     141    }
     142    void TimeFactor_ValueChanged(object sender, EventArgs e) {
     143      EvalBestKnownSolution();
     144    }
     145    #endregion
    114146  }
    115147}
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/VRPProblemInstance.cs

    r4752 r4860  
    7777    }
    7878
     79    protected OptionalValueParameter<DoubleValue> BestKnownQualityParameter {
     80      get { return (OptionalValueParameter<DoubleValue>)Parameters["BestKnownQuality"]; }
     81    }
     82    protected OptionalValueParameter<VRPSolution> BestKnownSolutionParameter {
     83      get { return (OptionalValueParameter<VRPSolution>)Parameters["BestKnownSolution"]; }
     84    }
     85
     86    IValueParameter<DoubleValue> IVRPProblemInstance.BestKnownQualityParameter {
     87      get { return BestKnownQualityParameter; }
     88    }
     89
     90    IValueParameter<VRPSolution> IVRPProblemInstance.BestKnownSolutionParameter {
     91      get { return BestKnownSolutionParameter; }
     92    }
     93
    7994    public DoubleMatrix Coordinates {
    8095      get { return CoordinatesParameter.Value; }
     
    109124      get { return DistanceFactorParameter.Value; }
    110125      set { DistanceFactorParameter.Value = value; }
     126    }
     127
     128    public DoubleValue BestKnownQuality {
     129      get { return BestKnownQualityParameter.Value; }
     130      set { BestKnownQualityParameter.Value = value; }
     131    }
     132    public VRPSolution BestKnownSolution {
     133      get { return BestKnownSolutionParameter.Value; }
     134      set { BestKnownSolutionParameter.Value = value; }
    111135    }
    112136
     
    171195    public double Evaluate(Tour tour) {
    172196      return EvaluatorParameter.Value.Evaluate(this, tour).Quality;
     197    }
     198
     199    protected void EvalBestKnownSolution() {
     200      if (BestKnownSolution != null) {
     201        //call evaluator
     202        BestKnownQuality = new DoubleValue(Evaluate(BestKnownSolution.Solution));
     203        BestKnownSolution.Quality = BestKnownQuality;
     204      } else {
     205        BestKnownQuality = null;
     206      }
    173207    }
    174208
     
    192226      Parameters.Add(new ValueParameter<IVRPCreator>("SolutionCreator", "The operator which should be used to create new VRP solutions.", Creator));
    193227      Parameters.Add(new ValueParameter<IVRPEvaluator>("Evaluator", "The operator which should be used to evaluate VRP solutions.", Evaluator));
     228
     229      Parameters.Add(new OptionalValueParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this VRP instance."));
     230      Parameters.Add(new OptionalValueParameter<VRPSolution>("BestKnownSolution", "The best known solution of this VRP instance."));
     231
     232      AttachEventHandlers();
    194233    }
    195234
    196235    protected VRPProblemInstance(VRPProblemInstance original, Cloner cloner)
    197236      : base(original, cloner) {
    198     }
     237        AttachEventHandlers();
     238    }
     239
     240    [StorableHook(HookType.AfterDeserialization)]
     241    private void AfterDeserializationHook() {
     242      #region Backwards Compatibility
     243      if (!Parameters.ContainsKey("BestKnownSolution")) {
     244        Parameters.Add(new OptionalValueParameter<VRPSolution>("BestKnownSolution", "The best known solution of this TSP instance."));
     245      }
     246      #endregion
     247     
     248      AttachEventHandlers();
     249    }
     250
     251    private void AttachEventHandlers() {
     252      BestKnownSolutionParameter.ValueChanged += new EventHandler(BestKnownSolutionParameter_ValueChanged);
     253      DistanceFactorParameter.ValueChanged += new EventHandler(DistanceFactorParameter_ValueChanged);
     254      DistanceFactorParameter.Value.ValueChanged += new EventHandler(DistanceFactor_ValueChanged);
     255      FleetUsageFactorParameter.ValueChanged += new EventHandler(FleetUsageFactorParameter_ValueChanged);
     256      FleetUsageFactorParameter.Value.ValueChanged += new EventHandler(FleetUsageFactor_ValueChanged);
     257      DistanceMatrixParameter.ValueChanged += new EventHandler(DistanceMatrixParameter_ValueChanged);
     258      if (DistanceMatrix != null) {
     259        DistanceMatrix.ItemChanged += new EventHandler<EventArgs<int, int>>(DistanceMatrix_ItemChanged);
     260        DistanceMatrix.Reset += new EventHandler(DistanceMatrix_Reset);
     261      }
     262      UseDistanceMatrixParameter.ValueChanged += new EventHandler(UseDistanceMatrixParameter_ValueChanged);
     263      UseDistanceMatrix.ValueChanged += new EventHandler(UseDistanceMatrix_ValueChanged);
     264    }
     265
     266    #region Event handlers
     267    void BestKnownSolutionParameter_ValueChanged(object sender, EventArgs e) {
     268      EvalBestKnownSolution();
     269    }
     270    void DistanceFactorParameter_ValueChanged(object sender, EventArgs e) {
     271      DistanceFactorParameter.Value.ValueChanged += new EventHandler(DistanceFactor_ValueChanged);
     272      EvalBestKnownSolution();
     273    }
     274    void DistanceFactor_ValueChanged(object sender, EventArgs e) {
     275      EvalBestKnownSolution();
     276    }
     277    void FleetUsageFactorParameter_ValueChanged(object sender, EventArgs e) {
     278      FleetUsageFactorParameter.Value.ValueChanged += new EventHandler(FleetUsageFactor_ValueChanged);
     279      EvalBestKnownSolution();
     280    }
     281    void FleetUsageFactor_ValueChanged(object sender, EventArgs e) {
     282      EvalBestKnownSolution();
     283    }
     284    void DistanceMatrixParameter_ValueChanged(object sender, EventArgs e) {
     285      if (DistanceMatrix != null) {
     286        DistanceMatrix.ItemChanged += new EventHandler<EventArgs<int, int>>(DistanceMatrix_ItemChanged);
     287        DistanceMatrix.Reset += new EventHandler(DistanceMatrix_Reset);
     288      }
     289      EvalBestKnownSolution();
     290    }
     291    void DistanceMatrix_Reset(object sender, EventArgs e) {
     292      EvalBestKnownSolution();
     293    }
     294    void DistanceMatrix_ItemChanged(object sender, EventArgs<int, int> e) {
     295      EvalBestKnownSolution();
     296    }
     297    void UseDistanceMatrixParameter_ValueChanged(object sender, EventArgs e) {
     298      UseDistanceMatrix.ValueChanged += new EventHandler(UseDistanceMatrix_ValueChanged);
     299      EvalBestKnownSolution();
     300    }
     301    void UseDistanceMatrix_ValueChanged(object sender, EventArgs e) {
     302      EvalBestKnownSolution();
     303    }
     304    #endregion
    199305  }
    200306}
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/VehicleRoutingProblem.cs

    r4752 r4860  
    6464      get { return BestKnownQualityParameter; }
    6565    }
     66    public OptionalValueParameter<VRPSolution> BestKnownSolutionParameter {
     67      get { return (OptionalValueParameter<VRPSolution>)Parameters["BestKnownSolution"]; }
     68    }
    6669    public IValueParameter<IVRPCreator> SolutionCreatorParameter {
    6770      get { return (IValueParameter<IVRPCreator>)Parameters["SolutionCreator"]; }
     
    8285      get { return ProblemInstanceParameter.Value; }
    8386      set { ProblemInstanceParameter.Value = value; }
     87    }
     88
     89    public VRPSolution BestKnownSolution {
     90      get { return BestKnownSolutionParameter.Value; }
     91      set { BestKnownSolutionParameter.Value = value; }
    8492    }
    8593
     
    111119      Parameters.Add(new ValueParameter<IVRPProblemInstance>("ProblemInstance", "The VRP problem instance"));
    112120      Parameters.Add(new OptionalValueParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this VRP instance."));
     121      Parameters.Add(new OptionalValueParameter<VRPSolution>("BestKnownSolution", "The best known solution of this VRP instance."));
    113122
    114123      operators = new List<IOperator>();
     
    172181        Parameters.Remove("SolutionCreator");
    173182
     183      if (Parameters.ContainsKey("BestKnownSolution"))
     184        Parameters.Remove("BestKnownSolution");
     185
     186      if (Parameters.ContainsKey("BestKnownQuality"))
     187        Parameters.Remove("BestKnownQuality");
     188
     189
    174190      if (ProblemInstance != null) {
    175191        ProblemInstance.SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged);
     
    177193        Parameters.Add(ProblemInstance.EvaluatorParameter);
    178194        Parameters.Add(ProblemInstance.SolutionCreatorParameter);
     195
     196        Parameters.Add(ProblemInstance.BestKnownQualityParameter);
     197        Parameters.Add(ProblemInstance.BestKnownSolutionParameter);
    179198      }
    180199    }
     
    251270      int problemSize = parser.Demands.Length;
    252271
    253       if (parser.Depot != 1)
    254         throw new Exception("Invalid depot specification");
    255 
    256       if (parser.WeightType != TSPLIBParser.TSPLIBEdgeWeightType.EUC_2D)
    257         throw new Exception("Invalid weight type");
     272      if (parser.Depot != 1) {
     273        ErrorHandling.ShowErrorDialog(new Exception("Invalid depot specification"));
     274        return;
     275      }
     276
     277      if (parser.WeightType != TSPLIBParser.TSPLIBEdgeWeightType.EUC_2D)  {
     278        ErrorHandling.ShowErrorDialog(new Exception("Invalid weight type"));
     279        return;
     280      }
    258281
    259282      CVRPTWProblemInstance problem = new CVRPTWProblemInstance();
     
    337360      this.ProblemInstance = problem;
    338361    }
     362
     363    public void ImportSolution(string solutionFileName) {
     364      SolutionParser parser = new SolutionParser(solutionFileName);
     365      parser.Parse();
     366
     367      HeuristicLab.Problems.VehicleRouting.Encodings.Potvin.PotvinEncoding encoding = new Encodings.Potvin.PotvinEncoding(ProblemInstance);
     368
     369      int cities = 0;
     370      foreach (List<int> route in parser.Routes) {
     371        Tour tour = new Tour();
     372        tour.Stops.AddRange(route);
     373        cities += tour.Stops.Count;
     374
     375        encoding.Tours.Add(tour);
     376      }
     377
     378      if (cities != ProblemInstance.Coordinates.Rows - 1)
     379        ErrorHandling.ShowErrorDialog(new Exception("The optimal solution does not seem to correspond with the problem data"));
     380      else {
     381        VRPSolution solution = new VRPSolution(ProblemInstance, encoding, new DoubleValue(0));
     382        ProblemInstance.BestKnownSolutionParameter.Value = solution;
     383      }
     384    }
    339385  }
    340386}
Note: See TracChangeset for help on using the changeset viewer.