Changeset 6177
- Timestamp:
- 05/10/11 17:25:35 (14 years ago)
- 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 36 36 <Reference Include="System.Drawing" /> 37 37 <Reference Include="System.Windows.Forms" /> 38 <Reference Include="System.Windows.Forms.DataVisualization" /> 38 39 <Reference Include="System.Xml.Linq" /> 39 40 <Reference Include="System.Data.DataSetExtensions" /> … … 43 44 </ItemGroup> 44 45 <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> 45 52 <Compile Include="JobShopSchedulingProblemView.cs"> 46 53 <SubType>UserControl</SubType> … … 154 161 <Name>HeuristicLab.Problems.VehicleRouting-3.3</Name> 155 162 </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> 158 172 <EmbeddedResource Include="JobShopSchedulingProblemView.resx"> 159 173 <DependentUpon>JobShopSchedulingProblemView.cs</DependentUpon> -
branches/Scheduling/HeuristicLab.Problems.Scheduling.Views/3.3/JobShopSchedulingProblemView.Designer.cs
r6121 r6177 29 29 this.tabPage1 = new System.Windows.Forms.TabPage(); 30 30 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(); 32 32 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 33 33 this.tabControl1.SuspendLayout(); … … 98 98 // tabPage2 99 99 // 100 this.tabPage2.Controls.Add(this. scheduleView1);100 this.tabPage2.Controls.Add(this.ganttChart); 101 101 this.tabPage2.Location = new System.Drawing.Point(4, 22); 102 102 this.tabPage2.Name = "tabPage2"; … … 107 107 this.tabPage2.UseVisualStyleBackColor = true; 108 108 // 109 // scheduleView1109 // ganttChart 110 110 // 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; 121 115 // 122 116 // JobShopSchedulingProblemView … … 149 143 private System.Windows.Forms.TabPage tabPage1; 150 144 private System.Windows.Forms.TabPage tabPage2; 151 private ScheduleView scheduleView1;145 private GanttChart ganttChart; 152 146 } 153 147 } -
branches/Scheduling/HeuristicLab.Problems.Scheduling.Views/3.3/JobShopSchedulingProblemView.cs
r6121 r6177 28 28 using HeuristicLab.Parameters; 29 29 using HeuristicLab.PluginInfrastructure; 30 using System.Drawing; 30 31 31 32 namespace HeuristicLab.Problems.Scheduling.Views { … … 47 48 if (Content == null) { 48 49 parameterCollectionView.Content = null; 49 scheduleView1.Content = null;50 ganttChart.Reset(); 50 51 } else { 51 52 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++; 53 74 } 54 75 } … … 75 96 Content.ImportSolution(spImportDialog.OptimalScheduleFileName); 76 97 * */ 98 OnContentChanged(); 77 99 } 78 100 catch (Exception ex) { -
branches/Scheduling/HeuristicLab.Problems.Scheduling.Views/3.3/JobShopSchedulingProblemView.resx
r6121 r6177 121 121 <value>107, 17</value> 122 122 </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>126 123 <metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> 127 124 <value>17, 17</value> -
branches/Scheduling/HeuristicLab.Problems.Scheduling.Views/3.3/Plugin.cs
r6121 r6177 23 23 24 24 namespace HeuristicLab.Problems.Scheduling.Views { 25 [Plugin("HeuristicLab.Problems.Scheduling.Views", "3.3.3. 0")]25 [Plugin("HeuristicLab.Problems.Scheduling.Views", "3.3.3.6121")] 26 26 [PluginFile("HeuristicLab.Problems.Scheduling.Views-3.3.dll", PluginFileType.Assembly)] 27 27 public class HeuristicLabProblemsSchedulingViewsPlugin : PluginBase { -
branches/Scheduling/HeuristicLab.Problems.Scheduling.Views/3.3/Properties/AssemblyInfo.cs
r6121 r6177 53 53 // by using the '*' as shown below: 54 54 [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 24 24 /// </summary> 25 25 private void InitializeComponent() { 26 this. parameterCollectionView = new HeuristicLab.Core.Views.ParameterCollectionView();26 this.ganttChart = new HeuristicLab.Problems.Scheduling.Views.GanttChart(); 27 27 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 28 28 this.SuspendLayout(); … … 38 38 this.infoLabel.Location = new System.Drawing.Point(510, 3); 39 39 // 40 // parameterCollectionView40 // ganttChart 41 41 // 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) 44 43 | System.Windows.Forms.AnchorStyles.Left) 45 44 | 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; 53 49 // 54 50 // ScheduleView … … 56 52 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 57 53 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 58 this.Controls.Add(this. parameterCollectionView);54 this.Controls.Add(this.ganttChart); 59 55 this.Name = "ScheduleView"; 60 56 this.Size = new System.Drawing.Size(529, 345); 61 this.Controls.SetChildIndex(this. parameterCollectionView, 0);57 this.Controls.SetChildIndex(this.ganttChart, 0); 62 58 this.Controls.SetChildIndex(this.nameLabel, 0); 63 59 this.Controls.SetChildIndex(this.nameTextBox, 0); … … 71 67 #endregion 72 68 73 private Core.Views.ParameterCollectionView parameterCollectionView; 69 private GanttChart ganttChart; 70 74 71 } 75 72 } -
branches/Scheduling/HeuristicLab.Problems.Scheduling.Views/3.3/ScheduleView.cs
r6121 r6177 48 48 base.OnContentChanged(); 49 49 if (Content == null) { 50 parameterCollectionView.Content = null;50 ResetGanttChart(); 51 51 } 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++; 53 81 } 54 82 } … … 56 84 protected override void SetEnabledStateOfControls() { 57 85 base.SetEnabledStateOfControls(); 58 parameterCollectionView.Enabled = Content != null;86 ganttChart.Enabled = Content != null; 59 87 } 60 88 } -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Analyzers/BestSchedulingSolutionAnalyzer.cs
r6121 r6177 36 36 [Item("BestSchedulingSolutionAnalyzer", "An operator for analyzing the best solution of Scheduling Problems given in schedule-representation.")] 37 37 [StorableClass] 38 public sealed class BestSchedulingSolutionAnalyzer : SchedulingOperator, IAnalyzer, IStochasticOperator {38 public sealed class BestSchedulingSolutionAnalyzer : JSSPOperator, IAnalyzer, IStochasticOperator { 39 39 [StorableConstructor] 40 40 private BestSchedulingSolutionAnalyzer(bool deserializing) : base(deserializing) { } … … 61 61 get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters["Quality"]; } 62 62 } 63 public LookupParameter< JSSPEncoding> BestSolutionParameter {64 get { return (LookupParameter< JSSPEncoding>)Parameters["BestSolution"]; }63 public LookupParameter<Schedule> BestSolutionParameter { 64 get { return (LookupParameter<Schedule>)Parameters["BestSolution"]; } 65 65 } 66 66 public ValueLookupParameter<ResultCollection> ResultsParameter { … … 70 70 get { return (LookupParameter<DoubleValue>)Parameters["BestKnownQuality"]; } 71 71 } 72 public LookupParameter< JSSPEncoding> BestKnownSolutionParameter {73 get { return (LookupParameter< JSSPEncoding>)Parameters["BestKnownSolution"]; }72 public LookupParameter<Schedule> BestKnownSolutionParameter { 73 get { return (LookupParameter<Schedule>)Parameters["BestKnownSolution"]; } 74 74 } 75 public ScopeTreeLookupParameter< JSSPEncoding> SchedulingSolutionParameter {76 get { return (ScopeTreeLookupParameter< JSSPEncoding>)Parameters["SchedulingSolution"]; }75 public ScopeTreeLookupParameter<Schedule> SchedulingSolutionParameter { 76 get { return (ScopeTreeLookupParameter<Schedule>)Parameters["DecodedSchedulingSolution"]; } 77 77 } 78 78 … … 84 84 Parameters.Add(new LookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem.")); 85 85 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.")); 88 88 Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The result collection where the best JSSP solution should be stored.")); 89 89 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.")); 91 91 } 92 92 93 93 94 94 public override IOperation Apply() { 95 IntValue nrOfResources = NrOfResources;96 95 ItemList<JSSPJob> jobs = Jobs; 97 96 ItemArray<DoubleValue> qualities = QualityParameter.ActualValue; 98 ItemArray< JSSPEncoding> solutions = SchedulingSolutionParameter.ActualValue;97 ItemArray<Schedule> solutions = SchedulingSolutionParameter.ActualValue; 99 98 ResultCollection results = ResultsParameter.ActualValue; 100 99 bool max = MaximizationParameter.ActualValue.Value; … … 110 109 !max && qualities[i].Value < bestKnownQuality.Value) { 111 110 BestKnownQualityParameter.ActualValue = new DoubleValue(qualities[i].Value); 112 BestKnownSolutionParameter.ActualValue = ( JSSPEncoding)solutions[i].Clone();111 BestKnownSolutionParameter.ActualValue = (Schedule)solutions[i].Clone(); 113 112 } 114 113 115 JSSPEncodingbestSolution = BestSolutionParameter.ActualValue;114 Schedule bestSolution = BestSolutionParameter.ActualValue; 116 115 if (bestSolution == null) { 117 bestSolution = ( JSSPEncoding)solutions[i].Clone();116 bestSolution = (Schedule)solutions[i].Clone(); 118 117 bestSolution.Quality.Value = qualities [i].Value; 119 118 BestSolutionParameter.ActualValue = bestSolution; … … 122 121 if (max && bestSolution.Quality.Value < qualities[i].Value || 123 122 !max && bestSolution.Quality.Value > qualities[i].Value) { 124 bestSolution = ( JSSPEncoding)solutions[i].Clone();123 bestSolution = (Schedule)solutions[i].Clone(); 125 124 bestSolution.Quality.Value = qualities[i].Value; 126 125 } -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Encodings/JSSPCreator.cs
r6121 r6177 29 29 using HeuristicLab.Parameters; 30 30 using HeuristicLab.Problems.Scheduling.Encodings; 31 using HeuristicLab.Problems.Scheduling.Interfaces; 31 32 32 33 namespace HeuristicLab.Problems.Scheduling.Encodings { 33 34 [Item("JobShop Scheduling Problem Creator", "Represents the generalized form of creators for JobShop Scheduling Problems.")] 34 35 [StorableClass] 35 public abstract class JSSPCreator<T> : SchedulingCreator where T :JSSPEncoding{36 public abstract class JSSPCreator<T> :JSSPOperator, IJSSPCreator where T : Item, IJSSPEncoding{ 36 37 [StorableConstructor] 37 38 protected JSSPCreator(bool deserializing) : base(deserializing) { } … … 48 49 } 49 50 51 protected abstract T CreateSolution(); 52 50 53 public override IOperation Apply() { 51 54 SchedulingSolutionParameter.ActualValue = CreateSolution(); 52 55 return base.Apply(); 53 56 } 54 55 56 protected abstract T CreateSolution();57 58 57 } 59 58 } -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Encodings/JSSPCrossover.cs
r6121 r6177 25 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 26 using HeuristicLab.Problems.Scheduling.Interfaces; 27 using HeuristicLab.Optimization; 27 28 28 29 namespace HeuristicLab.Problems.Scheduling.Encodings { 29 30 [Item("JSSPCrossover", "A scheduling crossover operation.")] 30 31 [StorableClass] 31 public abstract class JSSPCrossover : SchedulingOperator, IJSSPCrossover {32 public abstract class JSSPCrossover : JSSPOperator, IJSSPCrossover, IStochasticOperator { 32 33 #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"]; } 35 36 } 36 37 37 public ILookupParameter< JSSPEncoding> ChildParameter {38 get { return (ILookupParameter< JSSPEncoding>)Parameters["Child"]; }38 public ILookupParameter<IJSSPEncoding> ChildParameter { 39 get { return (ILookupParameter<IJSSPEncoding>)Parameters["Child"]; } 39 40 } 40 41 #endregion 42 43 public ILookupParameter<IRandom> RandomParameter { 44 get { return (LookupParameter<IRandom>)Parameters["Random"]; } 45 } 41 46 42 47 [StorableConstructor] … … 47 52 public JSSPCrossover() 48 53 : 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.")); 50 56 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.")); 52 58 ChildParameter.ActualName = "SchedulingSolution"; 53 59 } -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Encodings/JSSPManipulator.cs
r6121 r6177 25 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 26 using HeuristicLab.Problems.Scheduling.Interfaces; 27 using HeuristicLab.Optimization; 27 28 28 29 namespace HeuristicLab.Problems.Scheduling.Encodings { 29 30 [Item("JSSPManipulator", "A JSSP manipulation operation.")] 30 31 [StorableClass] 31 public abstract class JSSPManipulator : SchedulingOperator, IJSSPManipulator {32 public abstract class JSSPManipulator : JSSPOperator, IJSSPManipulator, IStochasticOperator { 32 33 #region IJSSPManipulator Members 33 34 34 public ILookupParameter< JSSPEncoding> SchedulingSolutionParameter {35 get { return (ILookupParameter< JSSPEncoding>)Parameters["SchedulingSolution"]; }35 public ILookupParameter<IJSSPEncoding> SchedulingSolutionParameter { 36 get { return (ILookupParameter<IJSSPEncoding>)Parameters["SchedulingSolution"]; } 36 37 } 37 38 38 39 #endregion 40 41 public ILookupParameter<IRandom> RandomParameter { 42 get { return (LookupParameter<IRandom>)Parameters["Random"]; } 43 } 39 44 40 45 [StorableConstructor] … … 45 50 public JSSPManipulator() 46 51 : 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.")); 48 54 } 49 55 -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Encodings/JobSequenceMatrix/Crossovers/JSMCrossover.cs
r6121 r6177 30 30 [Item("JSMCrossover", "An operator which crosses two JSM representations.")] 31 31 [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 { 36 33 37 34 [StorableConstructor] … … 40 37 public JSMCrossover() 41 38 : base() { 42 Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators."));43 39 } 44 40 45 p rotected abstractJSSPEncoding Crossover(IRandom random, JSMEncoding parent1, JSMEncoding parent2);41 public abstract IJSSPEncoding Crossover(IRandom random, JSMEncoding parent1, JSMEncoding parent2); 46 42 47 43 public override IOperation Apply() { 48 ItemArray< JSSPEncoding> parents = ParentsParameter.ActualValue;44 ItemArray<IJSSPEncoding> parents = ParentsParameter.ActualValue; 49 45 50 46 ChildParameter.ActualValue = -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Encodings/JobSequenceMatrix/Crossovers/JSMSXXCrossover.cs
r6121 r6177 27 27 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 28 using HeuristicLab.Core; 29 using HeuristicLab.Problems.Scheduling.Interfaces; 30 using HeuristicLab.Encodings.PermutationEncoding; 29 31 30 32 namespace HeuristicLab.Problems.Scheduling.Encodings.JobSequenceMatrix.Crossovers { 31 [Item("JSM Subsequence Exchange Crossover", "Represents a crossover operation swappingsubsequences 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.")] 32 34 [StorableClass] 33 35 public class JSMSXXCrossover : JSMCrossover { … … 43 45 public JSMSXXCrossover () : base () {} 44 46 45 p rotected override JSSPEncoding Crossover(IRandom random, JSMEncoding parent1, JSMEncoding parent2) {46 JS SPEncoding result = parent1;47 public static IJSSPEncoding Cross(IRandom random, JSMEncoding parent1, JSMEncoding parent2) { 48 JSMEncoding result = new JSMEncoding(); 47 49 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 } 48 61 49 62 return result; 50 63 } 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 } 51 107 } 52 108 } -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Encodings/JobSequenceMatrix/JSMDecoder.cs
r6121 r6177 35 35 [Item("Job Sequencing Matrix Decoder", "Applies the GifflerThompson algorithm to create an active schedule from a JobSequencing Matrix.")] 36 36 [StorableClass] 37 public class JSMDecoder : NamedItem{37 public class JSMDecoder : JSSPDecoder<JSMEncoding>, IStochasticOperator { 38 38 [StorableConstructor] 39 39 protected JSMDecoder(bool deserializing) : base(deserializing) { } … … 41 41 : base(original, cloner) { 42 42 this.resultingSchedule = cloner.Clone(original.resultingSchedule); 43 this.decodingErrorPolicy = original.decodingErrorPolicy; 44 this.forcingStrategy = original.forcingStrategy; 43 45 } 44 46 public override IDeepCloneable Clone(Cloner cloner) { … … 46 48 } 47 49 50 public ILookupParameter<IRandom> RandomParameter { 51 get { return (LookupParameter<IRandom>)Parameters["Random"]; } 52 } 53 48 54 [Storable] 49 55 private Schedule resultingSchedule; 50 56 51 57 [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() 55 64 : 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 91 68 private ItemList<JSSPTask> GetEarliestNotScheduledTasks(ItemList<JSSPJob> jobs) { 92 69 ItemList<JSSPTask> result = new ItemList<JSSPTask>(); … … 132 109 IntValue solutionCandidateJobNr = new IntValue(jsm[conflictedResource.Value][progressOnResource.Value]); 133 110 foreach (JSSPTask t in conflictSet) { 134 if (t.Job. JobIndex == solutionCandidateJobNr)111 if (t.Job.Index.Value == solutionCandidateJobNr.Value) 135 112 result = t; 136 113 } … … 141 118 //Repairing happens here 142 119 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 144 128 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) 148 131 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 } */ 156 161 } 157 162 private DoubleValue ComputeEarliestStartTime(JSSPTask t) { … … 174 179 affectedResource.Tasks.Add(selectedTask); 175 180 } 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 } 176 220 } 177 221 } -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Encodings/JobSequenceMatrix/JSMEncoding.cs
r6121 r6177 29 29 using HeuristicLab.Encodings.PermutationEncoding; 30 30 using HeuristicLab.Data; 31 using HeuristicLab.Problems.Scheduling.Encodings; 31 using HeuristicLab.Problems.Scheduling.Interfaces; 32 using HeuristicLab.Problems.Scheduling.Encodings.JobSequenceMatrix.Crossovers; 33 using HeuristicLab.Problems.Scheduling.Encodings.JobSequenceMatrix.Manipulators; 32 34 33 35 namespace HeuristicLab.Problems.Scheduling.Encodings.JobSequenceMatrix { 34 36 [Item("Job Sequencing Matrix Encoding", "Represents a solution for a standard JobShop Scheduling Problem.")] 35 37 [StorableClass] 36 public class JSMEncoding : JSSPEncoding{38 public class JSMEncoding : ParameterizedNamedItem, IJSSPEncoding{ 37 39 [StorableConstructor] 38 40 protected JSMEncoding(bool deserializing) : base(deserializing) { } … … 52 54 } 53 55 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 59 56 public override string ToString() { 60 57 StringBuilder sb = new StringBuilder(); -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Encodings/JobSequenceMatrix/JSMRandomCreator.cs
r6121 r6177 64 64 JSMEncoding solution = new JSMEncoding(); 65 65 IntValue nrOfJobs = new IntValue (Jobs.Count); 66 IntValue nrOfResources = NrOfResources;66 IntValue nrOfResources = new IntValue (Jobs[0].Tasks.Count); 67 67 68 68 for (int i = 0; i < nrOfResources.Value; i++) { -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Encodings/JobSequenceMatrix/Manipulators/JSMManipulator.cs
r6121 r6177 32 32 [Item("AlbaManipulator", "An operator which manipulates a VRP representation.")] 33 33 [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 { 39 35 [StorableConstructor] 40 36 protected JSMManipulator(bool deserializing) : base(deserializing) { } … … 42 38 public JSMManipulator() 43 39 : base() { 44 Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators."));45 40 } 46 41 … … 49 44 50 45 public override IOperation Apply() { 51 JSSPEncoding solution = SchedulingSolutionParameter.ActualValue;46 IJSSPEncoding solution = SchedulingSolutionParameter.ActualValue; 52 47 53 48 SchedulingSolutionParameter.ActualValue = Manipulate(RandomParameter.ActualValue, solution as JSMEncoding); -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Evaluators/MakespanEvaluator.cs
r6121 r6177 34 34 [Item("Makespan Evaluator", "Represents an evaluator using the maximum makespan of a schedule.")] 35 35 [StorableClass] 36 public class MakespanEvaluator : JSSPEvaluator , IStochasticOperator{36 public class MakespanEvaluator : JSSPEvaluator { 37 37 [StorableConstructor] 38 38 protected MakespanEvaluator(bool deserializing) : base(deserializing) { } … … 44 44 } 45 45 46 47 48 46 public MakespanEvaluator () : base () { } 49 50 47 51 48 protected override DoubleValue evaluate(Schedule schedule) { -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/HeuristicLab.Problems.Scheduling-3.3.csproj
r6121 r6177 49 49 <ItemGroup> 50 50 <Compile Include="Analyzers\BestSchedulingSolutionAnalyzer.cs" /> 51 <Compile Include="Encodings\JobSequenceMatrix\JSMDecodingErrorPolicyTypes.cs" /> 52 <Compile Include="Encodings\JobSequenceMatrix\Crossovers\JSMJOXCrossover.cs" /> 51 53 <Compile Include="Encodings\JobSequenceMatrix\Crossovers\JSMCrossover.cs" /> 54 <Compile Include="Encodings\JobSequenceMatrix\Crossovers\JSMOrderCrossover.cs" /> 52 55 <Compile Include="Encodings\JobSequenceMatrix\Crossovers\JSMSXXCrossover.cs" /> 53 56 <Compile Include="Encodings\JobSequenceMatrix\JSMDecoder.cs" /> 57 <Compile Include="Encodings\JobSequenceMatrix\JSMForcingStrategyTypes.cs" /> 54 58 <Compile Include="Encodings\JobSequenceMatrix\JSMRandomCreator.cs" /> 55 59 <Compile Include="Encodings\JobSequenceMatrix\JSMEncoding.cs" /> 60 <Compile Include="Encodings\JobSequenceMatrix\Manipulators\JSMShiftChangeManipulator.cs" /> 56 61 <Compile Include="Encodings\JobSequenceMatrix\Manipulators\JSMManipulator.cs" /> 57 <Compile Include="Encodings\JobSequenceMatrix\Manipulators\JSM SwapManipulator.cs" />62 <Compile Include="Encodings\JobSequenceMatrix\Manipulators\JSMInsertionManipulator.cs" /> 58 63 <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" /> 60 74 <Compile Include="Encodings\JSSPCreator.cs" /> 61 75 <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" /> 62 80 <Compile Include="Evaluators\MakespanEvaluator.cs" /> 81 <Compile Include="IndexedTaskList.cs" /> 63 82 <Compile Include="Interfaces\IJSMOperator.cs" /> 64 83 <Compile Include="Interfaces\IJSSPCrossover.cs" /> 65 84 <Compile Include="Interfaces\IJSSPManipulator.cs" /> 85 <Compile Include="Interfaces\ISchedulingCreator.cs" /> 86 <Compile Include="Interfaces\ISchedulingEvaluator.cs" /> 66 87 <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" /> 69 90 <Compile Include="JSSPJob.cs" /> 70 91 <Compile Include="JobShopSchedulingProblem.cs" /> 71 92 <Compile Include="JSSPTask.cs" /> 72 <Compile Include="SchedulingOperator.cs" /> 93 <Compile Include="Encodings\JSSPOperator.cs" /> 94 <Compile Include="Evaluators\SchedulingEvaluator.cs" /> 73 95 <Compile Include="SchedulingProblem.cs" /> 74 <Compile Include="Task.cs" />75 96 <Compile Include="Plugin.cs" /> 76 97 <Compile Include="Properties\AssemblyInfo.cs" /> … … 103 124 <Name>HeuristicLab.Data-3.3</Name> 104 125 </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> 105 130 <ProjectReference Include="..\..\HeuristicLab.Encodings.PermutationEncoding\3.3\HeuristicLab.Encodings.PermutationEncoding-3.3.csproj"> 106 131 <Project>{DBECB8B0-B166-4133-BAF1-ED67C3FD7FCA}</Project> … … 128 153 </ProjectReference> 129 154 </ItemGroup> 130 <ItemGroup> 131 <Folder Include="Encodings\PriorityRulesVector\" /> 132 </ItemGroup> 155 <ItemGroup /> 133 156 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 134 157 <PropertyGroup> -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Interfaces/IJSSPCrossover.cs
r6121 r6177 8 8 9 9 namespace 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; } 13 13 } 14 14 } -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Interfaces/IJSSPManipulator.cs
r6121 r6177 26 26 namespace HeuristicLab.Problems.Scheduling.Interfaces { 27 27 public interface IJSSPManipulator : IManipulator { 28 ILookupParameter< JSSPEncoding> SchedulingSolutionParameter { get; }28 ILookupParameter<IJSSPEncoding> SchedulingSolutionParameter { get; } 29 29 } 30 30 } -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/JSSPJob.cs
r6121 r6177 33 33 [Item("Job Class", "Represents a composition of tasks that require processing in a job shop scheduling problem.")] 34 34 [StorableClass] 35 public class JSSPJob : ParameterizedNamedItem{35 public class JSSPJob : IndexedTaskList { 36 36 [StorableConstructor] 37 37 protected JSSPJob(bool deserializing) : base(deserializing) { } 38 38 protected JSSPJob(JSSPJob original, Cloner cloner) 39 39 : base(original, cloner) { 40 this.JobIndex = cloner.Clone(original.JobIndex);41 this.Tasks = cloner.Clone(original.Tasks);42 40 } 43 41 public override IDeepCloneable Clone(Cloner cloner) { … … 45 43 } 46 44 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) {} 77 46 78 47 public override string ToString() { 79 48 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) { 82 51 sb.Append(t.ToString () + " "); 83 52 } … … 85 54 return sb.ToString(); 86 55 } 87 88 56 } 89 57 } -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/JSSPTask.cs
r6121 r6177 32 32 [Item("Job Shop Scheduling Task Class", "Represents smallest unit for a job shop scheduling problem.")] 33 33 [StorableClass] 34 public class JSSPTask : Task{34 public class JSSPTask : Item { 35 35 [StorableConstructor] 36 36 protected JSSPTask(bool deserializing) : base(deserializing) { } 37 37 protected JSSPTask(JSSPTask original, Cloner cloner) 38 38 : 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); 39 44 this.Job = cloner.Clone(original.Job); 40 45 this.PreviousTask = cloner.Clone(original.PreviousTask); 46 this.NextTask = cloner.Clone(original.NextTask); 41 47 } 42 48 public override IDeepCloneable Clone(Cloner cloner) { … … 45 51 46 52 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; } 47 66 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); 52 73 Job = j; 53 74 } -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/JobShopSchedulingProblem.cs
r6121 r6177 41 41 using HeuristicLab.Problems.Scheduling.Encodings.JobSequenceMatrix.Crossovers; 42 42 using HeuristicLab.Problems.Scheduling.Interfaces; 43 using HeuristicLab.Problems.Scheduling.Encodings.PriorityRulesVector; 44 using HeuristicLab.Encodings.IntegerVectorEncoding; 43 45 44 46 namespace HeuristicLab.Problems.Scheduling { … … 52 54 : base(original, cloner) { 53 55 operators = original.operators.Select(x => (IOperator)cloner.Clone(x)).ToList(); 56 this.encodingType = original.encodingType; 57 AttachEventHandlers(); 54 58 } 55 59 public override IDeepCloneable Clone(Cloner cloner) { … … 59 63 60 64 #region Parameter Properties 61 public ValueParameter<IntValue> NrOfResourcesParameter {62 get { return (ValueParameter<IntValue>)Parameters["NrOfResources"]; }63 }64 65 public ValueParameter<ItemList<JSSPJob>> JobsParameter { 65 66 get { return (ValueParameter<ItemList<JSSPJob>>)Parameters["Jobs"]; } 66 67 } 67 public OptionalValueParameter< JSSPEncoding> BestKnownSolutionParameter {68 get { return (OptionalValueParameter< JSSPEncoding>)Parameters["BestKnownSolution"]; }68 public OptionalValueParameter<Schedule> BestKnownSolutionParameter { 69 get { return (OptionalValueParameter<Schedule>)Parameters["BestKnownSolution"]; } 69 70 } 70 71 #endregion 71 72 72 73 #region Properties 73 public IntValue NrOfResources {74 get { return NrOfResourcesParameter.Value; }75 set { NrOfResourcesParameter.Value = value; }76 }77 74 public ItemList<JSSPJob> Jobs { 78 75 get { return JobsParameter.Value; } 79 76 set { JobsParameter.Value = value; } 80 77 } 81 public JSSPEncodingBestKnownSolution {78 public Schedule BestKnownSolution { 82 79 get { return BestKnownSolutionParameter.Value; } 83 80 set { BestKnownSolutionParameter.Value = value; } … … 89 86 private List<IOperator> operators; 90 87 88 [Storable] 89 private JSSPEncodingTypes encodingType; 91 90 92 91 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 ()) { 95 93 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; 98 96 InitializeOperators(); 97 AttachEventHandlers(); 99 98 } 100 99 101 100 #region Events 102 101 //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 } 103 110 #endregion 104 111 105 112 #region Helpers 106 113 private void InitializeOperators() { 107 Operators.AddRange(ApplicationManager.Manager.GetInstances<IJSMOperator>()); 114 Operators.Clear(); 115 ApplyEncoding(); 108 116 Operators.Add(new BestSchedulingSolutionAnalyzer()); 109 117 //ParameterizeAnalyzer(); 110 118 //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 } 111 131 } 112 132 … … 148 168 string line = problemFile.ReadLine(); 149 169 List<string> data = SplitString(line); 150 int taskCount = 0;151 170 if (data.Count > 0 && ((int)data[0][0] >= 48 && (int)data[0][0] <= 57)) { 152 NrOfResources = new IntValue(Int32.Parse(data[1]));153 171 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])); 154 176 line = problemFile.ReadLine(); 155 177 data = SplitString(line); … … 157 179 JSSPJob j = new JSSPJob(new IntValue(jobCount)); 158 180 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) { 162 183 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 } 163 187 j.Tasks.Add(t); 164 188 i++; -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Resource.cs
r6121 r6177 30 30 using HeuristicLab.Common; 31 31 32 //ATTENTION! This class may have lots of parallels with the HeuristicLab.Problems.Scheduling.JSSPJob class.33 34 32 namespace HeuristicLab.Problems.Scheduling { 35 33 [Item("Resource Class", "Represents a resource used in scheduling problems.")] 36 34 [StorableClass] 37 public class Resource : ParameterizedNamedItem{35 public class Resource : IndexedTaskList { 38 36 [StorableConstructor] 39 37 protected Resource(bool deserializing) : base(deserializing) { } 40 38 protected Resource(Resource original, Cloner cloner) 41 39 : base(original, cloner) { 42 this.ResourceIndex = cloner.Clone(original.ResourceIndex);43 this.Tasks = cloner.Clone(original.Tasks);44 40 } 45 41 public override IDeepCloneable Clone(Cloner cloner) { … … 47 43 } 48 44 49 #region Parameter Properties50 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 #endregion57 58 #region Properties59 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 }67 45 public DoubleValue TotalDuration { 68 46 get { … … 73 51 } 74 52 } 75 #endregion76 53 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) { } 86 55 87 56 public override string ToString() { 88 57 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) { 91 60 sb.Append(t.ToString() + " "); 92 61 } … … 94 63 return sb.ToString(); 95 64 } 96 97 65 } 98 66 } -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Schedule.cs
r6121 r6177 35 35 [Item("Schedule Class", "Represents the general solution for scheduling problems.")] 36 36 [StorableClass] 37 public class Schedule : ParameterizedNamedItem{37 public class Schedule : NamedItem{ 38 38 [StorableConstructor] 39 39 protected Schedule(bool deserializing) : base(deserializing) { } … … 41 41 : base(original, cloner) { 42 42 this.Resources = cloner.Clone (original.Resources); 43 this.Quality = cloner.Clone(original.Quality); 43 44 } 44 45 public override IDeepCloneable Clone(Cloner cloner) { … … 46 47 } 47 48 49 [Storable] 50 public ItemList<Resource> Resources; 48 51 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; 52 56 } 53 #endregion54 55 #region Properties56 public ItemList<Resource> Resources {57 get { return ResourcesParameter.Value; }58 set { ResourcesParameter.Value = value; }59 }60 #endregion61 62 57 63 58 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(); 65 61 for (int i = 0; i < nrOfResources.Value; i++) { 66 62 Resources.Add(new Resource(new IntValue (i))); … … 68 64 } 69 65 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 78 66 public override string ToString() { 79 67 StringBuilder sb = new StringBuilder(); 80 68 sb.Append("[ "); 81 82 69 foreach (Resource r in Resources) { 83 70 sb.Append(r.ToString () + " \n"); 84 71 } 85 86 72 sb.Append("]"); 87 73 return sb.ToString(); 88 74 } 89 90 75 } 91 76 } -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/SchedulingProblem.cs
r6121 r6177 28 28 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 29 using HeuristicLab.Common; 30 using HeuristicLab.Problems.Scheduling.Interfaces; 30 31 31 32 namespace HeuristicLab.Problems.Scheduling { 32 33 [Item("Scheduling Problem", "Abstract class that represents a Scheduling Problem")] 33 34 [StorableClass] 34 public abstract class SchedulingProblem : SingleObjectiveHeuristicOptimizationProblem< JSSPEvaluator,SchedulingCreator> {35 public abstract class SchedulingProblem : SingleObjectiveHeuristicOptimizationProblem<ISchedulingEvaluator, ISchedulingCreator> { 35 36 [StorableConstructor] 36 37 protected SchedulingProblem(bool deserializing) : base(deserializing) { } … … 39 40 } 40 41 41 protected SchedulingProblem ( JSSPEvaluator se,SchedulingCreator sc) : base (se, sc) {}42 protected SchedulingProblem (ISchedulingEvaluator se, ISchedulingCreator sc) : base (se, sc) {} 42 43 43 44 }
Note: See TracChangeset
for help on using the changeset viewer.