Free cookie consent management tool by TermsFeed Policy Generator

Changeset 6177 for branches/Scheduling


Ignore:
Timestamp:
05/10/11 17:25:35 (13 years ago)
Author:
jhelm
Message:

#1329: Implemented PriorityRulesVector based encoding and added new operators to the JSMEncoding. Added Gantt-Charts for visualization of schedules and problems.

Location:
branches/Scheduling
Files:
32 added
6 deleted
28 edited

Legend:

Unmodified
Added
Removed
  • branches/Scheduling/HeuristicLab.Problems.Scheduling.Views/3.3/HeuristicLab.Problems.Scheduling.Views-3.3.csproj

    r6121 r6177  
    3636    <Reference Include="System.Drawing" />
    3737    <Reference Include="System.Windows.Forms" />
     38    <Reference Include="System.Windows.Forms.DataVisualization" />
    3839    <Reference Include="System.Xml.Linq" />
    3940    <Reference Include="System.Data.DataSetExtensions" />
     
    4344  </ItemGroup>
    4445  <ItemGroup>
     46    <Compile Include="GanttChart.cs">
     47      <SubType>UserControl</SubType>
     48    </Compile>
     49    <Compile Include="GanttChart.Designer.cs">
     50      <DependentUpon>GanttChart.cs</DependentUpon>
     51    </Compile>
    4552    <Compile Include="JobShopSchedulingProblemView.cs">
    4653      <SubType>UserControl</SubType>
     
    154161      <Name>HeuristicLab.Problems.VehicleRouting-3.3</Name>
    155162    </ProjectReference>
    156   </ItemGroup>
    157   <ItemGroup>
     163    <ProjectReference Include="..\..\HeuristicLab.Visualization.ChartControlsExtensions\3.3\HeuristicLab.Visualization.ChartControlsExtensions-3.3.csproj">
     164      <Project>{315BDA09-3F4F-49B3-9790-B37CFC1C5750}</Project>
     165      <Name>HeuristicLab.Visualization.ChartControlsExtensions-3.3</Name>
     166    </ProjectReference>
     167  </ItemGroup>
     168  <ItemGroup>
     169    <EmbeddedResource Include="GanttChart.resx">
     170      <DependentUpon>GanttChart.cs</DependentUpon>
     171    </EmbeddedResource>
    158172    <EmbeddedResource Include="JobShopSchedulingProblemView.resx">
    159173      <DependentUpon>JobShopSchedulingProblemView.cs</DependentUpon>
  • branches/Scheduling/HeuristicLab.Problems.Scheduling.Views/3.3/JobShopSchedulingProblemView.Designer.cs

    r6121 r6177  
    2929      this.tabPage1 = new System.Windows.Forms.TabPage();
    3030      this.tabPage2 = new System.Windows.Forms.TabPage();
    31       this.scheduleView1 = new HeuristicLab.Problems.Scheduling.Views.ScheduleView();
     31      this.ganttChart = new HeuristicLab.Problems.Scheduling.Views.GanttChart();
    3232      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    3333      this.tabControl1.SuspendLayout();
     
    9898      // tabPage2
    9999      //
    100       this.tabPage2.Controls.Add(this.scheduleView1);
     100      this.tabPage2.Controls.Add(this.ganttChart);
    101101      this.tabPage2.Location = new System.Drawing.Point(4, 22);
    102102      this.tabPage2.Name = "tabPage2";
     
    107107      this.tabPage2.UseVisualStyleBackColor = true;
    108108      //
    109       // scheduleView1
     109      // ganttChart
    110110      //
    111       this.scheduleView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    112                   | System.Windows.Forms.AnchorStyles.Left)
    113                   | System.Windows.Forms.AnchorStyles.Right)));
    114       this.scheduleView1.Caption = "Schedule View";
    115       this.scheduleView1.Content = null;
    116       this.scheduleView1.Location = new System.Drawing.Point(0, 6);
    117       this.scheduleView1.Name = "scheduleView1";
    118       this.scheduleView1.ReadOnly = false;
    119       this.scheduleView1.Size = new System.Drawing.Size(716, 381);
    120       this.scheduleView1.TabIndex = 0;
     111      this.ganttChart.Location = new System.Drawing.Point(0, 3);
     112      this.ganttChart.Name = "ganttChart";
     113      this.ganttChart.Size = new System.Drawing.Size(716, 384);
     114      this.ganttChart.TabIndex = 0;
    121115      //
    122116      // JobShopSchedulingProblemView
     
    149143    private System.Windows.Forms.TabPage tabPage1;
    150144    private System.Windows.Forms.TabPage tabPage2;
    151     private ScheduleView scheduleView1;
     145    private GanttChart ganttChart;
    152146  }
    153147}
  • branches/Scheduling/HeuristicLab.Problems.Scheduling.Views/3.3/JobShopSchedulingProblemView.cs

    r6121 r6177  
    2828using HeuristicLab.Parameters;
    2929using HeuristicLab.PluginInfrastructure;
     30using System.Drawing;
    3031
    3132namespace HeuristicLab.Problems.Scheduling.Views {
     
    4748      if (Content == null) {
    4849        parameterCollectionView.Content = null;
    49         scheduleView1.Content = null;
     50        ganttChart.Reset();
    5051      } else {
    5152        parameterCollectionView.Content = ((IParameterizedNamedItem)Content).Parameters;
    52         //TODO: display the current best solution in the view
     53        FillGanttChart(Content);
     54      }
     55    }
     56
     57    private void FillGanttChart(JobShopSchedulingProblem content) {
     58      //Add Jobs as Categories
     59      int jobCount = 0;
     60      Random random = new Random();
     61      foreach (JSSPJob j in content.Jobs) {
     62        foreach (JSSPTask t in content.Jobs[jobCount].Tasks) {
     63          string categoryName = "ScheduleTasks";
     64          categoryName = "Job" + t.Job.Index;
     65          ganttChart.AddCategory(categoryName, Color.FromArgb(random.Next(255), random.Next(255), random.Next(255)));
     66          ganttChart.AddData(categoryName,
     67            categoryName,
     68            t.StartTime.Value,
     69            t.EndTime.Value,
     70            "Job" + t.Job.Index + " - " + "Task#" + t.TaskNr.Value.ToString(),
     71            false);
     72        }
     73        jobCount++;
    5374      }
    5475    }
     
    7596            Content.ImportSolution(spImportDialog.OptimalScheduleFileName);
    7697           * */
     98          OnContentChanged();
    7799        }
    78100        catch (Exception ex) {
  • branches/Scheduling/HeuristicLab.Problems.Scheduling.Views/3.3/JobShopSchedulingProblemView.resx

    r6121 r6177  
    121121    <value>107, 17</value>
    122122  </metadata>
    123   <metadata name="errorProvider.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    124     <value>107, 17</value>
    125   </metadata>
    126123  <metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    127124    <value>17, 17</value>
  • branches/Scheduling/HeuristicLab.Problems.Scheduling.Views/3.3/Plugin.cs

    r6121 r6177  
    2323
    2424namespace HeuristicLab.Problems.Scheduling.Views {
    25   [Plugin("HeuristicLab.Problems.Scheduling.Views", "3.3.3.0")]
     25  [Plugin("HeuristicLab.Problems.Scheduling.Views", "3.3.3.6121")]
    2626  [PluginFile("HeuristicLab.Problems.Scheduling.Views-3.3.dll", PluginFileType.Assembly)]
    2727  public class HeuristicLabProblemsSchedulingViewsPlugin : PluginBase {
  • branches/Scheduling/HeuristicLab.Problems.Scheduling.Views/3.3/Properties/AssemblyInfo.cs

    r6121 r6177  
    5353// by using the '*' as shown below:
    5454[assembly: AssemblyVersion("3.3.0.0")]
    55 [assembly: AssemblyFileVersion("3.3.0.0")]
     55[assembly: AssemblyFileVersion("3.3.0.6121")]
  • branches/Scheduling/HeuristicLab.Problems.Scheduling.Views/3.3/ScheduleView.Designer.cs

    r6121 r6177  
    2424    /// </summary>
    2525    private void InitializeComponent() {
    26       this.parameterCollectionView = new HeuristicLab.Core.Views.ParameterCollectionView();
     26      this.ganttChart = new HeuristicLab.Problems.Scheduling.Views.GanttChart();
    2727      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    2828      this.SuspendLayout();
     
    3838      this.infoLabel.Location = new System.Drawing.Point(510, 3);
    3939      //
    40       // parameterCollectionView
     40      // ganttChart
    4141      //
    42       this.parameterCollectionView.AllowEditingOfHiddenParameters = true;
    43       this.parameterCollectionView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     42      this.ganttChart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    4443                  | System.Windows.Forms.AnchorStyles.Left)
    4544                  | System.Windows.Forms.AnchorStyles.Right)));
    46       this.parameterCollectionView.Caption = "ParameterCollection View";
    47       this.parameterCollectionView.Content = null;
    48       this.parameterCollectionView.Location = new System.Drawing.Point(6, 29);
    49       this.parameterCollectionView.Name = "parameterCollectionView";
    50       this.parameterCollectionView.ReadOnly = false;
    51       this.parameterCollectionView.Size = new System.Drawing.Size(498, 313);
    52       this.parameterCollectionView.TabIndex = 3;
     45      this.ganttChart.Location = new System.Drawing.Point(6, 22);
     46      this.ganttChart.Name = "ganttChart";
     47      this.ganttChart.Size = new System.Drawing.Size(520, 320);
     48      this.ganttChart.TabIndex = 3;
    5349      //
    5450      // ScheduleView
     
    5652      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    5753      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    58       this.Controls.Add(this.parameterCollectionView);
     54      this.Controls.Add(this.ganttChart);
    5955      this.Name = "ScheduleView";
    6056      this.Size = new System.Drawing.Size(529, 345);
    61       this.Controls.SetChildIndex(this.parameterCollectionView, 0);
     57      this.Controls.SetChildIndex(this.ganttChart, 0);
    6258      this.Controls.SetChildIndex(this.nameLabel, 0);
    6359      this.Controls.SetChildIndex(this.nameTextBox, 0);
     
    7167    #endregion
    7268
    73     private Core.Views.ParameterCollectionView parameterCollectionView;
     69    private GanttChart ganttChart;
     70
    7471  }
    7572}
  • branches/Scheduling/HeuristicLab.Problems.Scheduling.Views/3.3/ScheduleView.cs

    r6121 r6177  
    4848      base.OnContentChanged();
    4949      if (Content == null) {
    50         parameterCollectionView.Content = null;
     50        ResetGanttChart();
    5151      } else {
    52         parameterCollectionView.Content = ((IParameterizedNamedItem)Content).Parameters;
     52        FillGanttChart(Content);
     53      }
     54    }
     55
     56    private void ResetGanttChart() {
     57      ganttChart.Reset();
     58    }
     59
     60    private void FillGanttChart(Schedule content) {
     61      //Add Resources as Categories
     62      int resCount = 0;
     63      Random random = new Random ();
     64      foreach (Resource r in content.Resources) {
     65        foreach (JSSPTask t in content.Resources[resCount].Tasks) {
     66          string categoryName = "ScheduleTasks";
     67          string toolTip = "Task#" + t.TaskNr.Value.ToString();
     68          if (t is JSSPTask) {
     69            categoryName = "Job" + ((JSSPTask)t).Job.Index;
     70            toolTip = categoryName + " - " + toolTip;
     71          }
     72          ganttChart.AddCategory(categoryName, Color.FromArgb(random.Next(255), random.Next(255), random.Next(255)));
     73          ganttChart.AddData("Resource" + r.Index,
     74            categoryName,
     75            t.StartTime.Value,
     76            t.EndTime.Value,
     77            toolTip,
     78            false);
     79        }
     80        resCount++;
    5381      }
    5482    }
     
    5684    protected override void SetEnabledStateOfControls() {
    5785      base.SetEnabledStateOfControls();
    58       parameterCollectionView.Enabled = Content != null;
     86      ganttChart.Enabled = Content != null;
    5987    }
    6088  }
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Analyzers/BestSchedulingSolutionAnalyzer.cs

    r6121 r6177  
    3636  [Item("BestSchedulingSolutionAnalyzer", "An operator for analyzing the best solution of Scheduling Problems given in schedule-representation.")]
    3737  [StorableClass]
    38   public sealed class BestSchedulingSolutionAnalyzer : SchedulingOperator, IAnalyzer, IStochasticOperator {
     38  public sealed class BestSchedulingSolutionAnalyzer : JSSPOperator, IAnalyzer, IStochasticOperator {
    3939    [StorableConstructor]
    4040    private BestSchedulingSolutionAnalyzer(bool deserializing) : base(deserializing) { }
     
    6161      get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters["Quality"]; }
    6262    }
    63     public LookupParameter<JSSPEncoding> BestSolutionParameter {
    64       get { return (LookupParameter<JSSPEncoding>)Parameters["BestSolution"]; }
     63    public LookupParameter<Schedule> BestSolutionParameter {
     64      get { return (LookupParameter<Schedule>)Parameters["BestSolution"]; }
    6565    }
    6666    public ValueLookupParameter<ResultCollection> ResultsParameter {
     
    7070      get { return (LookupParameter<DoubleValue>)Parameters["BestKnownQuality"]; }
    7171    }
    72     public LookupParameter<JSSPEncoding> BestKnownSolutionParameter {
    73       get { return (LookupParameter<JSSPEncoding>)Parameters["BestKnownSolution"]; }
     72    public LookupParameter<Schedule> BestKnownSolutionParameter {
     73      get { return (LookupParameter<Schedule>)Parameters["BestKnownSolution"]; }
    7474    }
    75     public ScopeTreeLookupParameter<JSSPEncoding> SchedulingSolutionParameter {
    76       get { return (ScopeTreeLookupParameter<JSSPEncoding>)Parameters["SchedulingSolution"]; }
     75    public ScopeTreeLookupParameter<Schedule> SchedulingSolutionParameter {
     76      get { return (ScopeTreeLookupParameter<Schedule>)Parameters["DecodedSchedulingSolution"]; }
    7777    }
    7878
     
    8484      Parameters.Add(new LookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem."));
    8585      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The qualities of the JSSP solutions which should be analyzed."));
    86       Parameters.Add(new ScopeTreeLookupParameter<JSSPEncoding>("SchedulingSolution", "The solutions from which the best solution has to be chosen from."));
    87       Parameters.Add(new LookupParameter<JSSPEncoding>("BestSolution", "The best JSSP solution."));
     86      Parameters.Add(new ScopeTreeLookupParameter<Schedule>("DecodedSchedulingSolution", "The solutions from which the best solution has to be chosen from."));
     87      Parameters.Add(new LookupParameter<Schedule>("BestSolution", "The best JSSP solution."));
    8888      Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The result collection where the best JSSP solution should be stored."));
    8989      Parameters.Add(new LookupParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this JSSP instance."));
    90       Parameters.Add(new LookupParameter<JSSPEncoding>("BestKnownSolution", "The best known solution of this JSSP instance."));
     90      Parameters.Add(new LookupParameter<Schedule>("BestKnownSolution", "The best known solution of this JSSP instance."));
    9191    }
    9292
    9393
    9494    public override IOperation Apply() {
    95       IntValue nrOfResources = NrOfResources;
    9695      ItemList<JSSPJob> jobs = Jobs;
    9796      ItemArray<DoubleValue> qualities = QualityParameter.ActualValue;
    98       ItemArray<JSSPEncoding> solutions = SchedulingSolutionParameter.ActualValue;
     97      ItemArray<Schedule> solutions = SchedulingSolutionParameter.ActualValue;
    9998      ResultCollection results = ResultsParameter.ActualValue;
    10099      bool max = MaximizationParameter.ActualValue.Value;
     
    110109          !max && qualities[i].Value < bestKnownQuality.Value) {
    111110        BestKnownQualityParameter.ActualValue = new DoubleValue(qualities[i].Value);
    112         BestKnownSolutionParameter.ActualValue = (JSSPEncoding)solutions[i].Clone();
     111        BestKnownSolutionParameter.ActualValue = (Schedule)solutions[i].Clone();
    113112      }
    114113
    115       JSSPEncoding bestSolution = BestSolutionParameter.ActualValue;
     114      Schedule bestSolution = BestSolutionParameter.ActualValue;
    116115      if (bestSolution == null) {
    117         bestSolution = (JSSPEncoding)solutions[i].Clone();
     116        bestSolution = (Schedule)solutions[i].Clone();
    118117        bestSolution.Quality.Value = qualities [i].Value;
    119118        BestSolutionParameter.ActualValue = bestSolution;
     
    122121        if (max && bestSolution.Quality.Value < qualities[i].Value ||
    123122          !max && bestSolution.Quality.Value > qualities[i].Value) {
    124             bestSolution = (JSSPEncoding)solutions[i].Clone();
     123            bestSolution = (Schedule)solutions[i].Clone();
    125124          bestSolution.Quality.Value = qualities[i].Value;
    126125        }
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Encodings/JSSPCreator.cs

    r6121 r6177  
    2929using HeuristicLab.Parameters;
    3030using HeuristicLab.Problems.Scheduling.Encodings;
     31using HeuristicLab.Problems.Scheduling.Interfaces;
    3132
    3233namespace HeuristicLab.Problems.Scheduling.Encodings {
    3334  [Item("JobShop Scheduling Problem Creator", "Represents the generalized form of creators for JobShop Scheduling Problems.")]
    3435  [StorableClass]
    35   public abstract class JSSPCreator<T> : SchedulingCreator where T : JSSPEncoding{
     36  public abstract class JSSPCreator<T> :JSSPOperator, IJSSPCreator where T : Item, IJSSPEncoding{
    3637    [StorableConstructor]
    3738    protected JSSPCreator(bool deserializing) : base(deserializing) { }
     
    4849    }
    4950
     51    protected abstract T CreateSolution();
     52
    5053    public override IOperation Apply() {
    5154      SchedulingSolutionParameter.ActualValue = CreateSolution();
    5255      return base.Apply();
    5356    }
    54 
    55 
    56     protected abstract T CreateSolution();
    57    
    5857  }
    5958}
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Encodings/JSSPCrossover.cs

    r6121 r6177  
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2626using HeuristicLab.Problems.Scheduling.Interfaces;
     27using HeuristicLab.Optimization;
    2728
    2829namespace HeuristicLab.Problems.Scheduling.Encodings {
    2930  [Item("JSSPCrossover", "A scheduling crossover operation.")]
    3031  [StorableClass]
    31   public abstract class JSSPCrossover : SchedulingOperator, IJSSPCrossover {
     32  public abstract class JSSPCrossover : JSSPOperator, IJSSPCrossover, IStochasticOperator {
    3233    #region IJSSPCrossover Members
    33     public ILookupParameter<ItemArray<JSSPEncoding>> ParentsParameter {
    34       get { return (ScopeTreeLookupParameter<JSSPEncoding>)Parameters["Parents"]; }
     34    public ILookupParameter<ItemArray<IJSSPEncoding>> ParentsParameter {
     35      get { return (ScopeTreeLookupParameter<IJSSPEncoding>)Parameters["Parents"]; }
    3536    }
    3637
    37     public ILookupParameter<JSSPEncoding> ChildParameter {
    38       get { return (ILookupParameter<JSSPEncoding>)Parameters["Child"]; }
     38    public ILookupParameter<IJSSPEncoding> ChildParameter {
     39      get { return (ILookupParameter<IJSSPEncoding>)Parameters["Child"]; }
    3940    }
    4041    #endregion
     42
     43    public ILookupParameter<IRandom> RandomParameter {
     44      get { return (LookupParameter<IRandom>)Parameters["Random"]; }
     45    }
    4146
    4247    [StorableConstructor]
     
    4752    public JSSPCrossover()
    4853      : base() {
    49       Parameters.Add(new ScopeTreeLookupParameter<JSSPEncoding>("Parents", "The parent permutations which should be crossed."));
     54        Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators."));
     55      Parameters.Add(new ScopeTreeLookupParameter<IJSSPEncoding>("Parents", "The parent solution which should be crossed."));
    5056      ParentsParameter.ActualName = "SchedulingSolution";
    51       Parameters.Add(new LookupParameter<JSSPEncoding>("Child", "The child permutation resulting from the crossover."));
     57      Parameters.Add(new LookupParameter<IJSSPEncoding>("Child", "The child solution resulting from the crossover."));
    5258      ChildParameter.ActualName = "SchedulingSolution";
    5359    }
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Encodings/JSSPManipulator.cs

    r6121 r6177  
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2626using HeuristicLab.Problems.Scheduling.Interfaces;
     27using HeuristicLab.Optimization;
    2728
    2829namespace HeuristicLab.Problems.Scheduling.Encodings {
    2930  [Item("JSSPManipulator", "A JSSP manipulation operation.")]
    3031  [StorableClass]
    31   public abstract class JSSPManipulator : SchedulingOperator, IJSSPManipulator {
     32  public abstract class JSSPManipulator : JSSPOperator, IJSSPManipulator, IStochasticOperator {
    3233    #region IJSSPManipulator Members
    3334
    34     public ILookupParameter<JSSPEncoding> SchedulingSolutionParameter {
    35       get { return (ILookupParameter<JSSPEncoding>)Parameters["SchedulingSolution"]; }
     35    public ILookupParameter<IJSSPEncoding> SchedulingSolutionParameter {
     36      get { return (ILookupParameter<IJSSPEncoding>)Parameters["SchedulingSolution"]; }
    3637    }
    3738
    3839    #endregion
     40
     41    public ILookupParameter<IRandom> RandomParameter {
     42      get { return (LookupParameter<IRandom>)Parameters["Random"]; }
     43    }
    3944
    4045    [StorableConstructor]
     
    4550    public JSSPManipulator()
    4651      : base() {
    47         Parameters.Add(new LookupParameter<JSSPEncoding>("SchedulingEncoding", "The JSSP solution to be manipulated."));
     52        Parameters.Add(new LookupParameter<IJSSPEncoding>("SchedulingSolution", "The JSSP solution to be manipulated."));
     53        Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators."));
    4854    }
    4955
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Encodings/JobSequenceMatrix/Crossovers/JSMCrossover.cs

    r6121 r6177  
    3030  [Item("JSMCrossover", "An operator which crosses two JSM representations.")]
    3131  [StorableClass]
    32   public abstract class JSMCrossover : JSSPCrossover, IStochasticOperator, IJSMOperator {
    33     public ILookupParameter<IRandom> RandomParameter {
    34       get { return (LookupParameter<IRandom>)Parameters["Random"]; }
    35     }
     32  public abstract class JSMCrossover : JSSPCrossover, IJSMOperator {
    3633
    3734    [StorableConstructor]
     
    4037    public JSMCrossover()
    4138      : base() {
    42       Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators."));
    4339    }
    4440
    45     protected abstract JSSPEncoding Crossover(IRandom random, JSMEncoding parent1, JSMEncoding parent2);
     41    public abstract IJSSPEncoding Crossover(IRandom random, JSMEncoding parent1, JSMEncoding parent2);
    4642
    4743    public override IOperation Apply() {
    48       ItemArray<JSSPEncoding> parents = ParentsParameter.ActualValue;
     44      ItemArray<IJSSPEncoding> parents = ParentsParameter.ActualValue;
    4945
    5046      ChildParameter.ActualValue =
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Encodings/JobSequenceMatrix/Crossovers/JSMSXXCrossover.cs

    r6121 r6177  
    2727using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2828using HeuristicLab.Core;
     29using HeuristicLab.Problems.Scheduling.Interfaces;
     30using HeuristicLab.Encodings.PermutationEncoding;
    2931
    3032namespace HeuristicLab.Problems.Scheduling.Encodings.JobSequenceMatrix.Crossovers {
    31   [Item("JSM Subsequence Exchange Crossover", "Represents a crossover operation swapping subsequences of the parents to generate offspring.")]
     33  [Item("JSM Subsequence Exchange Crossover", "Represents a crossover operation identifiying and exchanging equal subsequences of the parents to generate offspring.")]
    3234  [StorableClass]
    3335  public class JSMSXXCrossover : JSMCrossover {
     
    4345    public JSMSXXCrossover () : base () {}
    4446
    45     protected override JSSPEncoding Crossover(IRandom random, JSMEncoding parent1, JSMEncoding parent2) {
    46       JSSPEncoding result = parent1;
     47    public static IJSSPEncoding Cross(IRandom random, JSMEncoding parent1, JSMEncoding parent2) {
     48      JSMEncoding result = new JSMEncoding();
    4749
     50      int subSequenceLength = 3;
     51
     52      for (int i = 0; i < parent1.JobSequenceMatrix.Count; i++) {
     53        Permutation p1 = (Permutation)parent1.JobSequenceMatrix[i].Clone();
     54        Permutation p2 = (Permutation)parent2.JobSequenceMatrix[i].Clone();
     55        FindAndExchangeSubsequences(p1, p2, subSequenceLength);
     56        //parent1.JobSequenceMatrix[i] = p1;
     57        //parent2.JobSequenceMatrix[i] = p2;
     58
     59        result.JobSequenceMatrix.Add(p1);
     60      }
    4861
    4962      return result;
    5063    }
     64
     65    private static void FindAndExchangeSubsequences(Permutation p1, Permutation p2, int subSequenceLength) {
     66      for (int i = 0; i <= p1.Length - subSequenceLength; i++) {
     67        for (int j = 0; j <= p2.Length - subSequenceLength; j++) {
     68          int[] ss1 = GetSubSequenceAtPosition(p1, i, subSequenceLength);
     69          int[] ss2 = GetSubSequenceAtPosition(p2, j, subSequenceLength);
     70          if (AreEqualSubsequences(ss1, ss2)) {
     71            ExchangeSubsequences(p1, i, p2, j, subSequenceLength);
     72            break;
     73          }
     74        }
     75      }
     76    }
     77    private static void ExchangeSubsequences(Permutation p1, int index1, Permutation p2, int index2, int subSequenceLength) {
     78      Permutation aux = (Permutation)p1.Clone();
     79      for (int i = 0; i < subSequenceLength; i++) {
     80        p1[i + index1] = p2[i + index2];
     81        p2[i + index2] = aux[i + index1];
     82      }
     83    }
     84    private static bool AreEqualSubsequences(int[] ss1, int[] ss2) {
     85      int counter = 0;
     86      for (int i = 0; i < ss1.Length; i++) {
     87        for (int j = 0; j < ss2.Length; j++) {
     88          if (ss1[i] == ss2[j])
     89            counter++;
     90        }
     91      }
     92      return counter == ss1.Length;
     93    }
     94    private static int[] GetSubSequenceAtPosition(Permutation p1, int index, int subSequenceLength) {
     95      int[] result = new int[subSequenceLength];
     96      for (int i = 0; i < subSequenceLength; i++)
     97        result[i] = p1[i + index];
     98
     99      return result;
     100    }
     101
     102
     103
     104    public override IJSSPEncoding Crossover(IRandom random, JSMEncoding parent1, JSMEncoding parent2) {
     105      return Cross(random, parent1, parent2);
     106    }
    51107  }
    52108}
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Encodings/JobSequenceMatrix/JSMDecoder.cs

    r6121 r6177  
    3535  [Item("Job Sequencing Matrix Decoder", "Applies the GifflerThompson algorithm to create an active schedule from a JobSequencing Matrix.")]
    3636  [StorableClass]
    37   public class JSMDecoder : NamedItem {
     37  public class JSMDecoder : JSSPDecoder<JSMEncoding>, IStochasticOperator {
    3838    [StorableConstructor]
    3939    protected JSMDecoder(bool deserializing) : base(deserializing) { }
     
    4141      : base(original, cloner) {
    4242        this.resultingSchedule = cloner.Clone(original.resultingSchedule);
     43        this.decodingErrorPolicy = original.decodingErrorPolicy;
     44        this.forcingStrategy = original.forcingStrategy;
    4345    }
    4446    public override IDeepCloneable Clone(Cloner cloner) {
     
    4648    }
    4749
     50    public ILookupParameter<IRandom> RandomParameter {
     51      get { return (LookupParameter<IRandom>)Parameters["Random"]; }
     52    }
     53
    4854    [Storable]
    4955    private Schedule resultingSchedule;
    5056
    5157    [Storable]
    52     private IRandom random;
    53 
    54     public JSMDecoder(IntValue nrOfResources, IRandom r)
     58    private JSMDecodingErrorPolicyTypes decodingErrorPolicy = JSMDecodingErrorPolicyTypes.GuidedPolicy;
     59
     60    [Storable]
     61    private JSMForcingStrategyTypes forcingStrategy = JSMForcingStrategyTypes.ShiftForcing;
     62
     63    public JSMDecoder()
    5564      : base() {
    56       resultingSchedule = new Schedule(nrOfResources);
    57       random = r;
    58     }
    59 
    60 
    61     public Schedule CreateScheduleFromJSM(ItemList<JSSPJob> jobs, ItemList<Permutation> jobSequenceMatrix) {
    62       //Reset scheduled tasks in result
    63       foreach (JSSPJob j in jobs) {
    64         foreach (JSSPTask t in j.Tasks) {
    65           t.IsScheduled.Value = false;
    66         }
    67       }
    68 
    69       //GT-Algorithm
    70       //STEP 0 - Compute a list of "earliest operations"
    71       ItemList<JSSPTask> earliestTasksList = GetEarliestNotScheduledTasks(jobs);
    72       while (earliestTasksList.Count > 0) {
    73         //STEP 1 - Get earliest not scheduled operation with minimal earliest completing time
    74         JSSPTask minimal = GetTaskWithMinimalEC(earliestTasksList);
    75 
    76         //STEP 2 - Compute a conflict set of all operations that can be scheduled on the machine the previously selected operation runs on
    77         ItemList<JSSPTask> conflictSet = GetConflictSetForTask(minimal, earliestTasksList);
    78 
    79         //STEP 3 - Select an operation from the conflict set (various methods depending on how the algorithm should work..)
    80         JSSPTask selectedTask = SelectTaskFromConflictSet(minimal.ResourceNr, conflictSet, jobSequenceMatrix);
    81 
    82         //STEP 4 - Adding the selected operation to the current schedule
    83         AddTaskToSchedule(selectedTask);
    84 
    85         //STEP 5 - Back to STEP 1
    86         earliestTasksList = GetEarliestNotScheduledTasks(jobs);
    87       }
    88 
    89       return resultingSchedule;
    90     }
     65      Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators."));
     66    }
     67
    9168    private ItemList<JSSPTask> GetEarliestNotScheduledTasks(ItemList<JSSPJob> jobs) {
    9269      ItemList<JSSPTask> result = new ItemList<JSSPTask>();
     
    132109        IntValue solutionCandidateJobNr = new IntValue(jsm[conflictedResource.Value][progressOnResource.Value]);
    133110        foreach (JSSPTask t in conflictSet) {
    134           if (t.Job.JobIndex == solutionCandidateJobNr)
     111          if (t.Job.Index.Value == solutionCandidateJobNr.Value)
    135112            result = t;
    136113        }
     
    141118      //Repairing happens here
    142119      if (result == null) {
    143         result = conflictSet[random.Next(conflictSet.Count - 1)];
     120        //Decoding Error Policy BEGIN
     121        //CHOOSE OTHER RESOLUTION FOR CONFLICT SET
     122        result = ApplyDecodingErrorPolicy(conflictSet);
     123        //result = conflictSet[RandomParameter.ActualValue.Next(conflictSet.Count - 1)];
     124        //Decoding Error Policy END
     125
     126
     127        //Determine index of new resolution
    144128        int index = 0;
    145         foreach (int jobAssignment in jsm[conflictedResource.Value]) {
    146           if (jobAssignment == result.Job.JobIndex.Value)
    147             break;
     129        while (index < jsm[conflictedResource.Value].Length &&
     130          jsm[conflictedResource.Value][index] != result.Job.Index.Value)
    148131          index++;
    149         }
    150         jsm[conflictedResource.Value][index] = jsm[conflictedResource.Value][progressOnResource.Value];
    151         jsm[conflictedResource.Value][progressOnResource.Value] = result.Job.JobIndex.Value;
    152       }
    153        
    154 
    155       return result;
     132
     133
     134        //Forcing Strategy BEGIN
     135        ApplyForcingStrategy(jsm, conflictedResource.Value, index, progressOnResource.Value, result.Job.Index.Value);
     136       
     137        //ForcingStrategy END
     138      }
     139      return result;
     140    }
     141
     142    private void ApplyForcingStrategy(ItemList<Permutation> jsm, int conflictedResource, int newResolutionIndex, int progressOnResource, int newResolution) {
     143      //if (forcingStrategy == JSMForcingStrategyTypes.SwapForcing) {
     144        //SwapForcing
     145        jsm[conflictedResource][newResolutionIndex] = jsm[conflictedResource][progressOnResource];
     146        jsm[conflictedResource][progressOnResource] = newResolution;
     147      /*} else {
     148        //ShiftForcing
     149
     150      } */
     151    }
     152
     153    private JSSPTask ApplyDecodingErrorPolicy(ItemList<JSSPTask> conflictSet) {
     154      //if (decodingErrorPolicy == JSMDecodingErrorPolicyTypes.RandomPolicy) {
     155        //Random
     156        return conflictSet[RandomParameter.ActualValue.Next(conflictSet.Count - 1)];
     157      /*} else {
     158        //Guided
     159
     160      }    */
    156161    }
    157162    private DoubleValue ComputeEarliestStartTime(JSSPTask t) {
     
    174179      affectedResource.Tasks.Add(selectedTask);
    175180    }
     181
     182    public override Schedule CreateScheduleFromEncoding(JSMEncoding solution) {
     183      ItemList<Permutation> jobSequenceMatrix = solution.JobSequenceMatrix;
     184
     185      resultingSchedule = new Schedule(new IntValue(Jobs[0].Tasks.Count));
     186
     187      //Reset scheduled tasks in result
     188      foreach (JSSPJob j in Jobs) {
     189        foreach (JSSPTask t in j.Tasks) {
     190          t.IsScheduled.Value = false;
     191        }
     192      }
     193
     194      //GT-Algorithm
     195      //STEP 0 - Compute a list of "earliest operations"
     196      ItemList<JSSPTask> earliestTasksList = GetEarliestNotScheduledTasks(Jobs);
     197      while (earliestTasksList.Count > 0) {
     198        //STEP 1 - Get earliest not scheduled operation with minimal earliest completing time
     199        JSSPTask minimal = GetTaskWithMinimalEC(earliestTasksList);
     200
     201        //STEP 2 - Compute a conflict set of all operations that can be scheduled on the machine the previously selected operation runs on
     202        ItemList<JSSPTask> conflictSet = GetConflictSetForTask(minimal, earliestTasksList);
     203
     204        //STEP 3 - Select an operation from the conflict set (various methods depending on how the algorithm should work..)
     205        JSSPTask selectedTask = SelectTaskFromConflictSet(minimal.ResourceNr, conflictSet, jobSequenceMatrix);
     206
     207        //STEP 4 - Adding the selected operation to the current schedule
     208        AddTaskToSchedule(selectedTask);
     209
     210        //STEP 5 - Back to STEP 1
     211        earliestTasksList = GetEarliestNotScheduledTasks(Jobs);
     212      }
     213
     214      return resultingSchedule;
     215    }
     216
     217    public override IOperation Apply() {
     218      return base.Apply();
     219    }
    176220  }
    177221}
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Encodings/JobSequenceMatrix/JSMEncoding.cs

    r6121 r6177  
    2929using HeuristicLab.Encodings.PermutationEncoding;
    3030using HeuristicLab.Data;
    31 using HeuristicLab.Problems.Scheduling.Encodings;
     31using HeuristicLab.Problems.Scheduling.Interfaces;
     32using HeuristicLab.Problems.Scheduling.Encodings.JobSequenceMatrix.Crossovers;
     33using HeuristicLab.Problems.Scheduling.Encodings.JobSequenceMatrix.Manipulators;
    3234
    3335namespace HeuristicLab.Problems.Scheduling.Encodings.JobSequenceMatrix {
    3436  [Item("Job Sequencing Matrix Encoding", "Represents a solution for a standard JobShop Scheduling Problem.")]
    3537  [StorableClass]
    36   public class JSMEncoding : JSSPEncoding{
     38  public class JSMEncoding : ParameterizedNamedItem, IJSSPEncoding{
    3739    [StorableConstructor]
    3840    protected JSMEncoding(bool deserializing) : base(deserializing) { }
     
    5254    }
    5355
    54     public override Schedule ToSchedule(IntValue nrOfResources, ItemList<JSSPJob> jobs, IRandom random) {
    55       JSMDecoder decoder = new JSMDecoder(nrOfResources, random);
    56       return decoder.CreateScheduleFromJSM (jobs, JobSequenceMatrix);
    57     }
    58 
    5956    public override string ToString() {
    6057      StringBuilder sb = new StringBuilder();
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Encodings/JobSequenceMatrix/JSMRandomCreator.cs

    r6121 r6177  
    6464      JSMEncoding solution = new JSMEncoding();
    6565      IntValue nrOfJobs = new IntValue (Jobs.Count);
    66       IntValue nrOfResources = NrOfResources;
     66      IntValue nrOfResources = new IntValue (Jobs[0].Tasks.Count);
    6767
    6868      for (int i = 0; i < nrOfResources.Value; i++) {
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Encodings/JobSequenceMatrix/Manipulators/JSMManipulator.cs

    r6121 r6177  
    3232  [Item("AlbaManipulator", "An operator which manipulates a VRP representation.")]
    3333  [StorableClass]
    34   public abstract class JSMManipulator : JSSPManipulator, IStochasticOperator, IJSMOperator {
    35     public ILookupParameter<IRandom> RandomParameter {
    36       get { return (LookupParameter<IRandom>)Parameters["Random"]; }
    37     }
    38 
     34  public abstract class JSMManipulator : JSSPManipulator, IJSMOperator {
    3935    [StorableConstructor]
    4036    protected JSMManipulator(bool deserializing) : base(deserializing) { }
     
    4238    public JSMManipulator()
    4339      : base() {
    44       Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators."));
    4540    }
    4641
     
    4944
    5045    public override IOperation Apply() {
    51       JSSPEncoding solution = SchedulingSolutionParameter.ActualValue;
     46      IJSSPEncoding solution = SchedulingSolutionParameter.ActualValue;
    5247
    5348      SchedulingSolutionParameter.ActualValue = Manipulate(RandomParameter.ActualValue, solution as JSMEncoding);
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Evaluators/MakespanEvaluator.cs

    r6121 r6177  
    3434  [Item("Makespan Evaluator", "Represents an evaluator using the maximum makespan of a schedule.")]
    3535  [StorableClass]
    36   public class MakespanEvaluator : JSSPEvaluator, IStochasticOperator {
     36  public class MakespanEvaluator : JSSPEvaluator {
    3737    [StorableConstructor]
    3838    protected MakespanEvaluator(bool deserializing) : base(deserializing) { }
     
    4444    }
    4545
    46    
    47 
    4846    public MakespanEvaluator () : base () { }
    49 
    5047
    5148    protected override DoubleValue evaluate(Schedule schedule) {
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/HeuristicLab.Problems.Scheduling-3.3.csproj

    r6121 r6177  
    4949  <ItemGroup>
    5050    <Compile Include="Analyzers\BestSchedulingSolutionAnalyzer.cs" />
     51    <Compile Include="Encodings\JobSequenceMatrix\JSMDecodingErrorPolicyTypes.cs" />
     52    <Compile Include="Encodings\JobSequenceMatrix\Crossovers\JSMJOXCrossover.cs" />
    5153    <Compile Include="Encodings\JobSequenceMatrix\Crossovers\JSMCrossover.cs" />
     54    <Compile Include="Encodings\JobSequenceMatrix\Crossovers\JSMOrderCrossover.cs" />
    5255    <Compile Include="Encodings\JobSequenceMatrix\Crossovers\JSMSXXCrossover.cs" />
    5356    <Compile Include="Encodings\JobSequenceMatrix\JSMDecoder.cs" />
     57    <Compile Include="Encodings\JobSequenceMatrix\JSMForcingStrategyTypes.cs" />
    5458    <Compile Include="Encodings\JobSequenceMatrix\JSMRandomCreator.cs" />
    5559    <Compile Include="Encodings\JobSequenceMatrix\JSMEncoding.cs" />
     60    <Compile Include="Encodings\JobSequenceMatrix\Manipulators\JSMShiftChangeManipulator.cs" />
    5661    <Compile Include="Encodings\JobSequenceMatrix\Manipulators\JSMManipulator.cs" />
    57     <Compile Include="Encodings\JobSequenceMatrix\Manipulators\JSMSwapManipulator.cs" />
     62    <Compile Include="Encodings\JobSequenceMatrix\Manipulators\JSMInsertionManipulator.cs" />
    5863    <Compile Include="Encodings\JSSPCrossover.cs" />
    59     <Compile Include="Encodings\JSSPEncoding.cs" />
     64    <Compile Include="Encodings\JSSPDecoder.cs" />
     65    <Compile Include="Encodings\JSSPEncodingTypes.cs" />
     66    <Compile Include="Encodings\PriorityRulesVector\Crossovers\PRVSinglePointCrossover.cs" />
     67    <Compile Include="Encodings\PriorityRulesVector\Crossovers\PRVDiscreteCrossover.cs" />
     68    <Compile Include="Encodings\PriorityRulesVector\Manipulators\PRVUniformOnePositionManipulator.cs" />
     69    <Compile Include="Encodings\PriorityRulesVector\PRVEncoding.cs" />
     70    <Compile Include="Interfaces\IJSSPDecoder.cs" />
     71    <Compile Include="Interfaces\IJSSPOperator.cs" />
     72    <Compile Include="Interfaces\IPRVOperator.cs" />
     73    <Compile Include="Interfaces\IJSSPEncoding.cs" />
    6074    <Compile Include="Encodings\JSSPCreator.cs" />
    6175    <Compile Include="Encodings\JSSPManipulator.cs" />
     76    <Compile Include="Encodings\PriorityRulesVector\Crossovers\PRVCrossover.cs" />
     77    <Compile Include="Encodings\PriorityRulesVector\PRVDecoder.cs" />
     78    <Compile Include="Encodings\PriorityRulesVector\PRVRandomCreator.cs" />
     79    <Compile Include="Encodings\PriorityRulesVector\Manipulators\PRVManipulator.cs" />
    6280    <Compile Include="Evaluators\MakespanEvaluator.cs" />
     81    <Compile Include="IndexedTaskList.cs" />
    6382    <Compile Include="Interfaces\IJSMOperator.cs" />
    6483    <Compile Include="Interfaces\IJSSPCrossover.cs" />
    6584    <Compile Include="Interfaces\IJSSPManipulator.cs" />
     85    <Compile Include="Interfaces\ISchedulingCreator.cs" />
     86    <Compile Include="Interfaces\ISchedulingEvaluator.cs" />
    6687    <Compile Include="Resource.cs" />
    67     <Compile Include="JSSPEvaluator.cs" />
    68     <Compile Include="SchedulingCreator.cs" />
     88    <Compile Include="Evaluators\JSSPEvaluator.cs" />
     89    <Compile Include="Interfaces\IJSSPCreator.cs" />
    6990    <Compile Include="JSSPJob.cs" />
    7091    <Compile Include="JobShopSchedulingProblem.cs" />
    7192    <Compile Include="JSSPTask.cs" />
    72     <Compile Include="SchedulingOperator.cs" />
     93    <Compile Include="Encodings\JSSPOperator.cs" />
     94    <Compile Include="Evaluators\SchedulingEvaluator.cs" />
    7395    <Compile Include="SchedulingProblem.cs" />
    74     <Compile Include="Task.cs" />
    7596    <Compile Include="Plugin.cs" />
    7697    <Compile Include="Properties\AssemblyInfo.cs" />
     
    103124      <Name>HeuristicLab.Data-3.3</Name>
    104125    </ProjectReference>
     126    <ProjectReference Include="..\..\HeuristicLab.Encodings.IntegerVectorEncoding\3.3\HeuristicLab.Encodings.IntegerVectorEncoding-3.3.csproj">
     127      <Project>{DDFB14DD-2A85-493C-A52D-E69729BBAEB0}</Project>
     128      <Name>HeuristicLab.Encodings.IntegerVectorEncoding-3.3</Name>
     129    </ProjectReference>
    105130    <ProjectReference Include="..\..\HeuristicLab.Encodings.PermutationEncoding\3.3\HeuristicLab.Encodings.PermutationEncoding-3.3.csproj">
    106131      <Project>{DBECB8B0-B166-4133-BAF1-ED67C3FD7FCA}</Project>
     
    128153    </ProjectReference>
    129154  </ItemGroup>
    130   <ItemGroup>
    131     <Folder Include="Encodings\PriorityRulesVector\" />
    132   </ItemGroup>
     155  <ItemGroup />
    133156  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    134157  <PropertyGroup>
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Interfaces/IJSSPCrossover.cs

    r6121 r6177  
    88
    99namespace HeuristicLab.Problems.Scheduling.Interfaces {
    10   interface IJSSPCrossover : ICrossover{
    11     ILookupParameter<ItemArray<JSSPEncoding>> ParentsParameter { get; }
    12     ILookupParameter<JSSPEncoding> ChildParameter { get; }
     10  public interface IJSSPCrossover : ICrossover{
     11    ILookupParameter<ItemArray<IJSSPEncoding>> ParentsParameter { get; }
     12    ILookupParameter<IJSSPEncoding> ChildParameter { get; }
    1313  }
    1414}
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Interfaces/IJSSPManipulator.cs

    r6121 r6177  
    2626namespace HeuristicLab.Problems.Scheduling.Interfaces {
    2727  public interface IJSSPManipulator : IManipulator {
    28     ILookupParameter<JSSPEncoding> SchedulingSolutionParameter { get; }
     28    ILookupParameter<IJSSPEncoding> SchedulingSolutionParameter { get; }
    2929  }
    3030}
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/JSSPJob.cs

    r6121 r6177  
    3333  [Item("Job Class", "Represents a composition of tasks that require processing in a job shop scheduling problem.")]
    3434  [StorableClass]
    35   public class JSSPJob : ParameterizedNamedItem {
     35  public class JSSPJob : IndexedTaskList {
    3636    [StorableConstructor]
    3737    protected JSSPJob(bool deserializing) : base(deserializing) { }
    3838    protected JSSPJob(JSSPJob original, Cloner cloner)
    3939      : base(original, cloner) {
    40       this.JobIndex = cloner.Clone(original.JobIndex);
    41       this.Tasks = cloner.Clone(original.Tasks);
    4240    }
    4341    public override IDeepCloneable Clone(Cloner cloner) {
     
    4543    }
    4644
    47     #region Parameter Properties
    48     public ValueParameter<IntValue> JobIndexParameter {
    49       get { return (ValueParameter<IntValue>)Parameters["JobIndex"]; }
    50     }
    51 
    52     public ValueParameter<ItemList<Task>> TasksParameter {
    53       get { return (ValueParameter<ItemList<Task>>)Parameters["Tasks"]; }
    54     }
    55     #endregion
    56 
    57     #region Properties
    58     public IntValue JobIndex {
    59       get { return JobIndexParameter.Value; }
    60       set { JobIndexParameter.Value = value; }
    61     }
    62     public ItemList<Task> Tasks {
    63       get { return TasksParameter.Value; }
    64       set { TasksParameter.Value = value; }
    65     }
    66     #endregion
    67 
    68 
    69     public JSSPJob(IntValue ji) {
    70       Parameters.Add(new ValueParameter<IntValue>("JobIndex", "The index of the job in the associated JSSP-Instance.", new IntValue()));
    71       Parameters.Add(new ValueParameter<ItemList<Task>>("Tasks", "Taskdata defining duration, start-time and resource assignment of the tasks.", new ItemList<Task>()));
    72 
    73       JobIndex = ji;
    74       Tasks = new ItemList<Task>();
    75     }
    76 
     45    public JSSPJob(IntValue index) : base (index) {}
    7746
    7847    public override string ToString() {
    7948      StringBuilder sb = new StringBuilder();
    80       sb.Append("Job" + JobIndex + " [ ");
    81       foreach (Task t in Tasks) {
     49      sb.Append("Job#" + Index + " [ ");
     50      foreach (JSSPTask t in Tasks) {
    8251        sb.Append(t.ToString () + " ");
    8352      }
     
    8554      return sb.ToString();
    8655    }
    87 
    8856  }
    8957}
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/JSSPTask.cs

    r6121 r6177  
    3232  [Item("Job Shop Scheduling Task Class", "Represents smallest unit for a job shop scheduling problem.")]
    3333  [StorableClass]
    34   public class JSSPTask : Task {
     34  public class JSSPTask : Item {
    3535    [StorableConstructor]
    3636    protected JSSPTask(bool deserializing) : base(deserializing) { }
    3737    protected JSSPTask(JSSPTask original, Cloner cloner)
    3838      : base(original, cloner) {
     39      this.ResourceNr = cloner.Clone(original.ResourceNr);
     40      this.Duration = cloner.Clone(original.Duration);
     41      this.StartTime = cloner.Clone(original.StartTime);
     42      this.TaskNr = cloner.Clone(original.TaskNr);
     43      this.IsScheduled = cloner.Clone(original.IsScheduled);
    3944      this.Job = cloner.Clone(original.Job);
    4045      this.PreviousTask = cloner.Clone(original.PreviousTask);
     46      this.NextTask = cloner.Clone(original.NextTask);
    4147    }
    4248    public override IDeepCloneable Clone(Cloner cloner) {
     
    4551
    4652
     53    public BoolValue IsScheduled { get; set; }
     54    public IntValue TaskNr { get; set; }
     55    public IntValue ResourceNr { get; set; }
     56    public DoubleValue Duration { get; set; }
     57    public DoubleValue StartTime { get; set; }
     58    public DoubleValue EndTime {
     59      get {
     60        return new DoubleValue(Duration.Value + StartTime.Value);
     61      }
     62    }
     63    public JSSPJob Job { get; set; }
     64    public JSSPTask PreviousTask { get; set; }
     65    public JSSPTask NextTask { get; set; }
    4766
    48     public JSSPJob Job { get; set; }
    49     public Task PreviousTask { get; set; }
    50 
    51     public JSSPTask (IntValue taskNr, IntValue resNr, DoubleValue duration, JSSPJob j) : base (taskNr, resNr, duration) {
     67    public JSSPTask (IntValue taskNr, IntValue resNr, DoubleValue duration, JSSPJob j) : base () {
     68      Duration = duration;
     69      ResourceNr = resNr;
     70      TaskNr = taskNr;
     71      StartTime = new DoubleValue(0);
     72      IsScheduled = new BoolValue(false);
    5273      Job = j;
    5374    }
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/JobShopSchedulingProblem.cs

    r6121 r6177  
    4141using HeuristicLab.Problems.Scheduling.Encodings.JobSequenceMatrix.Crossovers;
    4242using HeuristicLab.Problems.Scheduling.Interfaces;
     43using HeuristicLab.Problems.Scheduling.Encodings.PriorityRulesVector;
     44using HeuristicLab.Encodings.IntegerVectorEncoding;
    4345
    4446namespace HeuristicLab.Problems.Scheduling {
     
    5254      : base(original, cloner) {
    5355        operators = original.operators.Select(x => (IOperator)cloner.Clone(x)).ToList();
     56        this.encodingType = original.encodingType;
     57        AttachEventHandlers();
    5458    }
    5559    public override IDeepCloneable Clone(Cloner cloner) {
     
    5963
    6064    #region Parameter Properties
    61     public ValueParameter<IntValue> NrOfResourcesParameter {
    62       get { return (ValueParameter<IntValue>)Parameters["NrOfResources"]; }
    63     }
    6465    public ValueParameter<ItemList<JSSPJob>> JobsParameter {
    6566      get { return (ValueParameter<ItemList<JSSPJob>>)Parameters["Jobs"]; }
    6667    }
    67     public OptionalValueParameter<JSSPEncoding> BestKnownSolutionParameter {
    68       get { return (OptionalValueParameter<JSSPEncoding>)Parameters["BestKnownSolution"]; }
     68    public OptionalValueParameter<Schedule> BestKnownSolutionParameter {
     69      get { return (OptionalValueParameter<Schedule>)Parameters["BestKnownSolution"]; }
    6970    }
    7071    #endregion
    7172
    7273    #region Properties
    73     public IntValue NrOfResources {
    74       get { return NrOfResourcesParameter.Value; }
    75       set { NrOfResourcesParameter.Value = value; }
    76     }
    7774    public ItemList<JSSPJob> Jobs {
    7875      get { return JobsParameter.Value; }
    7976      set { JobsParameter.Value = value; }
    8077    }
    81     public JSSPEncoding BestKnownSolution {
     78    public Schedule BestKnownSolution {
    8279      get { return BestKnownSolutionParameter.Value; }
    8380      set { BestKnownSolutionParameter.Value = value; }
     
    8986    private List<IOperator> operators;
    9087
     88    [Storable]
     89    private JSSPEncodingTypes encodingType;
    9190
    9291    public JobShopSchedulingProblem()
    93       : base(new MakespanEvaluator (), new JSMRandomCreator ()) {
    94         Parameters.Add(new ValueParameter<IntValue>("NrOfResources", "Number of Resources used in this JSSP-Instance.", new IntValue()));
     92      : base(new SchedulingEvaluator (), new JSMRandomCreator ()) {
    9593        Parameters.Add(new ValueParameter<ItemList<JSSPJob>>("Jobs", "Jobdata defining the precedence relationships and the duration of the tasks in this JSSP-Instance.", new ItemList<JSSPJob>()));
    96         Parameters.Add(new OptionalValueParameter<JSSPEncoding>("BestKnownSolution", "The best known solution of this JSSP instance."));
    97 
     94        Parameters.Add(new OptionalValueParameter<Schedule>("BestKnownSolution", "The best known solution of this JSSP instance."));
     95        encodingType = JSSPEncodingTypes.JSMEncoding;
    9896        InitializeOperators();
     97        AttachEventHandlers();
    9998    }
    10099
    101100    #region Events
    102101    //TODO: Implement event handlers for problem specific events!
     102    protected override void OnSolutionCreatorChanged() {
     103      if (SolutionCreator.GetType().Equals(typeof(JSMRandomCreator)))
     104        encodingType = JSSPEncodingTypes.JSMEncoding;
     105      else
     106        encodingType = JSSPEncodingTypes.PRVEncoding;
     107
     108      InitializeOperators();
     109    }
    103110    #endregion
    104111
    105112    #region Helpers
    106113    private void InitializeOperators() {
    107       Operators.AddRange(ApplicationManager.Manager.GetInstances<IJSMOperator>());
     114      Operators.Clear();
     115      ApplyEncoding();
    108116      Operators.Add(new BestSchedulingSolutionAnalyzer());
    109117      //ParameterizeAnalyzer();
    110118      //ParameterizeOperators();
     119    }
     120
     121    private void ApplyEncoding() {
     122      if (encodingType == JSSPEncodingTypes.JSMEncoding) {
     123        Operators.AddRange(ApplicationManager.Manager.GetInstances<IJSMOperator>());
     124        ((SchedulingEvaluator)this.EvaluatorParameter.ActualValue).InitializeOperatorGraph<JSMEncoding>(new JSMDecoder(), new MakespanEvaluator());
     125      } else {
     126        if (encodingType == JSSPEncodingTypes.PRVEncoding) {
     127          Operators.AddRange(ApplicationManager.Manager.GetInstances<IPRVOperator>());
     128          ((SchedulingEvaluator)this.EvaluatorParameter.ActualValue).InitializeOperatorGraph<PRVEncoding>(new PRVDecoder(), new MakespanEvaluator());
     129        }
     130      }
    111131    }
    112132
     
    148168        string line = problemFile.ReadLine();
    149169        List<string> data = SplitString(line);
    150         int taskCount = 0;
    151170        if (data.Count > 0 && ((int)data[0][0] >= 48 && (int)data[0][0] <= 57)) {
    152           NrOfResources = new IntValue(Int32.Parse(data[1]));
    153171          int jobCount = 0;
     172          //data[0] = nrOfJobs
     173          //data[1] = nrOfResources
     174          if (data.Count > 2)
     175            BestKnownQualityParameter.ActualValue = new DoubleValue(Double.Parse (data[2]));
    154176          line = problemFile.ReadLine();
    155177          data = SplitString(line);
     
    157179            JSSPJob j = new JSSPJob(new IntValue(jobCount));
    158180            for (int i = 0; i < data.Count; i++) {
    159               JSSPTask t = new JSSPTask(new IntValue (taskCount), new IntValue(Int32.Parse(data[i])), new DoubleValue(Double.Parse(data[i + 1])), j);
    160               taskCount++;
    161               if (j.Tasks.Count > 0)
     181              JSSPTask t = new JSSPTask(new IntValue (i / 2), new IntValue(Int32.Parse(data[i])), new DoubleValue(Double.Parse(data[i + 1])), j);
     182              if (j.Tasks.Count > 0) {
    162183                t.PreviousTask = j.Tasks[j.Tasks.Count - 1];
     184                j.Tasks[j.Tasks.Count - 1].NextTask = t;
     185                t.StartTime = new DoubleValue (t.PreviousTask.EndTime.Value + 2);
     186              }
    163187              j.Tasks.Add(t);
    164188              i++;
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Resource.cs

    r6121 r6177  
    3030using HeuristicLab.Common;
    3131
    32 //ATTENTION! This class may have lots of parallels with the HeuristicLab.Problems.Scheduling.JSSPJob class.
    33 
    3432namespace HeuristicLab.Problems.Scheduling {
    3533  [Item("Resource Class", "Represents a resource used in scheduling problems.")]
    3634  [StorableClass]
    37   public class Resource : ParameterizedNamedItem {
     35  public class Resource : IndexedTaskList {
    3836    [StorableConstructor]
    3937    protected Resource(bool deserializing) : base(deserializing) { }
    4038    protected Resource(Resource original, Cloner cloner)
    4139      : base(original, cloner) {
    42       this.ResourceIndex = cloner.Clone(original.ResourceIndex);
    43       this.Tasks = cloner.Clone(original.Tasks);
    4440    }
    4541    public override IDeepCloneable Clone(Cloner cloner) {
     
    4743    }
    4844
    49     #region Parameter Properties
    50     public ValueParameter<IntValue> ResourceIndexParameter {
    51       get { return (ValueParameter<IntValue>)Parameters["ResourceIndex"]; }
    52     }
    53     public ValueParameter<ItemList<Task>> TasksParameter {
    54       get { return (ValueParameter<ItemList<Task>>)Parameters["Tasks"]; }
    55     }
    56     #endregion
    57 
    58     #region Properties
    59     public IntValue ResourceIndex {
    60       get { return ResourceIndexParameter.Value; }
    61       set { ResourceIndexParameter.Value = value; }
    62     }
    63     public ItemList<Task> Tasks {
    64       get { return TasksParameter.Value; }
    65       set { TasksParameter.Value = value; }
    66     }
    6745    public DoubleValue TotalDuration {
    6846      get {
     
    7351      }
    7452    }
    75     #endregion
    7653
    77 
    78     public Resource(IntValue ri) {
    79       Parameters.Add(new ValueParameter<IntValue>("ResourceIndex", "The index of the resource in the associated Scheduling Problem.", new IntValue()));
    80       Parameters.Add(new ValueParameter<ItemList<Task>>("Tasks", "Taskdata defining duration, start-time and resource assignment of the tasks.", new ItemList<Task>()));
    81 
    82       ResourceIndex = ri;
    83       Tasks = new ItemList<Task>();
    84     }
    85 
     54    public Resource(IntValue index) : base (index) { }
    8655
    8756    public override string ToString() {
    8857      StringBuilder sb = new StringBuilder();
    89       sb.Append("Job" + ResourceIndex + " [ ");
    90       foreach (Task t in Tasks) {
     58      sb.Append("Resource#" + Index + " [ ");
     59      foreach (JSSPTask t in Tasks) {
    9160        sb.Append(t.ToString() + " ");
    9261      }
     
    9463      return sb.ToString();
    9564    }
    96 
    9765  }
    9866}
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Schedule.cs

    r6121 r6177  
    3535  [Item("Schedule Class", "Represents the general solution for scheduling problems.")]
    3636  [StorableClass]
    37   public class Schedule : ParameterizedNamedItem{
     37  public class Schedule : NamedItem{
    3838    [StorableConstructor]
    3939    protected Schedule(bool deserializing) : base(deserializing) { }
     
    4141      : base(original, cloner) {
    4242        this.Resources = cloner.Clone (original.Resources);
     43        this.Quality = cloner.Clone(original.Quality);
    4344    }
    4445    public override IDeepCloneable Clone(Cloner cloner) {
     
    4647    }
    4748
     49    [Storable]
     50    public ItemList<Resource> Resources;
    4851
    49     #region Parameter Properties
    50     public ValueParameter<ItemList<Resource>> ResourcesParameter {
    51       get { return (ValueParameter<ItemList<Resource>>)Parameters["Resources"]; }
     52    [Storable]
     53    public DoubleValue Quality {
     54      get;
     55      set;
    5256    }
    53     #endregion
    54 
    55     #region Properties
    56     public ItemList<Resource> Resources {
    57       get { return ResourcesParameter.Value; }
    58       set { ResourcesParameter.Value = value; }
    59     }
    60     #endregion
    61 
    6257
    6358    public Schedule(IntValue nrOfResources) {
    64       Parameters.Add(new ValueParameter<ItemList<Resource>>("Resources", "Taskdata defining duration, start-time and resource assignment of the tasks.", new ItemList<Resource>()));
     59      Resources = new ItemList<Resource>();
     60      Quality = new DoubleValue();
    6561      for (int i = 0; i < nrOfResources.Value; i++) {
    6662        Resources.Add(new Resource(new IntValue (i)));
     
    6864    }
    6965
    70 
    71     public event PropertyChangedEventHandler PropertyChanged;
    72     private void OnPropertyChanged(string propertyName) {
    73       var handler = PropertyChanged;
    74       if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
    75     }
    76 
    77 
    7866    public override string ToString() {
    7967      StringBuilder sb = new StringBuilder();
    8068      sb.Append("[ ");
    81 
    8269      foreach (Resource r in Resources) {
    8370        sb.Append(r.ToString () + " \n");
    8471      }
    85 
    8672      sb.Append("]");
    8773      return sb.ToString();
    8874    }
    89 
    9075  }
    9176}
  • branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/SchedulingProblem.cs

    r6121 r6177  
    2828using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2929using HeuristicLab.Common;
     30using HeuristicLab.Problems.Scheduling.Interfaces;
    3031
    3132namespace HeuristicLab.Problems.Scheduling {
    3233  [Item("Scheduling Problem", "Abstract class that represents a Scheduling Problem")]
    3334  [StorableClass]
    34   public abstract class SchedulingProblem : SingleObjectiveHeuristicOptimizationProblem<JSSPEvaluator, SchedulingCreator> {
     35  public abstract class SchedulingProblem : SingleObjectiveHeuristicOptimizationProblem<ISchedulingEvaluator, ISchedulingCreator> {
    3536    [StorableConstructor]
    3637    protected SchedulingProblem(bool deserializing) : base(deserializing) { }
     
    3940    }
    4041
    41     protected SchedulingProblem (JSSPEvaluator se, SchedulingCreator sc) : base (se, sc) {}
     42    protected SchedulingProblem (ISchedulingEvaluator se, ISchedulingCreator sc) : base (se, sc) {}
    4243
    4344  }
Note: See TracChangeset for help on using the changeset viewer.