Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/16/11 11:24:24 (12 years ago)
Author:
abeham
Message:

#567

  • Added item template
  • Adapted problem template
  • Enabled tab key to continue editing the next column in the grid
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/Templates/HeuristicLab.VS2010Wizards/ProblemWizardForm.cs

    r4214 r5704  
    11using System;
    2 using System.Collections.Generic;
    3 using System.ComponentModel;
    4 using System.Data;
    5 using System.Drawing;
    6 using System.Linq;
    7 using System.Text;
    82using System.Windows.Forms;
    93
     
    5044      private set;
    5145    }
    52     public string ProblemSpecificParameterProperties {
    53       get;
    54       private set;
    55     }
    56     public string ProblemSpecificProperties {
    57       get;
    58       private set;
    59     }
    60     public string ProblemSpecificParameterInitializers {
    61       get;
    62       private set;
    63     }
    6446
    6547    public ProblemWizardForm() {
    6648      InitializeComponent();
    67       IsSingleObjective = singleObjectiveCheckBox.Checked;
    68       IsMultiObjective = multiObjectiveCheckBox.Checked;
     49      IsSingleObjective = singleObjectiveRadioButton.Checked;
     50      IsMultiObjective = multiObjectiveRadioButton.Checked;
    6951      EvaluatorType = evaluatorTypeTextBox.Text;
    7052      SolutionCreatorType = solutionCreatorTypeTextBox.Text;
     53      nextButton.Enabled = IsSingleObjective || IsMultiObjective;
     54      finishButton.Enabled = nextButton.Enabled;
    7155    }
    7256
     
    8569      ProblemName = problemNameTextBox.Text;
    8670      ProblemDescription = problemDescriptionTextBox.Text;
    87       IsMultiObjective = multiObjectiveCheckBox.Checked;
     71      IsSingleObjective = singleObjectiveRadioButton.Checked;
     72      IsMultiObjective = multiObjectiveRadioButton.Checked;
    8873      ParameterProperties = parametersControl.GetParameterProperties("public");
    8974      Properties = parametersControl.GetProperties("public");
    9075      ParameterInitializers = parametersControl.GetInitializers();
    9176
    92       if (IsMultiObjective && IsSingleObjective) {
    93         ProblemTypeImplementation = "ISingleObjectiveProblem, IMultiObjectiveProblem";
     77      if (IsSingleObjective) {
     78        ProblemTypeImplementation = "SingleObjectiveProblem<" + EvaluatorType + ", " + SolutionCreatorType + ">";
    9479      } else if (IsMultiObjective) {
    95         ProblemTypeImplementation = "IMultiObjectiveProblem";
    96       }  else if (IsSingleObjective)
    97         ProblemTypeImplementation = "ISingleObjectiveProblem";
    98 
    99       ProblemSpecificParameterProperties = GetParamProps();
    100       ProblemSpecificProperties = GetProps();
    101       ProblemSpecificParameterInitializers = GetParamInitializers();
    102     }
    103 
    104     private string GetParamProps() {
    105       StringBuilder builder = new StringBuilder();
    106       if (IsSingleObjective) {
    107         builder.Append(@"public OptionalValueParameter<DoubleValue> BestKnownQualityParameter {
    108       get { return (OptionalValueParameter<DoubleValue>)Parameters[""BestKnownQuality""]; }
    109     }
    110     IParameter ISingleObjectiveProblem.BestKnownQualityParameter {
    111       get { return BestKnownQualityParameter; }
    112     }");
    113         builder.Append(Environment.NewLine);
    114         builder.Append(@"public ValueParameter<BoolValue> MaximizationParameter {
    115       get { return (ValueParameter<BoolValue>)Parameters[""Maximization""]; }
    116     }
    117     IParameter ISingleObjectiveProblem.MaximizationParameter {
    118       get { return MaximizationParameter; }
    119     }");
    120         builder.Append(Environment.NewLine);
     80        ProblemTypeImplementation = "MultiObjectiveProblem<" + EvaluatorType + ", " + SolutionCreatorType + ">";
    12181      }
    122       if (IsMultiObjective) {
    123         builder.Append(@" public ValueParameter<BoolArray> MultiObjectiveMaximizationParameter {
    124       get { return (ValueParameter<BoolArray>)Parameters[""MultiObjectiveMaximization""]; }
    125     }
    126     IParameter IMultiObjectiveProblem.MaximizationParameter {
    127       get { return MultiObjectiveMaximizationParameter; }
    128     }");
    129         builder.Append(Environment.NewLine);
    130       }
    131       builder.Append(@"public ValueParameter<" + SolutionCreatorType + @"> SolutionCreatorParameter {
    132       get { return (ValueParameter<" + SolutionCreatorType + @">)Parameters[""SolutionCreator""]; }
    133     }
    134     IParameter IProblem.SolutionCreatorParameter {
    135       get { return SolutionCreatorParameter; }
    136     }
    137     public ValueParameter<" + EvaluatorType + @"> EvaluatorParameter {
    138       get { return (ValueParameter<" + EvaluatorType + @">)Parameters[""Evaluator""]; }
    139     }
    140     IParameter IProblem.EvaluatorParameter {
    141       get { return EvaluatorParameter; }
    142     }");
    143       return builder.ToString();
    144     }
    145 
    146     private string GetProps() {
    147       StringBuilder builder = new StringBuilder();
    148       builder.Append(@"public " + SolutionCreatorType + @" SolutionCreator {
    149       get { return SolutionCreatorParameter.Value; }
    150       set { SolutionCreatorParameter.Value = value; }
    151     }
    152     ISolutionCreator IProblem.SolutionCreator {
    153       get { return SolutionCreatorParameter.Value; }
    154     }
    155     public " + EvaluatorType + @" Evaluator {
    156       get { return EvaluatorParameter.Value; }
    157       set { EvaluatorParameter.Value = value; }
    158     }");
    159       builder.Append(Environment.NewLine);
    160       if (IsSingleObjective) {
    161         builder.Append(@"ISingleObjectiveEvaluator ISingleObjectiveProblem.Evaluator {
    162       get { return EvaluatorParameter.Value; }
    163     }");
    164         builder.Append(Environment.NewLine);
    165       }
    166       if (IsMultiObjective) {
    167         builder.Append(@"IMultiObjectiveEvaluator IMultiObjectiveProblem.Evaluator {
    168       get { return EvaluatorParameter.Value; }
    169     }");
    170         builder.Append(Environment.NewLine);
    171       }
    172       builder.Append(@"IEvaluator IProblem.Evaluator {
    173       get { return EvaluatorParameter.Value; }
    174     }");
    175       builder.Append(Environment.NewLine);
    176       if (IsSingleObjective) {
    177         builder.Append(@"public DoubleValue BestKnownQuality {
    178       get { return BestKnownQualityParameter.Value; }
    179       set { BestKnownQualityParameter.Value = value; }
    180     }");
    181         builder.Append(Environment.NewLine);
    182       }
    183       return builder.ToString();
    184     }
    185 
    186     private string GetParamInitializers() {
    187       StringBuilder builder = new StringBuilder();
    188       if (IsSingleObjective) {
    189         builder.Append(@"Parameters.Add(new ValueParameter<BoolValue>(""Maximization"", ""TODO: Set to the false for minimization, true for maximization and add a description."", new BoolValue(false)));");
    190         builder.Append(Environment.NewLine);
    191       }
    192       if (IsMultiObjective) {
    193         builder.Append("// TODO: Change the default value to the number of objectives." + Environment.NewLine);
    194         builder.Append(@"Parameters.Add(new ValueParameter<BoolArray>(""MultiObjectiveMaximization"", ""Set to false as the error of the regression model should be minimized."", new BoolArray(new bool[] {false, false})));");
    195         builder.Append(Environment.NewLine);
    196       }
    197       builder.Append("// TODO: Add a default solution creator." + Environment.NewLine);
    198       builder.Append("Parameters.Add(new ValueParameter<" + SolutionCreatorType + ">(\"SolutionCreator\", \"The operator which should be used to create new solutions.\", null));");
    199       builder.Append(Environment.NewLine);
    200       builder.Append("//TODO: Add a default evaluator." + Environment.NewLine);
    201       builder.Append("Parameters.Add(new ValueParameter<" + EvaluatorType + ">(\"Evaluator\", \"The operator which should be used to evaluate solutions.\", null));");
    202       builder.Append(Environment.NewLine);
    203       if (IsSingleObjective) {
    204         builder.Append("Parameters.Add(new OptionalValueParameter<DoubleValue>(\"BestKnownQuality\", \"The quality of the best known solution.\"));");
    205         builder.Append(Environment.NewLine);
    206       }
    207       return builder.ToString();
    20882    }
    20983
     
    22296    }
    22397
    224     private void singleObjectiveCheckBox_CheckedChanged(object sender, EventArgs e) {
    225       IsSingleObjective = singleObjectiveCheckBox.Checked;
     98    private void singleObjectiveRadioButton_CheckedChanged(object sender, EventArgs e) {
     99      IsSingleObjective = singleObjectiveRadioButton.Checked;
    226100      nextButton.Enabled = IsSingleObjective || IsMultiObjective;
    227101      finishButton.Enabled = nextButton.Enabled;
    228102    }
    229     private void multiObjectiveCheckBox_CheckedChanged(object sender, EventArgs e) {
    230       IsMultiObjective = multiObjectiveCheckBox.Checked;
     103    private void multiObjectiveRadioButton_CheckedChanged(object sender, EventArgs e) {
     104      IsMultiObjective = multiObjectiveRadioButton.Checked;
    231105      nextButton.Enabled = IsSingleObjective || IsMultiObjective;
    232106      finishButton.Enabled = nextButton.Enabled;
Note: See TracChangeset for help on using the changeset viewer.