Changeset 3717


Ignore:
Timestamp:
05/08/10 04:36:13 (12 years ago)
Author:
mkommend
Message:

sorting of column names in RunCollection and fixed errors in RunCollectionConstraints (ticket #970)

Location:
trunk/sources/HeuristicLab.Optimization/3.3
Files:
5 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj

    r3702 r3717  
    104104    <Compile Include="Interfaces\IStrategyParameterCreator.cs" />
    105105    <Compile Include="Interfaces\IRun.cs" />
    106     <Compile Include="IRunCollectionConstraint.cs" />
     106    <Compile Include="RunCollectionConstraints\IRunCollectionConstraint.cs" />
    107107    <Compile Include="OptimizerList.cs" />
    108108    <Compile Include="Experiment.cs" />
  • trunk/sources/HeuristicLab.Optimization/3.3/RunCollection.cs

    r3716 r3717  
    147147
    148148    public IItem GetValue(IRun run, int columnIndex) {
     149      string name = ((IStringConvertibleMatrix)this).ColumnNames.ElementAt(columnIndex);
     150      return GetValue(run, name);
     151    }
     152
     153    public IItem GetValue(IRun run, string columnName) {
    149154      IItem value = null;
    150       if (columnIndex < parameterNames.Count) {
    151         string parameterName = parameterNames[columnIndex];
    152         if (run.Parameters.ContainsKey(parameterName))
    153           value = run.Parameters[parameterName];
    154       } else if (columnIndex < parameterNames.Count + resultNames.Count) {
    155         string resultName = resultNames[columnIndex - parameterNames.Count];
    156         if (run.Results.ContainsKey(resultName))
    157           value = run.Results[resultName];
    158       }
     155       if (run.Parameters.ContainsKey(columnName))
     156         value = run.Parameters[columnName];
     157       else if (run.Results.ContainsKey(columnName))
     158         value = run.Results[columnName];
    159159      return value;
    160160    }
     161
    161162
    162163    public override IDeepCloneable Clone(Cloner cloner) {
     
    193194        List<string> value = new List<string>(parameterNames);
    194195        value.AddRange(resultNames);
     196        value.Sort();
    195197        return value;
    196198      }
  • trunk/sources/HeuristicLab.Optimization/3.3/RunCollectionConstraints/IRunCollectionConstraint.cs

    r3713 r3717  
    2929  public interface IRunCollectionConstraint : IConstraint{
    3030    new RunCollection ConstrainedValue { get; set; }
    31     int ConstraintColumn { get; set; }
     31    string ConstraintColumn { get; set; }
    3232    event EventHandler ConstraintColumnChanged;
    3333  }
  • trunk/sources/HeuristicLab.Optimization/3.3/RunCollectionConstraints/RunCollectionComparisonConstraint.cs

    r3632 r3717  
    6161
    6262    [Storable]
    63     private int constraintColumn;
    64     public int ConstraintColumn {
     63    private string constraintColumn;
     64    public string ConstraintColumn {
    6565      get { return constraintColumn; }
    6666      set {
    67         if (value < 0 || value >= ((IStringConvertibleMatrix)ConstrainedValue).ColumnNames.Count())
     67        if (!((IStringConvertibleMatrix)ConstrainedValue).ColumnNames.Contains(value))
    6868          throw new ArgumentException("Could not set ConstraintData to not existing column index.");
    6969        if (constraintColumn != value) {
     
    8080      if (handler != null)
    8181        handler(this, EventArgs.Empty);
     82    }
     83
     84    protected override void OnConstrainedValueChanged() {
     85      base.OnConstrainedValueChanged();
     86      IStringConvertibleMatrix matrix = (IStringConvertibleMatrix)ConstrainedValue;
     87      if (constraintColumn == null && ConstrainedValue != null && matrix.Columns != 0)
     88        constraintColumn = matrix.ColumnNames.ElementAt(0);
    8289    }
    8390
     
    111118      IStringConvertibleMatrix matrix = ConstrainedValue;
    112119      if (matrix != null && matrix.ColumnNames.Count() != 0)
    113         s += matrix.ColumnNames.ElementAt(constraintColumn) + " ";
     120        s += constraintColumn + " ";
    114121      else
    115122        return "ComparisonConstraint";
  • trunk/sources/HeuristicLab.Optimization/3.3/RunCollectionConstraints/RunCollectionEqualityConstraint.cs

    r3617 r3717  
    5858
    5959    [Storable]
    60     private int constraintColumn;
    61     public int ConstraintColumn {
     60    private string constraintColumn;
     61    public string ConstraintColumn {
    6262      get { return constraintColumn; }
    6363      set {
    64         if (value < 0 || value >= ((IStringConvertibleMatrix)ConstrainedValue).ColumnNames.Count())
     64        if (!((IStringConvertibleMatrix)ConstrainedValue).ColumnNames.Contains(value))
    6565          throw new ArgumentException("Could not set ConstraintData to not existing column index.");
    6666        if (constraintColumn != value) {
     
    7777      if (handler != null)
    7878        handler(this, EventArgs.Empty);
     79    }
     80
     81    protected override void OnConstrainedValueChanged() {
     82      base.OnConstrainedValueChanged();
     83      IStringConvertibleMatrix matrix = (IStringConvertibleMatrix)ConstrainedValue;
     84      if (constraintColumn == null && ConstrainedValue != null && matrix.Columns != 0)
     85        constraintColumn = matrix.ColumnNames.ElementAt(0);
    7986    }
    8087
     
    108115      IStringConvertibleMatrix matrix = ConstrainedValue;
    109116      if (matrix != null && matrix.ColumnNames.Count() != 0)
    110         s += matrix.ColumnNames.ElementAt(constraintColumn) + " ";
     117        s += constraintColumn + " ";
    111118      else
    112119        return "EqualityConstraint";
  • trunk/sources/HeuristicLab.Optimization/3.3/RunCollectionConstraints/RunCollectionTypeCompatiblityConstraint.cs

    r3632 r3717  
    5151    }
    5252    [Storable]
    53     private int constraintColumn;
    54     public int ConstraintColumn {
     53    private string constraintColumn;
     54    public string ConstraintColumn {
    5555      get { return constraintColumn; }
    5656      set {
    57         if (value < 0 || value >= ((IStringConvertibleMatrix)ConstrainedValue).ColumnNames.Count())
     57        if (!((IStringConvertibleMatrix)ConstrainedValue).ColumnNames.Contains(value))
    5858          throw new ArgumentException("Could not set ConstraintData to not existing column index.");
    5959        if (constraintColumn != value) {
     
    7070      if (handler != null)
    7171        handler(this, EventArgs.Empty);
     72    }
     73
     74    protected override void OnConstrainedValueChanged() {
     75      base.OnConstrainedValueChanged();
     76      IStringConvertibleMatrix matrix = (IStringConvertibleMatrix)ConstrainedValue;
     77      if (constraintColumn == null && ConstrainedValue != null && matrix.Columns != 0)
     78        constraintColumn = matrix.ColumnNames.ElementAt(0);
    7279    }
    7380
     
    101108      IStringConvertibleMatrix matrix = ConstrainedValue;
    102109      if (matrix != null && matrix.ColumnNames.Count() != 0)
    103         s += matrix.ColumnNames.ElementAt(constraintColumn) + " ";
     110        s += constraintColumn + " ";
    104111      else
    105112        return "TypeCompabitilityConstraint";
Note: See TracChangeset for help on using the changeset viewer.