Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/15/17 12:14:18 (6 years ago)
Author:
abeham
Message:

#2747: worked on the CFSAP

  • merged HeuristicLab.Problems.Instances from trunk
  • updated best known qualities
  • reduced memory footprint of run
  • added convergence graph result to solving strategy
Location:
branches/CFSAP/HeuristicLab.Problems.Scheduling.CFSAP/3.3
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/CFSAP/HeuristicLab.Problems.Scheduling.CFSAP/3.3/CFSAP.cs

    r15460 r15472  
    6464      : base(original, cloner) {}
    6565    public CFSAP() {
    66       Parameters.Add(new ValueParameter<IntMatrix>("ProcessingTimes", "The processing times of each machine and each job."));
    67       Parameters.Add(new ValueParameter<ItemList<IntMatrix>>("SetupTimes", "The sequence dependent set up times of each machine and between all jobs."));
     66      Parameters.Add(new ValueParameter<IntMatrix>("ProcessingTimes", "The processing times of each machine and each job.") { GetsCollected = false });
     67      Parameters.Add(new ValueParameter<ItemList<IntMatrix>>("SetupTimes", "The sequence dependent set up times of each machine and between all jobs.") { GetsCollected = false });
    6868
    6969      ProcessingTimesParameter.Value = new IntMatrix(new int[,] {
     
    9090      Encoding.Add(new PermutationEncoding("sequence", 5, PermutationTypes.RelativeDirected));
    9191      Encoding.Add(new BinaryVectorEncoding("assignment", 5));
     92
     93      EncodingParameter.GetsCollected = false;
     94      foreach (var param in ((IEncoding)Encoding).Parameters.OfType<IValueParameter>().ToList()) {
     95        param.GetsCollected = false;
     96      }
    9297
    9398      Operators.RemoveAll(x => x is SingleObjectiveMoveGenerator);
  • branches/CFSAP/HeuristicLab.Problems.Scheduling.CFSAP/3.3/HeuristicLab.Problems.Scheduling.CFSAP-3.3.csproj

    r15460 r15472  
    7676      <SpecificVersion>False</SpecificVersion>
    7777      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Encodings.PermutationEncoding-3.3.dll</HintPath>
     78      <Private>False</Private>
     79    </Reference>
     80    <Reference Include="HeuristicLab.Operators-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     81      <SpecificVersion>False</SpecificVersion>
     82      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Operators-3.3.dll</HintPath>
    7883      <Private>False</Private>
    7984    </Reference>
  • branches/CFSAP/HeuristicLab.Problems.Scheduling.CFSAP/3.3/MultiNestCFSAP.cs

    r15460 r15472  
    4141      : base(original, cloner) { }
    4242    public MultiNestCFSAP() {
    43       Parameters.Add(new ValueParameter<ItemList<IntMatrix>>("ProcessingTimes", "The processing times of each nest, each machine, each job."));
    44       Parameters.Add(new ValueParameter<ItemList<ItemList<IntMatrix>>>("SetupTimes", "The sequence dependent set up times for each nest, each machine, and each job to each other."));
     43      Parameters.Add(new ValueParameter<ItemList<IntMatrix>>("ProcessingTimes", "The processing times of each nest, each machine, each job.") { GetsCollected = false });
     44      Parameters.Add(new ValueParameter<ItemList<ItemList<IntMatrix>>>("SetupTimes", "The sequence dependent set up times for each nest, each machine, and each job to each other.") { GetsCollected = false });
    4545
    4646      ProcessingTimesParameter.Value = new ItemList<IntMatrix>() {
     
    6969      Encoding.Add(new PermutationEncoding("seq0", 5, PermutationTypes.RelativeDirected));
    7070      Encoding.Add(new BinaryVectorEncoding("assign0", 5));
     71
     72      EncodingParameter.GetsCollected = false;
     73      foreach (var param in ((IEncoding)Encoding).Parameters.OfType<IValueParameter>().ToList()) {
     74        param.GetsCollected = false;
     75      }
    7176
    7277      Operators.RemoveAll(x => x is SingleObjectiveMoveGenerator);
     
    124129        Encoding.Add(new BinaryVectorEncoding("assign" + n, data.Jobs));
    125130      }
     131
     132      #region Reduce run size by removing collected parameters
     133      foreach (var param in ((IEncoding)Encoding).Parameters.OfType<IValueParameter>().ToList())
     134        param.GetsCollected = false;
     135
     136      var solCreator = SolutionCreator as IParameterizedItem;
     137      if (solCreator != null) {
     138        foreach (var param in solCreator.Parameters.OfType<IValueParameter>().ToList()) {
     139          param.GetsCollected = false;
     140          var secondLevel = param.Value as IParameterizedItem;
     141          if (secondLevel != null) {
     142            foreach (var secondLevelParam in secondLevel.Parameters.OfType<IValueParameter>().ToList())
     143              secondLevelParam.GetsCollected = false;
     144          }
     145        }
     146      }
     147      #endregion
     148
    126149      Name = data.Name;
    127150      Description = data.Description;
  • branches/CFSAP/HeuristicLab.Problems.Scheduling.CFSAP/3.3/MultiNestCFSAPSolvingStrategy.cs

    r15460 r15472  
    33using System.Linq;
    44using System.Threading;
     5using HeuristicLab.Analysis;
    56using HeuristicLab.Common;
    67using HeuristicLab.Core;
     
    3233    }
    3334
     35
     36    public IFixedValueParameter<StringValue> EvaluatedSolutionsNameParameter {
     37      get { return (IFixedValueParameter<StringValue>)Parameters["EvaluatedSolutionsName"]; }
     38    }
     39
     40    public IAlgorithm Solver {
     41      get { return SolverParameter.Value; }
     42      set { SolverParameter.Value = value; }
     43    }
     44
    3445    public TimeSpan MaximumRuntime {
    3546      get { return MaximumRuntimeParameter.Value.Value; }
    3647      set { MaximumRuntimeParameter.Value.Value = value; }
     48    }
     49
     50    public string EvaluatedSolutionsName {
     51      get { return EvaluatedSolutionsNameParameter.Value.Value; }
     52      set { EvaluatedSolutionsNameParameter.Value.Value = value; }
    3753    }
    3854
     
    4763      if (original.algorithmsResults != null)
    4864        algorithmsResults = cloner.Clone(original.algorithmsResults);
     65      if (original.qualityPerClock != null)
     66        qualityPerClock = cloner.Clone(original.qualityPerClock);
     67      if (original.qualityPerEvaluations != null)
     68        qualityPerEvaluations = cloner.Clone(original.qualityPerEvaluations);
    4969    }
    5070    public MultiNestCFSAPSolvingStrategy() {
    51       Parameters.Add(new ValueParameter<IAlgorithm>("Solver", "The actual solver template."));
     71      Parameters.Add(new ValueParameter<IAlgorithm>("Solver", "The actual solver template.") { GetsCollected = false });
    5272      Parameters.Add(new FixedValueParameter<TimeSpanValue>("MaximumRuntime", "The maximum time that the strategy should run.", new TimeSpanValue(TimeSpan.FromSeconds(60))));
     73      Parameters.Add(new FixedValueParameter<StringValue>("EvaluatedSolutionsName", "The name of the result that shows the number of evaluated solutions by the actual solver.", new StringValue("EvaluatedSolutions")));
    5374    }
    5475   
    5576    public override IDeepCloneable Clone(Cloner cloner) {
    5677      return new MultiNestCFSAPSolvingStrategy(this, cloner);
     78    }
     79
     80
     81    [StorableHook(HookType.AfterDeserialization)]
     82    private void AfterDeserialization() {
     83      if (!Parameters.ContainsKey("EvaluatedSolutionsName"))
     84        Parameters.Add(new FixedValueParameter<StringValue>("EvaluatedSolutionsName", "The name of the result that shows the number of evaluated solutions by the actual solver.", new StringValue("EvaluatedSolutions")));
    5785    }
    5886
     
    6391    [Storable]
    6492    private ResultCollection algorithmsResults;
     93    [Storable]
     94    private IndexedDataTable<double> qualityPerClock;
     95    [Storable]
     96    private IndexedDataTable<double> qualityPerEvaluations;
    6597
    6698    protected override void OnPrepared() {
     
    68100      algorithms = null;
    69101      qualities = null;
     102      algorithmsResults = null;
     103      qualityPerClock = null;
     104      qualityPerEvaluations = null;
    70105    }
    71106
     
    89124      var min = worst.Quality;
    90125
     126      qualityPerClock = new IndexedDataTable<double>("Quality per Clock");
     127      var qpcRow = new IndexedDataRow<double>("First-hit Graph");
     128      qpcRow.Values.Add(Tuple.Create(ExecutionTime.TotalSeconds, (double)min));
     129      qpcRow.Values.Add(Tuple.Create(ExecutionTime.TotalSeconds, (double)min));
     130      qualityPerClock.Rows.Add(qpcRow);
     131      qualityPerEvaluations = new IndexedDataTable<double>("Quality per Evaluations");
     132      var qpeRow = new IndexedDataRow<double>("First-hit Graph");
     133      qualityPerEvaluations.Rows.Add(qpeRow);
     134      double evaluations = GetEvaluatedSolutions();
     135      qpeRow.Values.Add(Tuple.Create((double)evaluations, (double)min));
     136      qpeRow.Values.Add(Tuple.Create((double)evaluations, (double)min));
     137
    91138      Results.Add(new Result("Nest with maximum T", new IntValue(worst.Index + 1)));
    92139      Results.Add(new Result("Maximum T", new IntValue(min)));
     140      Results.Add(new Result("BestQuality", new DoubleValue(min)));
    93141      Results.Add(new Result("Best Solution Found At", new TimeSpanValue(ExecutionTime)));
    94142      Results.Add(new Result("Delta T", new PercentValue((min - Problem.BestKnownQuality) / Problem.BestKnownQuality)));
    95143      Results.Add(new Result("Nest Results", algorithmsResults));
     144      Results.Add(new Result("QualityPerClock", qualityPerClock));
     145      Results.Add(new Result("QualityPerEvaluations", qualityPerEvaluations));
    96146
    97147      base.Initialize(cancellationToken);
     148    }
     149
     150    private double GetEvaluatedSolutions() {
     151      if (algorithmsResults == null) throw new InvalidOperationException("Strategy has not been started yet.");
     152      return algorithmsResults.Select(x => {
     153        IResult res;
     154        if (((ResultCollection)x.Value).TryGetValue(EvaluatedSolutionsName, out res)) {
     155          var itm = res.Value;
     156          if (itm is IntValue) return ((IntValue)itm).Value;
     157          else if (itm is DoubleValue) return ((DoubleValue)itm).Value;
     158        }
     159        throw new InvalidOperationException("No result " + EvaluatedSolutionsName + " in the collection of " + x.Name);
     160      }).Sum();
    98161    }
    99162
     
    106169        qualities[worst.Index] = (int)((DoubleValue)algorithms[worst.Index].Results["BestQuality"].Value).Value;
    107170        worst = qualities.Select((v, i) => new { Index = i, Quality = v }).MaxItems(x => x.Quality).First();
     171
     172        var evaluations = GetEvaluatedSolutions();
     173        var time = ExecutionTime.TotalSeconds;
     174        var qpcRow = qualityPerClock.Rows.First();
     175        var qpeRow = qualityPerEvaluations.Rows.First();
     176        qpcRow.Values[qpcRow.Values.Count - 1] = Tuple.Create(time, (double)min);
     177        qpeRow.Values[qpeRow.Values.Count - 1] = Tuple.Create(evaluations, (double)min);
     178
    108179        if (worst.Quality < min) {
    109180          min = worst.Quality;
    110           Results["Nest with maximum T"].Value = new IntValue(worst.Index + 1);
    111           Results["Maximum T"].Value = new IntValue(min);
    112           Results["Best Solution Found At"].Value = new TimeSpanValue(ExecutionTime);
    113           Results["Delta T"].Value = new PercentValue((min - Problem.BestKnownQuality) / Problem.BestKnownQuality);
     181          ((IntValue)Results["Nest with maximum T"].Value).Value = worst.Index + 1;
     182          ((IntValue)Results["Maximum T"].Value).Value = min;
     183          ((DoubleValue)Results["BestQuality"].Value).Value = min;
     184          ((TimeSpanValue)Results["Best Solution Found At"].Value).Value = TimeSpan.FromSeconds(time);
     185          ((PercentValue)Results["Delta T"].Value).Value = (min - Problem.BestKnownQuality) / Problem.BestKnownQuality;
     186          qpcRow.Values.Add(Tuple.Create(time, (double)min));
     187          qpeRow.Values.Add(Tuple.Create(evaluations, (double)min));
    114188        }
     189
    115190        if (cancellationToken.IsCancellationRequested) return;
    116191      }
  • branches/CFSAP/HeuristicLab.Problems.Scheduling.CFSAP/3.3/Plugin.cs.frame

    r14757 r15472  
    3030  [PluginDependency("HeuristicLab.Collections", "3.3")]
    3131  [PluginDependency("HeuristicLab.Common", "3.3")]
    32   [PluginDependency("HeuristicLab.Common.Resources", "3.3")]
    3332  [PluginDependency("HeuristicLab.Core", "3.3")]
    3433  [PluginDependency("HeuristicLab.Data", "3.3")]
     
    3837  [PluginDependency("HeuristicLab.Parameters", "3.3")]
    3938  [PluginDependency("HeuristicLab.Persistence", "3.3")]
    40   [PluginDependency("HeuristicLab.SimSharp", "3.0.9")]
     39  [PluginDependency("HeuristicLab.Problems.Instances", "3.3")]
    4140  public class HeuristicLabProblemsSchedulingCFSAPPlugin : PluginBase  {
    4241  }
Note: See TracChangeset for help on using the changeset viewer.