Exemplo n.º 1
0
 private void LoadBoolAndEnumParameters(Chromosomes chr)
 {
     if (chromosomes != null)
     {
         chr.InitializeValuesFrom(chromosomes);
     }
     chromosomes = chr;
     treeView.Nodes.Clear();
     foreach (Chromosome chromosome in chr)
     {
         var nonPrimitiveChromosome = chromosome as NonPrimitiveChromosome;
         if (nonPrimitiveChromosome == null)
         {
             continue;
         }
         var nameNode = new TreeNode {
             Text = nonPrimitiveChromosome.Parameter.Name, Checked = true
         };
         treeView.Nodes.Add(nameNode);
         foreach (NonPrimitiveChromosome.ChromosomeInfo chromosomeInfo in nonPrimitiveChromosome.GetListedValues())
         {
             var valueNode = new TreeNode {
                 Text = chromosomeInfo.Name, Checked = chromosomeInfo.Active
             };
             nameNode.Nodes.Add(valueNode);
         }
         nameNode.Expand();
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent(Chromosomes ch)
 {
     this.SuspendLayout();
     this.treeView = new GoTreeView();
     //
     // treeView
     //
     this.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
     this.UpdateStyles();
     LoadBoolAndEnumParameters(ch);
     this.treeView.Anchor = (((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                | System.Windows.Forms.AnchorStyles.Left)
                               | System.Windows.Forms.AnchorStyles.Right)));
     this.treeView.CheckBoxes   = true;
     this.treeView.Location     = new System.Drawing.Point(12, 12);
     this.treeView.Name         = "treeView";
     this.treeView.Size         = new System.Drawing.Size(264, 313);
     this.treeView.TabIndex     = 2;
     this.treeView.BeforeCheck += this.OnBeforeCheck;
     this.treeView.AfterCheck  += this.OnAfterCheck;
     this.buttonOk              = new System.Windows.Forms.Button();
     this.buttonCancel          = new System.Windows.Forms.Button();
     //
     // buttonOk
     //
     this.buttonOk.Anchor                  = (((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
     this.buttonOk.DialogResult            = System.Windows.Forms.DialogResult.OK;
     this.buttonOk.Location                = new System.Drawing.Point(127, 333);
     this.buttonOk.Name                    = "buttonOk";
     this.buttonOk.Size                    = new System.Drawing.Size(75, 23);
     this.buttonOk.TabIndex                = 0;
     this.buttonOk.Text                    = "OK";
     this.buttonOk.UseVisualStyleBackColor = true;
     //
     // buttonCancel
     //
     this.buttonCancel.Anchor                  = (((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
     this.buttonCancel.DialogResult            = System.Windows.Forms.DialogResult.Abort;
     this.buttonCancel.Location                = new System.Drawing.Point(208, 333);
     this.buttonCancel.Name                    = "buttonCancel";
     this.buttonCancel.Size                    = new System.Drawing.Size(69, 23);
     this.buttonCancel.TabIndex                = 1;
     this.buttonCancel.Text                    = "Cancel";
     this.buttonCancel.UseVisualStyleBackColor = true;
     //
     // GoForm
     //
     this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     this.AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Font;
     this.ClientSize          = new System.Drawing.Size(288, 366);
     this.Controls.Add(this.treeView);
     this.Controls.Add(this.buttonCancel);
     this.Controls.Add(this.buttonOk);
     this.MinimumSize = new System.Drawing.Size(180, 241);
     this.Name        = "GoForm";
     this.ShowIcon    = false;
     this.Text        = "Genetic Optimizer Options";
     this.ResumeLayout(false);
 }
Exemplo n.º 3
0
        public object Clone()
        {
            var ret = new Chromosomes();

            foreach (Chromosome chromosome in chromosomes)
            {
                ret.ChromosomesList.Add((Chromosome)chromosome.Clone());
            }
            ret.HasBoolOrEnum = HasBoolOrEnum;
            return(ret);
        }
Exemplo n.º 4
0
 public void InitializeValuesFrom(Chromosomes source)
 {
     foreach (var chromosome in this)
     {
         var tmpChromosome = source.Find(chromosome);
         if (tmpChromosome == null)
         {
             continue;
         }
         var nonPrimitiveOld = tmpChromosome     as NonPrimitiveChromosome;
         var nonPrimitiveNew = chromosome        as NonPrimitiveChromosome;
         if (nonPrimitiveOld == null || nonPrimitiveNew == null)
         {
             continue;
         }
         nonPrimitiveNew.InitializeFrom(nonPrimitiveOld);
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Called before Optimize() to setup the optimizer.
        /// Always called in main thread which would allow for putting additional GUI in here.
        /// </summary>
        public override void Initialize()
        {
            // don't forget to call Initialize() on the base class before any custom handling
            base.Initialize();
            bool optionWindowRequired = false;

            StrategyParameters = new Chromosomes(Strategy, true);
            if (StrategyParameters.HasBoolOrEnum)
            {
                optionWindowRequired = true;
                if (options == null)
                {
                    options = new GoForm(StrategyParameters);
                }
            }

            if (optionWindowRequired && options.ShowDialog(Form.ActiveForm) != DialogResult.OK)
            {
                StrategyParameters = new Chromosomes(Strategy, true);
            }
        }
Exemplo n.º 6
0
 public GoForm(Chromosomes ch)
 {
     InitializeComponent(ch);
 }