Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/19/10 18:49:17 (15 years ago)
Author:
gkronber
Message:

Removed max. and min. time offset constraints as algorithm parameters and from all engines. The time constraints were added to the relevant terminal symbols (variable & differential) instead. The time offset constraint can be changed by editing the symbols in the function library. #880 (Max and min time offsets for variable symbols are not set correctly by FunctionLibraryInjectors)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.GP/3.3/FunctionView.cs

    r2729 r2843  
    3030namespace HeuristicLab.GP {
    3131  public partial class FunctionView : ViewBase {
    32     private Function function;
     32
    3333    private const string ALL_SLOTS = "All";
    3434    private string selectedSlot = ALL_SLOTS;
    3535
    36     public FunctionView() {
     36    public Function Function {
     37      get {
     38        return (Function)Item;
     39      }
     40      set {
     41        Item = value;
     42      }
     43    }
     44
     45    public FunctionView()
     46      : base() {
    3747      InitializeComponent();
    3848    }
    3949
    4050    public FunctionView(Function function)
    41       : this() {
    42       this.function = function;
    43       function.Changed += (sender, args) => UpdateControls();
    44       Refresh();
     51      : base() {
     52      InitializeComponent();
     53      Function = function;
     54      UpdateControls();
    4555    }
    4656
    4757    protected override void UpdateControls() {
    48       nameTextBox.Text = function.Name;
    49       minSubTreesTextBox.Text = function.MinSubTrees.ToString();
    50       maxSubTreesTextBox.Text = function.MaxSubTrees.ToString();
    51       ticketsTextBox.Text = function.Tickets.ToString();
    52       minTreeHeightTextBox.Text = function.MinTreeHeight.ToString();
    53       minTreeSizeTextBox.Text = function.MinTreeSize.ToString();
    54       if (function.Initializer != null) {
    55         initializerTextBox.Text = function.Initializer.Name;
     58      nameTextBox.Text = Function.Name;
     59      minSubTreesTextBox.Text = Function.MinSubTrees.ToString();
     60      maxSubTreesTextBox.Text = Function.MaxSubTrees.ToString();
     61      ticketsTextBox.Text = Function.Tickets.ToString();
     62      minTreeHeightTextBox.Text = Function.MinTreeHeight.ToString();
     63      minTreeSizeTextBox.Text = Function.MinTreeSize.ToString();
     64      if (Function.Initializer != null) {
     65        initializerTextBox.Text = Function.Initializer.Name;
    5666      } else {
    5767        initializerTextBox.Enabled = false;
    5868        editInitializerButton.Enabled = false;
    5969      }
    60       if (function.Manipulator != null) {
    61         manipulatorTextBox.Text = function.Manipulator.Name;
     70      if (Function.Manipulator != null) {
     71        manipulatorTextBox.Text = Function.Manipulator.Name;
    6272      } else {
    6373        manipulatorTextBox.Enabled = false;
     
    6777      argumentComboBox.Items.Clear();
    6878      argumentComboBox.Items.Add(ALL_SLOTS);
    69       for (int i = 0; i < function.MaxSubTrees; i++) {
     79      for (int i = 0; i < Function.MaxSubTrees; i++) {
    7080        argumentComboBox.Items.Add(i.ToString());
    7181      }
     
    7585
    7686    private void UpdateAllowedSubFunctionsList() {
    77       if (function.MaxSubTrees > 0) {
     87      if (Function.MaxSubTrees > 0) {
    7888        subFunctionsListBox.Items.Clear();
    7989        if (selectedSlot == ALL_SLOTS) {
    80           IEnumerable<IFunction> functionSet = function.GetAllowedSubFunctions(0);
    81           for (int i = 1; i < function.MaxSubTrees; i++) {
    82             functionSet = functionSet.Intersect(function.GetAllowedSubFunctions(i));
     90          IEnumerable<IFunction> functionSet = Function.GetAllowedSubFunctions(0);
     91          for (int i = 1; i < Function.MaxSubTrees; i++) {
     92            functionSet = functionSet.Intersect(Function.GetAllowedSubFunctions(i));
    8393          }
    8494          foreach (var subFun in functionSet) {
     
    8797        } else {
    8898          int slot = int.Parse(selectedSlot);
    89           foreach (var subFun in function.GetAllowedSubFunctions(slot)) {
     99          foreach (var subFun in Function.GetAllowedSubFunctions(slot)) {
    90100            subFunctionsListBox.Items.Add(subFun);
    91101          }
     
    100110      string name = nameTextBox.Text;
    101111      if (!string.IsNullOrEmpty(name)) {
    102         function.Name = name;
     112        Function.Name = name;
    103113        functionPropertiesErrorProvider.SetError(nameTextBox, string.Empty);
    104114      } else {
     
    110120      int minSubTrees;
    111121      if (int.TryParse(minSubTreesTextBox.Text, out minSubTrees) && minSubTrees >= 0) {
    112         function.MinSubTrees = minSubTrees;
     122        Function.MinSubTrees = minSubTrees;
    113123        functionPropertiesErrorProvider.SetError(minSubTreesTextBox, string.Empty);
    114124      } else {
     
    120130      int maxSubTrees;
    121131      if (int.TryParse(maxSubTreesTextBox.Text, out maxSubTrees) && maxSubTrees >= 0) {
    122         function.MaxSubTrees = maxSubTrees;
     132        Function.MaxSubTrees = maxSubTrees;
    123133        functionPropertiesErrorProvider.SetError(maxSubTreesTextBox, string.Empty);
    124134      } else {
     
    130140      double tickets;
    131141      if (double.TryParse(ticketsTextBox.Text, out tickets) && tickets >= 0) {
    132         function.Tickets = tickets;
     142        Function.Tickets = tickets;
    133143        functionPropertiesErrorProvider.SetError(ticketsTextBox, string.Empty);
    134144      } else {
     
    138148
    139149    private void editInitializerButton_Click(object sender, EventArgs e) {
    140       ControlManager.Manager.ShowControl(function.Initializer.CreateView());
     150      ControlManager.Manager.ShowControl(Function.Initializer.CreateView());
    141151    }
    142152
    143153    private void editManipulatorButton_Click(object sender, EventArgs e) {
    144       ControlManager.Manager.ShowControl(function.Manipulator.CreateView());
     154      ControlManager.Manager.ShowControl(Function.Manipulator.CreateView());
    145155    }
    146156
     
    168178            Cursor = Cursors.WaitCursor;
    169179            if (selectedSlot == ALL_SLOTS) {
    170               for (int slot = 0; slot < function.MaxSubTrees; slot++)
    171                 function.AddAllowedSubFunction(fun, slot);
     180              for (int slot = 0; slot < Function.MaxSubTrees; slot++)
     181                Function.AddAllowedSubFunction(fun, slot);
    172182            } else {
    173183              int slot = int.Parse(selectedSlot);
    174               function.AddAllowedSubFunction(fun, slot);
     184              Function.AddAllowedSubFunction(fun, slot);
    175185            }
    176186          }
     
    188198          if (selectedSlot == ALL_SLOTS) {
    189199            List<IFunction> removedSubFunctions = new List<IFunction>(subFunctionsListBox.SelectedItems.Cast<IFunction>());
    190             for (int slot = 0; slot < function.MaxSubTrees; slot++) {
     200            for (int slot = 0; slot < Function.MaxSubTrees; slot++) {
    191201              foreach (var subFun in removedSubFunctions) {
    192                 function.RemoveAllowedSubFunction((IFunction)subFun, slot);
     202                Function.RemoveAllowedSubFunction((IFunction)subFun, slot);
    193203              }
    194204            }
     
    197207            List<IFunction> removedSubFunctions = new List<IFunction>(subFunctionsListBox.SelectedItems.Cast<IFunction>());
    198208            foreach (var subFun in removedSubFunctions) {
    199               function.RemoveAllowedSubFunction(subFun, slot);
     209              Function.RemoveAllowedSubFunction(subFun, slot);
    200210            }
    201211          }
Note: See TracChangeset for help on using the changeset viewer.