Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/24/11 09:47:24 (13 years ago)
Author:
jhelm
Message:

#1329: Implemented PermutationWithRepetition Encoding. Implemented new operators for JSM Encoding.

Location:
branches/Scheduling/HeuristicLab.Problems.Scheduling.Views/3.3
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/Scheduling/HeuristicLab.Problems.Scheduling.Views/3.3/GanttChart.Designer.cs

    r6177 r6260  
    5454      this.chart.TabIndex = 0;
    5555      this.chart.Text = "chart";
     56      this.chart.MouseClick += new System.Windows.Forms.MouseEventHandler(this.chart_MouseClick);
    5657      //
    5758      // GanttChart
  • branches/Scheduling/HeuristicLab.Problems.Scheduling.Views/3.3/GanttChart.cs

    r6177 r6260  
    99  public partial class GanttChart : UserControl {
    1010
    11     private IDictionary<string, Color> categories = new Dictionary<string, Color>();
     11    private IDictionary<int, Color> jobColors = new SortedDictionary<int, Color>();
    1212    private IDictionary<string, int> rowNames = new Dictionary<string, int>();
     13   
    1314
    1415    public GanttChart() {
    1516      InitializeComponent();
     17      chart.Series[0].YValueType = ChartValueType.Double;
    1618    }
    1719
    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        }   
    2231      }
    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);
    3032    }
    3133
     
    3739    }
    3840
    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);
    4548    }
    4649
    4750    public void Reset() {
    4851      chart.Series[0].Points.Clear();
    49       categories.Clear();
     52      jobColors.Clear();
    5053      chart.Legends[0].CustomItems.Clear();
    5154      rowNames.Clear();
    5255    }
     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    }
    5376  }
    5477}
  • branches/Scheduling/HeuristicLab.Problems.Scheduling.Views/3.3/HeuristicLab.Problems.Scheduling.Views-3.3.csproj

    r6177 r6260  
    3232  </PropertyGroup>
    3333  <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>
    3452    <Reference Include="System" />
    3553    <Reference Include="System.Core" />
     
    153171      <Name>HeuristicLab.PluginInfrastructure-3.3</Name>
    154172    </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>
    155177    <ProjectReference Include="..\..\HeuristicLab.Problems.Scheduling\3.3\HeuristicLab.Problems.Scheduling-3.3.csproj">
    156178      <Project>{2BF1D639-1A74-44ED-AAAD-41ECD395AD93}</Project>
  • branches/Scheduling/HeuristicLab.Problems.Scheduling.Views/3.3/JobShopSchedulingProblemView.Designer.cs

    r6177 r6260  
    109109      // ganttChart
    110110      //
     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)));
    111114      this.ganttChart.Location = new System.Drawing.Point(0, 3);
    112115      this.ganttChart.Name = "ganttChart";
  • branches/Scheduling/HeuristicLab.Problems.Scheduling.Views/3.3/JobShopSchedulingProblemView.cs

    r6177 r6260  
    5757    private void FillGanttChart(JobShopSchedulingProblem content) {
    5858      //Add Jobs as Categories
     59      ganttChart.Reset();
    5960      int jobCount = 0;
    60       Random random = new Random();
     61      Random random = new Random(1);
    6162      foreach (JSSPJob j in content.Jobs) {
    6263        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)));
     64          int categoryNr = t.JobNr.Value;
     65          string categoryName = "Job" + categoryNr;
     66          ganttChart.AddJobColor(categoryNr);
    6667          ganttChart.AddData(categoryName,
    67             categoryName,
     68            categoryNr,
    6869            t.StartTime.Value,
    6970            t.EndTime.Value,
    70             "Job" + t.Job.Index + " - " + "Task#" + t.TaskNr.Value.ToString(),
    71             false);
     71            "Job" + t.JobNr + " - " + "Task#" + t.TaskNr.Value.ToString());
    7272        }
    7373        jobCount++;
     
    9292          }
    9393
    94           /* TODO: Implement solution-import in problem-class
     94
    9595          if (!string.IsNullOrEmpty(spImportDialog.OptimalScheduleFileName))
    96             Content.ImportSolution(spImportDialog.OptimalScheduleFileName);
    97            * */
     96            Content.ImportJSMSolution(spImportDialog.OptimalScheduleFileName);
    9897          OnContentChanged();
    9998        }
  • branches/Scheduling/HeuristicLab.Problems.Scheduling.Views/3.3/Plugin.cs

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

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

    r6177 r6260  
    4040    }
    4141
     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
    4256    public new Schedule Content {
    4357      get { return (Schedule)base.Content; }
     
    5973
    6074    private void FillGanttChart(Schedule content) {
    61       //Add Resources as Categories
     75      ResetGanttChart();
    6276      int resCount = 0;
    63       Random random = new Random ();
     77      Random random = new Random (1);
    6478      foreach (Resource r in content.Resources) {
    6579        foreach (JSSPTask t in content.Resources[resCount].Tasks) {
     80          int categoryNr = 0;     
     81          string toolTip = "Task#" + t.TaskNr;
    6682          string categoryName = "ScheduleTasks";
    67           string toolTip = "Task#" + t.TaskNr.Value.ToString();
    6883          if (t is JSSPTask) {
    69             categoryName = "Job" + ((JSSPTask)t).Job.Index;
     84            categoryNr = ((JSSPTask)t).JobNr.Value;
     85            categoryName = "Job" + categoryNr;
    7086            toolTip = categoryName + " - " + toolTip;
    71           }
    72           ganttChart.AddCategory(categoryName, Color.FromArgb(random.Next(255), random.Next(255), random.Next(255)));
     87          } 
     88          ganttChart.AddJobColor(categoryNr);
    7389          ganttChart.AddData("Resource" + r.Index,
    74             categoryName,
     90            categoryNr,
    7591            t.StartTime.Value,
    7692            t.EndTime.Value,
    77             toolTip,
    78             false);
     93            toolTip);
    7994        }
    8095        resCount++;
     
    86101      ganttChart.Enabled = Content != null;
    87102    }
     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    }
    88128  }
    89129}
Note: See TracChangeset for help on using the changeset viewer.