Changeset 6260
- Timestamp:
- 05/24/11 09:47:24 (14 years ago)
- Location:
- branches/Scheduling
- Files:
-
- 20 added
- 9 deleted
- 35 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Scheduling/HeuristicLab.Problems.Scheduling.Views/3.3/GanttChart.Designer.cs
r6177 r6260 54 54 this.chart.TabIndex = 0; 55 55 this.chart.Text = "chart"; 56 this.chart.MouseClick += new System.Windows.Forms.MouseEventHandler(this.chart_MouseClick); 56 57 // 57 58 // GanttChart -
branches/Scheduling/HeuristicLab.Problems.Scheduling.Views/3.3/GanttChart.cs
r6177 r6260 9 9 public partial class GanttChart : UserControl { 10 10 11 private IDictionary< string, Color> categories = new Dictionary<string, Color>();11 private IDictionary<int, Color> jobColors = new SortedDictionary<int, Color>(); 12 12 private IDictionary<string, int> rowNames = new Dictionary<string, int>(); 13 13 14 14 15 public GanttChart() { 15 16 InitializeComponent(); 17 chart.Series[0].YValueType = ChartValueType.Double; 16 18 } 17 19 18 public void AddCategory(string name, Color color) { 19 if (!categories.ContainsKey(name)) { 20 categories[name] = color; 21 chart.Legends[0].CustomItems.Add(color, name); 20 public void AddJobColor(int jobNr) { 21 if (!jobColors.ContainsKey(jobNr)) { 22 Random r = new Random(jobNr + 1); 23 jobColors[jobNr] = Color.FromArgb (r.Next(256),r.Next(256),r.Next(256)); 24 chart.Legends[0].CustomItems.Clear(); 25 if (jobColors.Count > 1) { 26 int i = 0; 27 foreach (Color c in jobColors.Values) { 28 chart.Legends[0].CustomItems.Add(c, "Job#" + (i++)); 29 } 30 } 22 31 } 23 }24 25 public void AddData(string rowName, string category, double start, double end, string tooltip, bool showLabel = true) {26 AddRowName(rowName);27 var point = CreateDataPoint(rowNames[rowName], rowName, start, end, showLabel ? category : string.Empty, categories[category]);28 point.ToolTip = tooltip;29 chart.Series[0].Points.Add(point);30 32 } 31 33 … … 37 39 } 38 40 39 private static DataPoint CreateDataPoint(double x, string axisLabel, double start, double end, string text, Color color) { 40 var point = new DataPoint(x, new double[] { start, end }); 41 point.Color = color; 42 point.Label = text; 43 point.AxisLabel = axisLabel; 44 return point; 41 public void AddData(string rowName, int jobNr, double start, double end, string tooltip, bool showLabel = true) { 42 AddRowName(rowName); 43 var point = new DataPoint(rowNames[rowName], new double[] { start, end }); 44 point.Color = jobColors[jobNr]; 45 point.AxisLabel = rowName; 46 point.ToolTip = tooltip; 47 chart.Series[0].Points.Add(point); 45 48 } 46 49 47 50 public void Reset() { 48 51 chart.Series[0].Points.Clear(); 49 categories.Clear();52 jobColors.Clear(); 50 53 chart.Legends[0].CustomItems.Clear(); 51 54 rowNames.Clear(); 52 55 } 56 57 void chart_MouseClick(object sender, MouseEventArgs e) { 58 var pos = e.Location; 59 var results = chart.HitTest(pos.X, pos.Y, false, ChartElementType.DataPoint); 60 foreach (DataPoint dp in chart.Series[0].Points) { 61 Color newColor = Color.FromArgb(255, dp.Color); 62 dp.Color = newColor; 63 } 64 foreach (var result in results) { 65 if (result.ChartElementType == ChartElementType.DataPoint) { 66 Color currentColor = chart.Series[0].Points[result.PointIndex].Color; 67 foreach (DataPoint dp in result.Series.Points) { 68 if (dp.Color != currentColor) { 69 Color newColor = Color.FromArgb(0, dp.Color); 70 dp.Color = newColor; 71 } 72 } 73 } 74 } 75 } 53 76 } 54 77 } -
branches/Scheduling/HeuristicLab.Problems.Scheduling.Views/3.3/HeuristicLab.Problems.Scheduling.Views-3.3.csproj
r6177 r6260 32 32 </PropertyGroup> 33 33 <ItemGroup> 34 <Reference Include="HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4"> 35 <HintPath>..\..\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding\3.4\bin\Debug\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.dll</HintPath> 36 </Reference> 37 <Reference Include="HeuristicLab.Problems.DataAnalysis-3.4"> 38 <HintPath>..\..\HeuristicLab.Problems.DataAnalysis\3.4\bin\Debug\HeuristicLab.Problems.DataAnalysis-3.4.dll</HintPath> 39 </Reference> 40 <Reference Include="HeuristicLab.Problems.DataAnalysis.Symbolic-3.4"> 41 <HintPath>..\..\HeuristicLab.Problems.DataAnalysis.Symbolic\3.4\bin\Debug\HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.dll</HintPath> 42 </Reference> 43 <Reference Include="HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4"> 44 <HintPath>..\..\HeuristicLab.Problems.DataAnalysis.Symbolic.Regression\3.4\bin\Debug\HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.dll</HintPath> 45 </Reference> 46 <Reference Include="HeuristicLab.Problems.DataAnalysis.Symbolic.Views-3.4"> 47 <HintPath>..\..\HeuristicLab.Problems.DataAnalysis.Symbolic.Views\3.4\bin\Debug\HeuristicLab.Problems.DataAnalysis.Symbolic.Views-3.4.dll</HintPath> 48 </Reference> 49 <Reference Include="HeuristicLab.Problems.DataAnalysis.Views-3.4"> 50 <HintPath>..\..\HeuristicLab.Problems.DataAnalysis.Views\3.4\bin\Debug\HeuristicLab.Problems.DataAnalysis.Views-3.4.dll</HintPath> 51 </Reference> 34 52 <Reference Include="System" /> 35 53 <Reference Include="System.Core" /> … … 153 171 <Name>HeuristicLab.PluginInfrastructure-3.3</Name> 154 172 </ProjectReference> 173 <ProjectReference Include="..\..\HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views\3.4\HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views-3.4.csproj"> 174 <Project>{20831A74-D18F-42D9-A667-1CE3AF53DF93}</Project> 175 <Name>HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views-3.4</Name> 176 </ProjectReference> 155 177 <ProjectReference Include="..\..\HeuristicLab.Problems.Scheduling\3.3\HeuristicLab.Problems.Scheduling-3.3.csproj"> 156 178 <Project>{2BF1D639-1A74-44ED-AAAD-41ECD395AD93}</Project> -
branches/Scheduling/HeuristicLab.Problems.Scheduling.Views/3.3/JobShopSchedulingProblemView.Designer.cs
r6177 r6260 109 109 // ganttChart 110 110 // 111 this.ganttChart.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))); 111 114 this.ganttChart.Location = new System.Drawing.Point(0, 3); 112 115 this.ganttChart.Name = "ganttChart"; -
branches/Scheduling/HeuristicLab.Problems.Scheduling.Views/3.3/JobShopSchedulingProblemView.cs
r6177 r6260 57 57 private void FillGanttChart(JobShopSchedulingProblem content) { 58 58 //Add Jobs as Categories 59 ganttChart.Reset(); 59 60 int jobCount = 0; 60 Random random = new Random( );61 Random random = new Random(1); 61 62 foreach (JSSPJob j in content.Jobs) { 62 63 foreach (JSSPTask t in content.Jobs[jobCount].Tasks) { 63 string categoryName = "ScheduleTasks";64 categoryName = "Job" + t.Job.Index;65 ganttChart.Add Category(categoryName, Color.FromArgb(random.Next(255), random.Next(255), random.Next(255)));64 int categoryNr = t.JobNr.Value; 65 string categoryName = "Job" + categoryNr; 66 ganttChart.AddJobColor(categoryNr); 66 67 ganttChart.AddData(categoryName, 67 categoryN ame,68 categoryNr, 68 69 t.StartTime.Value, 69 70 t.EndTime.Value, 70 "Job" + t.Job.Index + " - " + "Task#" + t.TaskNr.Value.ToString(), 71 false); 71 "Job" + t.JobNr + " - " + "Task#" + t.TaskNr.Value.ToString()); 72 72 } 73 73 jobCount++; … … 92 92 } 93 93 94 /* TODO: Implement solution-import in problem-class 94 95 95 if (!string.IsNullOrEmpty(spImportDialog.OptimalScheduleFileName)) 96 Content.ImportSolution(spImportDialog.OptimalScheduleFileName); 97 * */ 96 Content.ImportJSMSolution(spImportDialog.OptimalScheduleFileName); 98 97 OnContentChanged(); 99 98 } -
branches/Scheduling/HeuristicLab.Problems.Scheduling.Views/3.3/Plugin.cs
r6177 r6260 23 23 24 24 namespace HeuristicLab.Problems.Scheduling.Views { 25 [Plugin("HeuristicLab.Problems.Scheduling.Views", "3.3.3.61 21")]25 [Plugin("HeuristicLab.Problems.Scheduling.Views", "3.3.3.6177")] 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
r6177 r6260 53 53 // by using the '*' as shown below: 54 54 [assembly: AssemblyVersion("3.3.0.0")] 55 [assembly: AssemblyFileVersion("3.3.0.61 21")]55 [assembly: AssemblyFileVersion("3.3.0.6177")] -
branches/Scheduling/HeuristicLab.Problems.Scheduling.Views/3.3/ScheduleView.cs
r6177 r6260 40 40 } 41 41 42 43 protected override void DeregisterContentEvents() { 44 Content.QualityChanged -= new EventHandler(Content_QualityChanged); 45 Content.ResourcesChanged -= new EventHandler(Content_ResourcesChanged); 46 47 base.DeregisterContentEvents(); 48 } 49 protected override void RegisterContentEvents() { 50 base.RegisterContentEvents(); 51 Content.QualityChanged += new EventHandler(Content_QualityChanged); 52 Content.ResourcesChanged += new EventHandler(Content_ResourcesChanged); 53 } 54 55 42 56 public new Schedule Content { 43 57 get { return (Schedule)base.Content; } … … 59 73 60 74 private void FillGanttChart(Schedule content) { 61 //Add Resources as Categories75 ResetGanttChart(); 62 76 int resCount = 0; 63 Random random = new Random ( );77 Random random = new Random (1); 64 78 foreach (Resource r in content.Resources) { 65 79 foreach (JSSPTask t in content.Resources[resCount].Tasks) { 80 int categoryNr = 0; 81 string toolTip = "Task#" + t.TaskNr; 66 82 string categoryName = "ScheduleTasks"; 67 string toolTip = "Task#" + t.TaskNr.Value.ToString();68 83 if (t is JSSPTask) { 69 categoryName = "Job" + ((JSSPTask)t).Job.Index; 84 categoryNr = ((JSSPTask)t).JobNr.Value; 85 categoryName = "Job" + categoryNr; 70 86 toolTip = categoryName + " - " + toolTip; 71 } 72 ganttChart.Add Category(categoryName, Color.FromArgb(random.Next(255), random.Next(255), random.Next(255)));87 } 88 ganttChart.AddJobColor(categoryNr); 73 89 ganttChart.AddData("Resource" + r.Index, 74 categoryN ame,90 categoryNr, 75 91 t.StartTime.Value, 76 92 t.EndTime.Value, 77 toolTip, 78 false); 93 toolTip); 79 94 } 80 95 resCount++; … … 86 101 ganttChart.Enabled = Content != null; 87 102 } 103 104 105 private void Content_QualityChanged(object sender, EventArgs e) { 106 if (InvokeRequired) 107 Invoke(new EventHandler(Content_QualityChanged), sender, e); 108 else { 109 if (Content == null) { 110 ResetGanttChart(); 111 } else { 112 FillGanttChart(Content); 113 } 114 } 115 } 116 117 private void Content_ResourcesChanged(object sender, EventArgs e) { 118 if (InvokeRequired) 119 Invoke(new EventHandler(Content_ResourcesChanged), sender, e); 120 else { 121 if (Content == null) { 122 ResetGanttChart(); 123 } else { 124 FillGanttChart(Content); 125 } 126 } 127 } 88 128 } 89 129 } -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Analyzers/BestSchedulingSolutionAnalyzer.cs
r6177 r6260 121 121 if (max && bestSolution.Quality.Value < qualities[i].Value || 122 122 !max && bestSolution.Quality.Value > qualities[i].Value) { 123 bestSolution = (Schedule)solutions[i].Clone();124 123 bestSolution.Quality.Value = qualities[i].Value; 124 bestSolution.Resources = (ItemList<Resource>)solutions[i].Resources.Clone(); 125 125 } 126 126 } -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Encodings/JSSPCreator.cs
r6177 r6260 34 34 [Item("JobShop Scheduling Problem Creator", "Represents the generalized form of creators for JobShop Scheduling Problems.")] 35 35 [StorableClass] 36 public abstract class JSSPCreator<T> :JSSPOperator, I JSSPCreator where T : Item, IJSSPEncoding{36 public abstract class JSSPCreator<T> :JSSPOperator, ISchedulingCreator where T : Item, ISchedulingEncoding{ 37 37 [StorableConstructor] 38 38 protected JSSPCreator(bool deserializing) : base(deserializing) { } -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Encodings/JSSPCrossover.cs
r6177 r6260 30 30 [Item("JSSPCrossover", "A scheduling crossover operation.")] 31 31 [StorableClass] 32 public abstract class JSSPCrossover : JSSPOperator, IJSSPCrossover, IStochasticOperator{32 public abstract class JSSPCrossover<T> : JSSPOperator, ISchedulingCrossover, IStochasticOperator where T : Item, ISchedulingEncoding { 33 33 #region IJSSPCrossover Members 34 public ILookupParameter<ItemArray< IJSSPEncoding>> ParentsParameter {35 get { return (ScopeTreeLookupParameter< IJSSPEncoding>)Parameters["Parents"]; }34 public ILookupParameter<ItemArray<T>> ParentsParameter { 35 get { return (ScopeTreeLookupParameter<T>)Parameters["Parents"]; } 36 36 } 37 37 38 public ILookupParameter< IJSSPEncoding> ChildParameter {39 get { return (ILookupParameter< IJSSPEncoding>)Parameters["Child"]; }38 public ILookupParameter<T> ChildParameter { 39 get { return (ILookupParameter<T>)Parameters["Child"]; } 40 40 } 41 41 #endregion … … 47 47 [StorableConstructor] 48 48 protected JSSPCrossover(bool deserializing) : base(deserializing) { } 49 protected JSSPCrossover(JSSPCrossover original, Cloner cloner)49 protected JSSPCrossover(JSSPCrossover<T> original, Cloner cloner) 50 50 : base(original, cloner) { 51 51 } … … 53 53 : base() { 54 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."));55 Parameters.Add(new ScopeTreeLookupParameter<T>("Parents", "The parent solution which should be crossed.")); 56 56 ParentsParameter.ActualName = "SchedulingSolution"; 57 Parameters.Add(new LookupParameter< IJSSPEncoding>("Child", "The child solution resulting from the crossover."));57 Parameters.Add(new LookupParameter<T>("Child", "The child solution resulting from the crossover.")); 58 58 ChildParameter.ActualName = "SchedulingSolution"; 59 59 } -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Encodings/JSSPDecoder.cs
r6177 r6260 31 31 32 32 namespace HeuristicLab.Problems.Scheduling.Encodings { 33 public abstract class JSSPDecoder<T> : JSSPOperator, I JSSPDecoder where T : Item, IJSSPEncoding {33 public abstract class JSSPDecoder<T> : JSSPOperator, ISchedulingDecoder where T : Item, ISchedulingEncoding { 34 34 [StorableConstructor] 35 35 protected JSSPDecoder(bool deserializing) : base(deserializing) { } -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Encodings/JSSPEncodingTypes.cs
r6177 r6260 7 7 public enum JSSPEncodingTypes { 8 8 JSMEncoding, 9 PRVEncoding 9 PRVEncoding, 10 PWREncoding 10 11 } 11 12 } -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Encodings/JSSPManipulator.cs
r6177 r6260 30 30 [Item("JSSPManipulator", "A JSSP manipulation operation.")] 31 31 [StorableClass] 32 public abstract class JSSPManipulator : JSSPOperator, IJSSPManipulator, IStochasticOperator{32 public abstract class JSSPManipulator<T> : JSSPOperator, ISchedulingManipulator, IStochasticOperator where T : Item, ISchedulingEncoding { 33 33 #region IJSSPManipulator Members 34 34 35 public ILookupParameter< IJSSPEncoding> SchedulingSolutionParameter {36 get { return (ILookupParameter< IJSSPEncoding>)Parameters["SchedulingSolution"]; }35 public ILookupParameter<T> SchedulingSolutionParameter { 36 get { return (ILookupParameter<T>)Parameters["SchedulingSolution"]; } 37 37 } 38 38 … … 45 45 [StorableConstructor] 46 46 protected JSSPManipulator(bool deserializing) : base(deserializing) { } 47 protected JSSPManipulator(JSSPManipulator original, Cloner cloner)47 protected JSSPManipulator(JSSPManipulator<T> original, Cloner cloner) 48 48 : base(original, cloner) { 49 49 } 50 50 public JSSPManipulator() 51 51 : base() { 52 Parameters.Add(new LookupParameter< IJSSPEncoding>("SchedulingSolution", "The JSSP solution to be manipulated."));52 Parameters.Add(new LookupParameter<T>("SchedulingSolution", "The JSSP solution to be manipulated.")); 53 53 Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators.")); 54 54 } -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Encodings/JSSPOperator.cs
r6177 r6260 35 35 [Item("SchedulingOperator", "A scheduling operator.")] 36 36 [StorableClass] 37 public abstract class JSSPOperator : SingleSuccessorOperator, I JSSPOperator{37 public abstract class JSSPOperator : SingleSuccessorOperator, ISchedulingOperator{ 38 38 [StorableConstructor] 39 39 protected JSSPOperator(bool deserializing) : base(deserializing) { } -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Encodings/JobSequenceMatrix/Crossovers/JSMCrossover.cs
r6177 r6260 30 30 [Item("JSMCrossover", "An operator which crosses two JSM representations.")] 31 31 [StorableClass] 32 public abstract class JSMCrossover : JSSPCrossover , IJSMOperator {32 public abstract class JSMCrossover : JSSPCrossover<JSMEncoding>, IJSMOperator { 33 33 34 34 [StorableConstructor] … … 39 39 } 40 40 41 public abstract IJSSPEncoding Crossover(IRandom random, JSMEncoding parent1, JSMEncoding parent2);41 public abstract JSMEncoding Crossover(IRandom random, JSMEncoding parent1, JSMEncoding parent2); 42 42 43 43 public override IOperation Apply() { 44 ItemArray< IJSSPEncoding> parents = ParentsParameter.ActualValue;44 ItemArray<JSMEncoding> parents = ParentsParameter.ActualValue; 45 45 46 46 ChildParameter.ActualValue = -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Encodings/JobSequenceMatrix/Crossovers/JSMJOXCrossover.cs
r6177 r6260 46 46 public JSMJOXCrossover() : base() { } 47 47 48 public static IJSSPEncoding Cross(IRandom random, JSMEncoding parent1, JSMEncoding parent2) {48 public static JSMEncoding Cross(IRandom random, JSMEncoding p1, JSMEncoding p2) { 49 49 JSMEncoding result = new JSMEncoding(); 50 50 51 int nrOfResources = p arent1.JobSequenceMatrix.Count;52 int nrOfJobs = p arent1.JobSequenceMatrix[0].Length;51 int nrOfResources = p1.JobSequenceMatrix.Count; 52 int nrOfJobs = p1.JobSequenceMatrix[0].Length; 53 53 54 54 //Determine randomly which jobindexes persist … … 56 56 for (int i = 0; i < persist.Length; i++) { 57 57 persist[i] = random.Next(2) == 1; 58 } 58 } 59 60 bool dominantParent = random.Next(2) == 1; 61 JSMEncoding parent1 = dominantParent ? p1 : p2; 62 JSMEncoding parent2 = dominantParent ? p2 : p1; 59 63 60 64 //Fill childmatrix with values … … 77 81 } 78 82 79 public override IJSSPEncoding Crossover(IRandom random, JSMEncoding parent1, JSMEncoding parent2) {83 public override JSMEncoding Crossover(IRandom random, JSMEncoding parent1, JSMEncoding parent2) { 80 84 return Cross(random, parent1, parent2); 81 85 } -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Encodings/JobSequenceMatrix/Crossovers/JSMSXXCrossover.cs
r6177 r6260 45 45 public JSMSXXCrossover () : base () {} 46 46 47 public static IJSSPEncoding Cross(IRandom random, JSMEncoding parent1, JSMEncoding parent2) {47 public static JSMEncoding Cross(IRandom random, JSMEncoding parent1, JSMEncoding parent2) { 48 48 JSMEncoding result = new JSMEncoding(); 49 49 50 int subSequenceLength = 3;50 int subSequenceLength = random.Next (parent1.JobSequenceMatrix[0].Length); 51 51 52 52 for (int i = 0; i < parent1.JobSequenceMatrix.Count; i++) { … … 102 102 103 103 104 public override IJSSPEncoding Crossover(IRandom random, JSMEncoding parent1, JSMEncoding parent2) {104 public override JSMEncoding Crossover(IRandom random, JSMEncoding parent1, JSMEncoding parent2) { 105 105 return Cross(random, parent1, parent2); 106 106 } -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Encodings/JobSequenceMatrix/JSMDecoder.cs
r6177 r6260 41 41 : base(original, cloner) { 42 42 this.resultingSchedule = cloner.Clone(original.resultingSchedule); 43 this.jobs = cloner.Clone(original.jobs); 43 44 this.decodingErrorPolicy = original.decodingErrorPolicy; 44 45 this.forcingStrategy = original.forcingStrategy; … … 52 53 } 53 54 55 #region Private Members 54 56 [Storable] 55 57 private Schedule resultingSchedule; 56 58 57 59 [Storable] 60 private ItemList<JSSPJob> jobs; 61 62 [Storable] 58 63 private JSMDecodingErrorPolicyTypes decodingErrorPolicy = JSMDecodingErrorPolicyTypes.GuidedPolicy; 59 64 60 65 [Storable] 61 private JSMForcingStrategyTypes forcingStrategy = JSMForcingStrategyTypes.ShiftForcing; 66 private JSMForcingStrategyTypes forcingStrategy = JSMForcingStrategyTypes.ShiftForcing; 67 #endregion 62 68 63 69 public JSMDecoder() … … 66 72 } 67 73 68 private ItemList<JSSPTask> GetEarliestNotScheduledTasks( ItemList<JSSPJob> jobs) {74 private ItemList<JSSPTask> GetEarliestNotScheduledTasks() { 69 75 ItemList<JSSPTask> result = new ItemList<JSSPTask>(); 70 76 foreach (JSSPJob j in jobs) { … … 79 85 } 80 86 private JSSPTask GetTaskWithMinimalEC(ItemList<JSSPTask> earliestTasksList) { 81 DoubleValue minEct = new DoubleValue(Double.MaxValue);87 double minEct = double.MaxValue; 82 88 JSSPTask result = null; 83 89 foreach (JSSPTask t in earliestTasksList) { 84 DoubleValue ect = ComputeEarliestCompletionTime(t);85 if (ect .Value < minEct.Value) {90 double ect = resultingSchedule.ComputeEarliestCompletionTime(t, jobs[t.JobNr.Value]); 91 if (ect < minEct) { 86 92 result = t; 87 93 minEct = ect; … … 92 98 private ItemList<JSSPTask> GetConflictSetForTask(JSSPTask conflictedTask, ItemList<JSSPTask> earliestTasksList) { 93 99 ItemList<JSSPTask> result = new ItemList<JSSPTask>(); 94 DoubleValue conflictedCompletionTime = ComputeEarliestCompletionTime(conflictedTask);100 double conflictedCompletionTime = resultingSchedule.ComputeEarliestCompletionTime(conflictedTask, jobs[conflictedTask.JobNr.Value]); 95 101 result.Add(conflictedTask); 96 102 foreach (JSSPTask t in earliestTasksList) { 97 103 if (t.ResourceNr.Value == conflictedTask.ResourceNr.Value) { 98 if ( ComputeEarliestStartTime(t).Value < conflictedCompletionTime.Value)104 if (resultingSchedule.ComputeEarliestStartTime(t, jobs[t.JobNr.Value]) < conflictedCompletionTime) 99 105 result.Add(t); 100 106 } … … 102 108 return result; 103 109 } 104 private JSSPTask SelectTaskFromConflictSet(IntValue conflictedResource, ItemList<JSSPTask> conflictSet, ItemList<Permutation> jsm) { 105 JSSPTask result = null; 106 IntValue progressOnResource = new IntValue (resultingSchedule.Resources[conflictedResource.Value].Tasks.Count); 107 108 if (progressOnResource.Value < jsm[conflictedResource.Value].Length) { 109 IntValue solutionCandidateJobNr = new IntValue(jsm[conflictedResource.Value][progressOnResource.Value]); 110 foreach (JSSPTask t in conflictSet) { 111 if (t.Job.Index.Value == solutionCandidateJobNr.Value) 112 result = t; 113 } 110 private JSSPTask SelectTaskFromConflictSet(int conflictedResourceNr, int progressOnConflictedResource, ItemList<JSSPTask> conflictSet, ItemList<Permutation> jsm) { 111 if (conflictSet.Count == 1) 112 return conflictSet[0]; 113 114 //get solutionCandidate from jobSequencingMatrix 115 int solutionCandidateJobNr = jsm[conflictedResourceNr][progressOnConflictedResource]; 116 117 //scan conflictSet for given solutionCandidate, and return if found 118 foreach (JSSPTask t in conflictSet) { 119 if (t.JobNr.Value == solutionCandidateJobNr) 120 return t; 121 } 122 123 //if solutionCandidate wasn't found in conflictSet apply DecodingErrorPolicy and ForcingPolicy 124 JSSPTask result = ApplyDecodingErrorPolicy(conflictSet, jsm[conflictedResourceNr], progressOnConflictedResource); 125 int newResolutionIndex = 0; 126 127 while (newResolutionIndex < jsm[conflictedResourceNr].Length && jsm[conflictedResourceNr][newResolutionIndex] != result.JobNr.Value) 128 newResolutionIndex++; 129 ApplyForcingStrategy(jsm, conflictedResourceNr, newResolutionIndex, progressOnConflictedResource, result.JobNr.Value); 130 131 return result; 132 } 133 private JSSPTask ApplyDecodingErrorPolicy(ItemList<JSSPTask> conflictSet, Permutation resource, int progress) { 134 if (decodingErrorPolicy == JSMDecodingErrorPolicyTypes.RandomPolicy) { 135 //Random 136 return conflictSet[RandomParameter.ActualValue.Next(conflictSet.Count - 1)]; 114 137 } else { 115 return null; 116 } 117 118 //Repairing happens here 119 if (result == null) { 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 128 int index = 0; 129 while (index < jsm[conflictedResource.Value].Length && 130 jsm[conflictedResource.Value][index] != result.Job.Index.Value) 131 index++; 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 138 //Guided 139 for (int i = progress; i < resource.Length; i++) { 140 int j = 0; 141 while (j < conflictSet.Count && conflictSet[j].JobNr.Value != resource[i]) 142 j++; 143 144 if (j < conflictSet.Count) 145 return (conflictSet[j]); 146 } 147 return conflictSet[RandomParameter.ActualValue.Next(conflictSet.Count - 1)]; 148 } 149 } 142 150 private void ApplyForcingStrategy(ItemList<Permutation> jsm, int conflictedResource, int newResolutionIndex, int progressOnResource, int newResolution) { 143 //if (forcingStrategy == JSMForcingStrategyTypes.SwapForcing) {151 if (forcingStrategy == JSMForcingStrategyTypes.SwapForcing) { 144 152 //SwapForcing 145 153 jsm[conflictedResource][newResolutionIndex] = jsm[conflictedResource][progressOnResource]; 146 154 jsm[conflictedResource][progressOnResource] = newResolution; 147 /*} else {155 } else { 148 156 //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 } */ 161 } 162 private DoubleValue ComputeEarliestStartTime(JSSPTask t) { 163 Resource affectedResource = resultingSchedule.Resources[t.ResourceNr.Value]; 164 165 DoubleValue lastMachineEndTime = affectedResource.TotalDuration; 166 DoubleValue previousJoboperationEndTime = new DoubleValue(double.MinValue); 167 if (t.PreviousTask != null) 168 previousJoboperationEndTime = t.PreviousTask.EndTime; 169 170 return new DoubleValue(Math.Max(previousJoboperationEndTime.Value, lastMachineEndTime.Value)); 171 } 172 private DoubleValue ComputeEarliestCompletionTime(JSSPTask t) { 173 return new DoubleValue(ComputeEarliestStartTime(t).Value + t.Duration.Value); 174 } 175 private void AddTaskToSchedule(JSSPTask selectedTask) { 176 Resource affectedResource = resultingSchedule.Resources[selectedTask.ResourceNr.Value]; 177 selectedTask.StartTime = ComputeEarliestStartTime(selectedTask); 178 selectedTask.IsScheduled.Value = true; 179 affectedResource.Tasks.Add(selectedTask); 180 } 181 182 public override Schedule CreateScheduleFromEncoding(JSMEncoding solution) { 157 List<int> asList = jsm[conflictedResource].ToList<int>(); 158 if (newResolutionIndex > progressOnResource) { 159 asList.RemoveAt(newResolutionIndex); 160 asList.Insert(progressOnResource, newResolution); 161 } else { 162 asList.Insert(progressOnResource, newResolution); 163 asList.RemoveAt(newResolutionIndex); 164 } 165 jsm[conflictedResource] = new Permutation (PermutationTypes.Absolute, asList.ToArray<int>()); 166 } 167 } 168 169 public Schedule CreateScheduleFromEncoding(JSMEncoding solution, ItemList<JSSPJob> jobData) { 183 170 ItemList<Permutation> jobSequenceMatrix = solution.JobSequenceMatrix; 184 171 185 resultingSchedule = new Schedule(new IntValue(Jobs[0].Tasks.Count)); 172 jobs = (ItemList<JSSPJob>)jobData.Clone(); 173 resultingSchedule = new Schedule(new IntValue(jobs[0].Tasks.Count)); 186 174 187 175 //Reset scheduled tasks in result 188 foreach (JSSPJob j in Jobs) {176 foreach (JSSPJob j in jobs) { 189 177 foreach (JSSPTask t in j.Tasks) { 190 178 t.IsScheduled.Value = false; … … 194 182 //GT-Algorithm 195 183 //STEP 0 - Compute a list of "earliest operations" 196 ItemList<JSSPTask> earliestTasksList = GetEarliestNotScheduledTasks( Jobs);184 ItemList<JSSPTask> earliestTasksList = GetEarliestNotScheduledTasks(); 197 185 while (earliestTasksList.Count > 0) { 198 186 //STEP 1 - Get earliest not scheduled operation with minimal earliest completing time 199 187 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 188 int conflictedResourceNr = minimal.ResourceNr.Value; 189 Resource conflictedResource = resultingSchedule.Resources[conflictedResourceNr]; 190 191 //STEP 2 - Compute a conflict set of all operations that can be scheduled on the conflicted resource 202 192 ItemList<JSSPTask> conflictSet = GetConflictSetForTask(minimal, earliestTasksList); 203 193 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); 194 //STEP 3 - Select a task from the conflict set 195 int progressOnResource = conflictedResource.Tasks.Count; 196 JSSPTask selectedTask = SelectTaskFromConflictSet(conflictedResourceNr, progressOnResource, conflictSet, jobSequenceMatrix); 197 198 //STEP 4 - Add the selected task to the current schedule 199 selectedTask.IsScheduled.Value = true; 200 resultingSchedule.AddTask(selectedTask, jobs[selectedTask.JobNr.Value]); 209 201 210 202 //STEP 5 - Back to STEP 1 211 earliestTasksList = GetEarliestNotScheduledTasks( Jobs);203 earliestTasksList = GetEarliestNotScheduledTasks(); 212 204 } 213 205 214 206 return resultingSchedule; 207 } 208 209 public override Schedule CreateScheduleFromEncoding(JSMEncoding solution) { 210 return CreateScheduleFromEncoding(solution, Jobs); 215 211 } 216 212 -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Encodings/JobSequenceMatrix/JSMEncoding.cs
r6177 r6260 36 36 [Item("Job Sequencing Matrix Encoding", "Represents a solution for a standard JobShop Scheduling Problem.")] 37 37 [StorableClass] 38 public class JSMEncoding : ParameterizedNamedItem, I JSSPEncoding{38 public class JSMEncoding : ParameterizedNamedItem, ISchedulingEncoding{ 39 39 [StorableConstructor] 40 40 protected JSMEncoding(bool deserializing) : base(deserializing) { } -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Encodings/JobSequenceMatrix/Manipulators/JSMManipulator.cs
r6177 r6260 32 32 [Item("AlbaManipulator", "An operator which manipulates a VRP representation.")] 33 33 [StorableClass] 34 public abstract class JSMManipulator : JSSPManipulator , IJSMOperator {34 public abstract class JSMManipulator : JSSPManipulator<JSMEncoding>, IJSMOperator { 35 35 [StorableConstructor] 36 36 protected JSMManipulator(bool deserializing) : base(deserializing) { } … … 44 44 45 45 public override IOperation Apply() { 46 IJSSPEncoding solution = SchedulingSolutionParameter.ActualValue;46 JSMEncoding solution = SchedulingSolutionParameter.ActualValue; 47 47 48 SchedulingSolutionParameter.ActualValue = Manipulate(RandomParameter.ActualValue, solution as JSMEncoding); 48 int nrOfMutations = RandomParameter.ActualValue.Next(5) + 1; 49 50 for (int i = 0; i < nrOfMutations; i++ ) 51 SchedulingSolutionParameter.ActualValue = Manipulate(RandomParameter.ActualValue, solution as JSMEncoding); 49 52 50 53 return base.Apply(); -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Encodings/PriorityRulesVector/Crossovers/PRVCrossover.cs
r6177 r6260 28 28 29 29 namespace HeuristicLab.Problems.Scheduling.Encodings.PriorityRulesVector.Crossovers { 30 [Item(" JSMCrossover", "An operator which crosses two JSMrepresentations.")]30 [Item("PRVCrossover", "An operator which crosses two PRV representations.")] 31 31 [StorableClass] 32 public abstract class PRVCrossover : JSSPCrossover , IPRVOperator {32 public abstract class PRVCrossover : JSSPCrossover<PRVEncoding>, IPRVOperator { 33 33 34 34 [StorableConstructor] … … 39 39 } 40 40 41 public abstract IJSSPEncoding Crossover(IRandom random, PRVEncoding parent1, PRVEncoding parent2);41 public abstract PRVEncoding Crossover(IRandom random, PRVEncoding parent1, PRVEncoding parent2); 42 42 43 43 public override IOperation Apply() { 44 ItemArray< IJSSPEncoding> parents = ParentsParameter.ActualValue;44 ItemArray<PRVEncoding> parents = ParentsParameter.ActualValue; 45 45 46 46 ChildParameter.ActualValue = -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Encodings/PriorityRulesVector/Crossovers/PRVDiscreteCrossover.cs
r6177 r6260 45 45 public PRVDiscreteCrossover() : base() { } 46 46 47 public static IJSSPEncoding Cross(IRandom random, PRVEncoding parent1, PRVEncoding parent2) {47 public static PRVEncoding Cross(IRandom random, PRVEncoding parent1, PRVEncoding parent2) { 48 48 return new PRVEncoding(DiscreteCrossover.Apply(random, parent1, parent2), parent1.NrOfRules); 49 49 } 50 50 51 public override IJSSPEncoding Crossover(IRandom random, PRVEncoding parent1, PRVEncoding parent2) {51 public override PRVEncoding Crossover(IRandom random, PRVEncoding parent1, PRVEncoding parent2) { 52 52 return Cross(random, parent1, parent2); 53 53 } -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Encodings/PriorityRulesVector/Crossovers/PRVSinglePointCrossover.cs
r6177 r6260 45 45 public PRVSinglePointCrossover() : base() { } 46 46 47 public static IJSSPEncoding Cross(IRandom random, PRVEncoding parent1, PRVEncoding parent2) {47 public static PRVEncoding Cross(IRandom random, PRVEncoding parent1, PRVEncoding parent2) { 48 48 return new PRVEncoding(SinglePointCrossover.Apply(random, parent1, parent2), parent1.NrOfRules); 49 49 } 50 50 51 public override IJSSPEncoding Crossover(IRandom random, PRVEncoding parent1, PRVEncoding parent2) {52 return Cross(random, parent1, parent2); 51 public override PRVEncoding Crossover(IRandom random, PRVEncoding parent1, PRVEncoding parent2) { 52 return Cross(random, parent1, parent2);; 53 53 } 54 54 } -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Encodings/PriorityRulesVector/Manipulators/PRVManipulator.cs
r6177 r6260 30 30 31 31 namespace HeuristicLab.Problems.Scheduling.Encodings.PriorityRulesVector.Manipulators { 32 [Item(" AlbaManipulator", "An operator which manipulates a VRPrepresentation.")]32 [Item("PRVManipulator", "An operator which manipulates a PRV representation.")] 33 33 [StorableClass] 34 public abstract class PRVManipulator : JSSPManipulator , IPRVOperator {34 public abstract class PRVManipulator : JSSPManipulator<PRVEncoding>, IPRVOperator { 35 35 [StorableConstructor] 36 36 protected PRVManipulator(bool deserializing) : base(deserializing) { } … … 44 44 45 45 public override IOperation Apply() { 46 IJSSPEncoding solution = SchedulingSolutionParameter.ActualValue;46 PRVEncoding solution = SchedulingSolutionParameter.ActualValue; 47 47 48 48 SchedulingSolutionParameter.ActualValue = Manipulate(RandomParameter.ActualValue, solution as PRVEncoding); -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Encodings/PriorityRulesVector/PRVDecoder.cs
r6177 r6260 50 50 } 51 51 52 #region Private Members 52 53 [Storable] 53 54 private Schedule resultingSchedule; 54 55 55 public PRVDecoder() 56 : base() { 57 Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators.")); 58 } 56 [Storable] 57 private ItemList<JSSPJob> jobs; 58 #endregion 59 59 60 60 #region Priority Rules … … 67 67 //earliest start time 68 68 private JSSPTask ESTRule(ItemList<JSSPTask> tasks) { 69 JSSPTask currentResult = tasks[0];69 JSSPTask currentResult = RandomRule(tasks); 70 70 double currentEST = double.MaxValue; 71 71 foreach (JSSPTask t in tasks) { 72 double est = ComputeEarliestStartTime(t).Value;72 double est = resultingSchedule.ComputeEarliestStartTime(t, jobs[t.JobNr.Value]); 73 73 if (est < currentEST) { 74 74 currentEST = est; … … 81 81 //shortest processingtime 82 82 private JSSPTask SPTRule(ItemList<JSSPTask> tasks) { 83 JSSPTask currentResult = tasks[0];83 JSSPTask currentResult = RandomRule(tasks); 84 84 foreach (JSSPTask t in tasks) { 85 85 if (t.Duration.Value < currentResult.Duration.Value) … … 91 91 //longest processing time 92 92 private JSSPTask LPTRule(ItemList<JSSPTask> tasks) { 93 JSSPTask currentResult = tasks[0];93 JSSPTask currentResult = RandomRule(tasks); 94 94 foreach (JSSPTask t in tasks) { 95 95 if (t.Duration.Value > currentResult.Duration.Value) … … 101 101 //most work remaining 102 102 private JSSPTask MWRRule(ItemList<JSSPTask> tasks) { 103 JSSPTask currentResult = tasks[0];103 JSSPTask currentResult = RandomRule(tasks); 104 104 double currentLargestRemainingProcessingTime = 0; 105 105 foreach (JSSPTask t in tasks) { 106 106 double remainingProcessingTime = 0; 107 foreach (JSSPTask jt in t.Job.Tasks) {107 foreach (JSSPTask jt in jobs[t.JobNr.Value].Tasks) { 108 108 if (!jt.IsScheduled.Value) 109 109 remainingProcessingTime += jt.Duration.Value; … … 119 119 //least work remaining 120 120 private JSSPTask LWRRule(ItemList<JSSPTask> tasks) { 121 JSSPTask currentResult = tasks[0];121 JSSPTask currentResult = RandomRule(tasks); 122 122 double currentSmallestRemainingProcessingTime = double.MaxValue; 123 123 foreach (JSSPTask t in tasks) { 124 124 double remainingProcessingTime = 0; 125 foreach (JSSPTask jt in t.Job.Tasks) {125 foreach (JSSPTask jt in jobs[t.JobNr.Value].Tasks) { 126 126 if (!jt.IsScheduled.Value) 127 127 remainingProcessingTime += jt.Duration.Value; … … 137 137 //most operations remaining 138 138 private JSSPTask MORRule(ItemList<JSSPTask> tasks) { 139 JSSPTask currentResult = tasks[0];139 JSSPTask currentResult = RandomRule(tasks); 140 140 int currentLargestNrOfRemainingTasks = 0; 141 141 foreach (JSSPTask t in tasks) { 142 142 int nrOfRemainingTasks = 0; 143 foreach (JSSPTask jt in t.Job.Tasks) {143 foreach (JSSPTask jt in jobs[t.JobNr.Value].Tasks) { 144 144 if (!jt.IsScheduled.Value) 145 145 nrOfRemainingTasks++; … … 155 155 //least operationsremaining 156 156 private JSSPTask LORRule(ItemList<JSSPTask> tasks) { 157 JSSPTask currentResult = tasks[0];157 JSSPTask currentResult = RandomRule(tasks); 158 158 int currentSmallestNrOfRemainingTasks = int.MaxValue; 159 159 foreach (JSSPTask t in tasks) { 160 160 int nrOfRemainingTasks = 0; 161 foreach (JSSPTask jt in t.Job.Tasks) {161 foreach (JSSPTask jt in jobs[t.JobNr.Value].Tasks) { 162 162 if (!jt.IsScheduled.Value) 163 163 nrOfRemainingTasks++; … … 185 185 #endregion 186 186 187 private ItemList<JSSPTask> GetEarliestNotScheduledTasks(ItemList<JSSPJob> jobs) { 187 public PRVDecoder() 188 : base() { 189 Parameters.Add(new LookupParameter<IRandom>("Random", "The pseudo random number generator which should be used for stochastic manipulation operators.")); 190 } 191 192 private ItemList<JSSPTask> GetEarliestNotScheduledTasks() { 188 193 ItemList<JSSPTask> result = new ItemList<JSSPTask>(); 189 194 foreach (JSSPJob j in jobs) { … … 198 203 } 199 204 private JSSPTask GetTaskWithMinimalEC(ItemList<JSSPTask> earliestTasksList) { 200 DoubleValue minEct = new DoubleValue(Double.MaxValue);205 double minEct = double.MaxValue; 201 206 JSSPTask result = null; 202 207 foreach (JSSPTask t in earliestTasksList) { 203 DoubleValue ect = ComputeEarliestCompletionTime(t);204 if (ect .Value < minEct.Value) {208 double ect = resultingSchedule.ComputeEarliestCompletionTime(t, jobs[t.JobNr.Value]); 209 if (ect < minEct) { 205 210 result = t; 206 211 minEct = ect; … … 211 216 private ItemList<JSSPTask> GetConflictSetForTask(JSSPTask conflictedTask, ItemList<JSSPTask> earliestTasksList) { 212 217 ItemList<JSSPTask> result = new ItemList<JSSPTask>(); 213 DoubleValue conflictedCompletionTime = ComputeEarliestCompletionTime(conflictedTask); 214 //result.Add(conflictedTask); 218 double conflictedCompletionTime = resultingSchedule.ComputeEarliestCompletionTime(conflictedTask, jobs[conflictedTask.JobNr.Value]); 215 219 foreach (JSSPTask t in earliestTasksList) { 216 220 if (t.ResourceNr.Value == conflictedTask.ResourceNr.Value) { 217 if ( ComputeEarliestStartTime(t).Value < conflictedCompletionTime.Value)221 if (resultingSchedule.ComputeEarliestStartTime(t, jobs[t.JobNr.Value]) < conflictedCompletionTime) 218 222 result.Add(t); 219 223 } … … 240 244 } 241 245 } 242 private DoubleValue ComputeEarliestStartTime(JSSPTask t) {243 Resource affectedResource = resultingSchedule.Resources[t.ResourceNr.Value];244 245 DoubleValue lastMachineEndTime = affectedResource.TotalDuration;246 DoubleValue previousJoboperationEndTime = new DoubleValue(double.MinValue);247 if (t.PreviousTask != null)248 previousJoboperationEndTime = t.PreviousTask.EndTime;249 250 return new DoubleValue(Math.Max(previousJoboperationEndTime.Value, lastMachineEndTime.Value));251 }252 private DoubleValue ComputeEarliestCompletionTime(JSSPTask t) {253 return new DoubleValue(ComputeEarliestStartTime(t).Value + t.Duration.Value);254 }255 private void AddTaskToSchedule(JSSPTask selectedTask) {256 Resource affectedResource = resultingSchedule.Resources[selectedTask.ResourceNr.Value];257 selectedTask.StartTime = ComputeEarliestStartTime(selectedTask);258 selectedTask.IsScheduled.Value = true;259 affectedResource.Tasks.Add(selectedTask);260 }261 246 262 247 public override Schedule CreateScheduleFromEncoding(PRVEncoding solution) { 263 PRVEncoding priorityRulesVector = solution; 264 248 jobs = (ItemList<JSSPJob>)Jobs.Clone(); 265 249 resultingSchedule = new Schedule(new IntValue(Jobs[0].Tasks.Count)); 266 250 … … 274 258 //GT-Algorithm 275 259 //STEP 0 - Compute a list of "earliest operations" 276 ItemList<JSSPTask> earliestTasksList = GetEarliestNotScheduledTasks( Jobs);260 ItemList<JSSPTask> earliestTasksList = GetEarliestNotScheduledTasks(); 277 261 int currentDecisionIndex = 0; 278 262 while (earliestTasksList.Count > 0) { … … 284 268 285 269 //STEP 3 - Select an operation from the conflict set (various methods depending on how the algorithm should work..) 286 JSSPTask selectedTask = SelectTaskFromConflictSet(conflictSet, priorityRulesVector[currentDecisionIndex++], solution.NrOfRules.Value);270 JSSPTask selectedTask = SelectTaskFromConflictSet(conflictSet, solution [currentDecisionIndex++], solution.NrOfRules.Value); 287 271 288 272 //STEP 4 - Adding the selected operation to the current schedule 289 AddTaskToSchedule(selectedTask); 273 selectedTask.IsScheduled.Value = true; 274 resultingSchedule.AddTask(selectedTask, jobs[selectedTask.JobNr.Value]); 290 275 291 276 //STEP 5 - Back to STEP 1 292 earliestTasksList = GetEarliestNotScheduledTasks( Jobs);277 earliestTasksList = GetEarliestNotScheduledTasks(); 293 278 } 294 279 -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Encodings/PriorityRulesVector/PRVEncoding.cs
r6177 r6260 37 37 [Item("Priority Rules Vector Encoding", "Represents a solution for a standard JobShop Scheduling Problem.")] 38 38 [StorableClass] 39 public class PRVEncoding : IntegerVector, I JSSPEncoding{39 public class PRVEncoding : IntegerVector, ISchedulingEncoding{ 40 40 [StorableConstructor] 41 41 protected PRVEncoding(bool deserializing) : base(deserializing) { } … … 64 64 public PRVEncoding (IntegerVector iv, IntValue nrOfRules) : base (iv.Length) { 65 65 this.nrOfRules = (IntValue)nrOfRules.Clone(); 66 for each (int i in iv) {66 for (int i = 0; i < iv.Length; i++) { 67 67 this[i] = iv[i]; 68 68 } -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Evaluators/JSSPEvaluator.cs
r6177 r6260 32 32 using HeuristicLab.Problems.Scheduling.Encodings; 33 33 using HeuristicLab.Operators; 34 using HeuristicLab.Problems.Scheduling.Interfaces; 34 35 35 36 … … 37 38 [Item("JSSP Evaluator", "Represents a evaluator class for standard job shop scheduling problems.")] 38 39 [StorableClass] 39 public abstract class JSSPEvaluator : JSSPOperator, IS ingleObjectiveEvaluator {40 public abstract class JSSPEvaluator : JSSPOperator, ISchedulingEvaluator { 40 41 [StorableConstructor] 41 42 protected JSSPEvaluator(bool deserializing) : base(deserializing) { } -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Evaluators/MakespanEvaluator.cs
r6177 r6260 50 50 foreach (Resource r in schedule.Resources) { 51 51 if (r.TotalDuration.Value > quality.Value) { 52 quality = r.TotalDuration;52 quality.Value = r.TotalDuration.Value; 53 53 } 54 54 } -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/HeuristicLab.Problems.Scheduling-3.3.csproj
r6177 r6260 52 52 <Compile Include="Encodings\JobSequenceMatrix\Crossovers\JSMJOXCrossover.cs" /> 53 53 <Compile Include="Encodings\JobSequenceMatrix\Crossovers\JSMCrossover.cs" /> 54 <Compile Include="Encodings\JobSequenceMatrix\Crossovers\JSMO rderCrossover.cs" />54 <Compile Include="Encodings\JobSequenceMatrix\Crossovers\JSMOXCrossover.cs" /> 55 55 <Compile Include="Encodings\JobSequenceMatrix\Crossovers\JSMSXXCrossover.cs" /> 56 56 <Compile Include="Encodings\JobSequenceMatrix\JSMDecoder.cs" /> … … 60 60 <Compile Include="Encodings\JobSequenceMatrix\Manipulators\JSMShiftChangeManipulator.cs" /> 61 61 <Compile Include="Encodings\JobSequenceMatrix\Manipulators\JSMManipulator.cs" /> 62 <Compile Include="Encodings\JobSequenceMatrix\Manipulators\JSM InsertionManipulator.cs" />62 <Compile Include="Encodings\JobSequenceMatrix\Manipulators\JSMSwapManipulator.cs" /> 63 63 <Compile Include="Encodings\JSSPCrossover.cs" /> 64 64 <Compile Include="Encodings\JSSPDecoder.cs" /> 65 65 <Compile Include="Encodings\JSSPEncodingTypes.cs" /> 66 <Compile Include="Encodings\PermutationWithRepetition\Crossovers\PWRGOXCrossover.cs" /> 67 <Compile Include="Encodings\PermutationWithRepetition\Crossovers\PWRCrossover.cs" /> 68 <Compile Include="Encodings\PermutationWithRepetition\Crossovers\PWRPPXCrossover.cs" /> 69 <Compile Include="Encodings\PermutationWithRepetition\Manipulators\PWRUniformOnePositionManipulator.cs" /> 70 <Compile Include="Encodings\PermutationWithRepetition\Manipulators\PWRManipulator.cs" /> 71 <Compile Include="Encodings\PermutationWithRepetition\PWRDecoder.cs" /> 72 <Compile Include="Encodings\PermutationWithRepetition\PWREncoding.cs" /> 73 <Compile Include="Encodings\PermutationWithRepetition\PWRRandomCreator.cs" /> 66 74 <Compile Include="Encodings\PriorityRulesVector\Crossovers\PRVSinglePointCrossover.cs" /> 67 75 <Compile Include="Encodings\PriorityRulesVector\Crossovers\PRVDiscreteCrossover.cs" /> … … 69 77 <Compile Include="Encodings\PriorityRulesVector\PRVEncoding.cs" /> 70 78 <Compile Include="Interfaces\IJSSPDecoder.cs" /> 71 <Compile Include="Interfaces\IJSSPOperator.cs" /> 79 <Compile Include="Interfaces\ISchedulingOperator.cs" /> 80 <Compile Include="Interfaces\IPWROperator.cs" /> 72 81 <Compile Include="Interfaces\IPRVOperator.cs" /> 73 82 <Compile Include="Interfaces\IJSSPEncoding.cs" /> … … 87 96 <Compile Include="Resource.cs" /> 88 97 <Compile Include="Evaluators\JSSPEvaluator.cs" /> 89 <Compile Include="Interfaces\IJSSPCreator.cs" />90 98 <Compile Include="JSSPJob.cs" /> 91 99 <Compile Include="JobShopSchedulingProblem.cs" /> 92 100 <Compile Include="JSSPTask.cs" /> 93 101 <Compile Include="Encodings\JSSPOperator.cs" /> 94 <Compile Include="Evaluators\ SchedulingEvaluator.cs" />102 <Compile Include="Evaluators\JSSPEvaluationAlgorithm.cs" /> 95 103 <Compile Include="SchedulingProblem.cs" /> 96 104 <Compile Include="Plugin.cs" /> -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/JSSPJob.cs
r6177 r6260 54 54 return sb.ToString(); 55 55 } 56 57 internal JSSPTask GetPreviousTask(JSSPTask t) { 58 if (t.TaskNr.Value == 0) 59 return null; 60 else 61 return Tasks[t.TaskNr.Value - 1]; 62 } 56 63 } 57 64 } -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/JSSPTask.cs
r6177 r6260 42 42 this.TaskNr = cloner.Clone(original.TaskNr); 43 43 this.IsScheduled = cloner.Clone(original.IsScheduled); 44 this.Job = cloner.Clone(original.Job); 45 this.PreviousTask = cloner.Clone(original.PreviousTask); 46 this.NextTask = cloner.Clone(original.NextTask); 44 this.JobNr = cloner.Clone (original.JobNr); 47 45 } 48 46 public override IDeepCloneable Clone(Cloner cloner) { … … 61 59 } 62 60 } 63 public JSSPJob Job { get; set; } 64 public JSSPTask PreviousTask { get; set; } 65 public JSSPTask NextTask { get; set; } 61 public IntValue JobNr { get; set; } 66 62 67 public JSSPTask (IntValue taskNr, IntValue resNr, DoubleValue duration, JSSPJob j) : base () { 63 64 public JSSPTask (IntValue taskNr, IntValue resNr, DoubleValue duration, IntValue jobNr) : base () { 68 65 Duration = duration; 69 66 ResourceNr = resNr; … … 71 68 StartTime = new DoubleValue(0); 72 69 IsScheduled = new BoolValue(false); 73 Job = j; 70 JobNr = jobNr; 71 } 72 73 public override string ToString() { 74 StringBuilder sb = new StringBuilder(); 75 sb.Append("[" + JobNr + "," + ResourceNr + "]"); 76 return sb.ToString(); 74 77 } 75 78 } -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/JobShopSchedulingProblem.cs
r6177 r6260 43 43 using HeuristicLab.Problems.Scheduling.Encodings.PriorityRulesVector; 44 44 using HeuristicLab.Encodings.IntegerVectorEncoding; 45 using HeuristicLab.Problems.Scheduling.Encodings.PermutationWithRepetition; 45 46 46 47 namespace HeuristicLab.Problems.Scheduling { … … 53 54 private JobShopSchedulingProblem(JobShopSchedulingProblem original, Cloner cloner) 54 55 : base(original, cloner) { 55 operators = original.operators.Select(x => (IOperator)cloner.Clone(x)).ToList();56 56 this.encodingType = original.encodingType; 57 57 AttachEventHandlers(); … … 82 82 #endregion 83 83 84 85 [Storable]86 private List<IOperator> operators;87 88 84 [Storable] 89 85 private JSSPEncodingTypes encodingType; 90 86 91 87 public JobShopSchedulingProblem() 92 : base(new SchedulingEvaluator(), new JSMRandomCreator ()) {88 : base(new JSSPEvaluationAlgorithm (), new JSMRandomCreator ()) { 93 89 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>())); 94 90 Parameters.Add(new OptionalValueParameter<Schedule>("BestKnownSolution", "The best known solution of this JSSP instance.")); … … 103 99 if (SolutionCreator.GetType().Equals(typeof(JSMRandomCreator))) 104 100 encodingType = JSSPEncodingTypes.JSMEncoding; 105 else 106 encodingType = JSSPEncodingTypes.PRVEncoding; 107 101 else { 102 if (SolutionCreator.GetType().Equals(typeof(PRVRandomCreator))) 103 encodingType = JSSPEncodingTypes.PRVEncoding; 104 else 105 encodingType = JSSPEncodingTypes.PWREncoding; 106 } 108 107 InitializeOperators(); 109 108 } … … 122 121 if (encodingType == JSSPEncodingTypes.JSMEncoding) { 123 122 Operators.AddRange(ApplicationManager.Manager.GetInstances<IJSMOperator>()); 124 (( SchedulingEvaluator)this.EvaluatorParameter.ActualValue).InitializeOperatorGraph<JSMEncoding>(new JSMDecoder(), new MakespanEvaluator());123 ((JSSPEvaluationAlgorithm)this.EvaluatorParameter.ActualValue).InitializeOperatorGraph<JSMEncoding>(new JSMDecoder(), new MakespanEvaluator()); 125 124 } else { 126 125 if (encodingType == JSSPEncodingTypes.PRVEncoding) { 127 126 Operators.AddRange(ApplicationManager.Manager.GetInstances<IPRVOperator>()); 128 ((SchedulingEvaluator)this.EvaluatorParameter.ActualValue).InitializeOperatorGraph<PRVEncoding>(new PRVDecoder(), new MakespanEvaluator()); 127 ((JSSPEvaluationAlgorithm)this.EvaluatorParameter.ActualValue).InitializeOperatorGraph<PRVEncoding>(new PRVDecoder(), new MakespanEvaluator()); 128 } else { 129 if (encodingType == JSSPEncodingTypes.PWREncoding) { 130 Operators.AddRange(ApplicationManager.Manager.GetInstances<IPWROperator>()); 131 ((JSSPEvaluationAlgorithm)this.EvaluatorParameter.ActualValue).InitializeOperatorGraph<PWREncoding>(new PWRDecoder(), new MakespanEvaluator()); 132 } 129 133 } 130 134 } … … 146 150 #region Importmethods 147 151 private List<string> SplitString(string line) { 152 if (line == null) 153 return null; 148 154 List<string> data = new List<string>(line.Split(' ')); 149 155 List<string> result = new List<string>(); … … 155 161 156 162 return result; 163 } 164 private int[] GetIntArray(List<string> data) { 165 int[] arr = new int [data.Count]; 166 for (int i = 0; i < data.Count; i++ ) { 167 arr[i] = Int32.Parse(data[i]); 168 } 169 return arr; 157 170 } 158 171 public void ImportFromORLibrary(string fileName) { … … 179 192 JSSPJob j = new JSSPJob(new IntValue(jobCount)); 180 193 for (int i = 0; i < data.Count; i++) { 181 JSSPTask t = new JSSPTask(new IntValue (i / 2), new IntValue(Int32.Parse(data[i])), new DoubleValue(Double.Parse(data[i + 1])), j);194 JSSPTask t = new JSSPTask(new IntValue (i / 2), new IntValue(Int32.Parse(data[i])), new DoubleValue(Double.Parse(data[i + 1])), new IntValue (jobCount)); 182 195 if (j.Tasks.Count > 0) { 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); 196 t.StartTime = new DoubleValue (j.Tasks[j.Tasks.Count - 1].EndTime.Value + 2); 186 197 } 187 198 j.Tasks.Add(t); … … 198 209 problemFile.Close(); 199 210 } 211 212 public void ImportJSMSolution(string fileName) { 213 if (!File.Exists(fileName)) 214 return; 215 StreamReader solutionFile = new StreamReader(fileName); 216 //assures that the parser only reads the first solution instance given in the file 217 bool solutionFound = false; 218 JSMEncoding solution = new JSMEncoding(); 219 while (!solutionFile.EndOfStream && !solutionFound) { 220 221 string line = solutionFile.ReadLine(); 222 List<string> data = SplitString(line); 223 if (data.Count > 0 && ((int)data[0][0] >= 48 && (int)data[0][0] <= 57)) { 224 if (data.Count > 2) 225 BestKnownQualityParameter.ActualValue = new DoubleValue(Double.Parse(data[2])); 226 line = solutionFile.ReadLine(); 227 data = SplitString(line); 228 while (data != null && data.Count > 0 && ((int)data[0][0] >= 48 && (int)data[0][0] <= 57)) { 229 Permutation p = new Permutation(PermutationTypes.Absolute, GetIntArray (data)); 230 solution.JobSequenceMatrix.Add(p); 231 232 line = solutionFile.ReadLine(); 233 data = SplitString(line); 234 }//while 235 solutionFound = true; 236 }//if 237 }//while 238 solutionFile.Close(); 239 240 JSMDecoder decoder = new JSMDecoder(); 241 Schedule result = decoder.CreateScheduleFromEncoding(solution, Jobs); 242 BestKnownSolution = result; 243 } 200 244 #endregion 201 245 -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Resource.cs
r6177 r6260 45 45 public DoubleValue TotalDuration { 46 46 get { 47 if (Tasks.Count > 0) 48 return new DoubleValue(Tasks[Tasks.Count - 1].EndTime.Value); 49 else 50 return new DoubleValue (0); 47 double result = 0; 48 foreach (JSSPTask t in Tasks) { 49 if (t.EndTime.Value > result) 50 result = t.EndTime.Value; 51 } 52 return new DoubleValue (result); 51 53 } 52 54 } -
branches/Scheduling/HeuristicLab.Problems.Scheduling/3.3/Schedule.cs
r6177 r6260 48 48 49 49 [Storable] 50 public ItemList<Resource> Resources; 50 private ItemList<Resource> resources; 51 public ItemList<Resource> Resources { 52 get { return resources; } 53 set { 54 if (resources != null) DeregisterResourcesEvents(); 55 resources = value; 56 if (resources != null) RegisterResourcesEvents(); 57 OnResourcesChanged(); 58 } 59 } 51 60 52 61 [Storable] 62 private DoubleValue quality; 53 63 public DoubleValue Quality { 54 get; 55 set; 64 get { return quality; } 65 set { 66 if (quality != value) { 67 if (quality != null) DeregisterQualityEvents(); 68 quality = value; 69 if (quality != null) RegisterQualityEvents(); 70 OnQualityChanged(); 71 } 72 } 73 } 74 75 public double Makespan { 76 get { 77 double quality = 0; 78 foreach (Resource r in Resources) { 79 if (r.TotalDuration.Value > quality) { 80 quality = r.TotalDuration.Value; 81 } 82 } 83 return quality; 84 } 56 85 } 57 86 … … 62 91 Resources.Add(new Resource(new IntValue (i))); 63 92 } 93 } 94 95 #region Events 96 public event EventHandler QualityChanged; 97 private void OnQualityChanged() { 98 var changed = QualityChanged; 99 if (changed != null) 100 changed(this, EventArgs.Empty); 101 } 102 private void RegisterQualityEvents() { 103 Quality.ValueChanged += new EventHandler(Quality_ValueChanged); 104 } 105 private void DeregisterQualityEvents() { 106 Quality.ValueChanged -= new EventHandler(Quality_ValueChanged); 107 } 108 private void Quality_ValueChanged(object sender, EventArgs e) { 109 OnQualityChanged(); 110 } 111 112 public event EventHandler ResourcesChanged; 113 private void OnResourcesChanged() { 114 var changed = ResourcesChanged; 115 if (changed != null) 116 changed(this, EventArgs.Empty); 117 } 118 private void RegisterResourcesEvents() { 119 Resources.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(Resources_PropertyChanged); 120 } 121 private void DeregisterResourcesEvents() { 122 Resources.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(Resources_PropertyChanged); 123 } 124 private void Resources_PropertyChanged(object sender, EventArgs e) { 125 OnResourcesChanged(); 126 } 127 #endregion 128 129 public void AddTask(JSSPTask task, JSSPJob job) { 130 task.StartTime = new DoubleValue (ComputeEarliestStartTime(task, job)); 131 Resource affectedResource = resources[task.ResourceNr.Value]; 132 int i = 0; 133 while (i < affectedResource.Tasks.Count && affectedResource.Tasks[i].StartTime.Value < task.StartTime.Value) 134 i++; 135 136 if (i >= affectedResource.Tasks.Count) 137 affectedResource.Tasks.Add(task); 138 else 139 affectedResource.Tasks.Insert(i, task); 140 } 141 public double ComputeEarliestStartTime(JSSPTask t, JSSPJob job) { 142 Resource affectedResource = resources[t.ResourceNr.Value]; 143 double lastMachineEndTime = affectedResource.TotalDuration.Value; 144 double previousJobTaskEndTime = 0; 145 JSSPTask previousTask = job.GetPreviousTask(t); 146 if (previousTask != null) 147 previousJobTaskEndTime = previousTask.EndTime.Value; 148 149 return Math.Max(previousJobTaskEndTime, lastMachineEndTime); 150 } 151 public double ComputeEarliestCompletionTime(JSSPTask t, JSSPJob job) { 152 Resource affectedResource = resources[t.ResourceNr.Value]; 153 return ComputeEarliestStartTime(t, job) + t.Duration.Value; 64 154 } 65 155
Note: See TracChangeset
for help on using the changeset viewer.