Example #1
0
        protected override void buttonSetParameters_Click(object sender, EventArgs e)
        {
            try
            {
                int newNumLv1Obs = Convert.ToInt32(this.spinBoxLv1NumObservations.Value);
                int newNumLv2Obs = Convert.ToInt32(this.spinBoxLv2NumObservations.Value);

                if (newNumLv1Obs > maxNumObservations)
                {
                    throw new Nmfs.Agepro.CoreLib.InvalidAgeproParameterException(
                              "Number of Level 1 Observations exceed maximum limit of " + maxNumObservations + ".");
                }
                if (newNumLv2Obs > maxNumObservations)
                {
                    throw new Nmfs.Agepro.CoreLib.InvalidAgeproParameterException(
                              "Number of Level 2 Observations exceed maximum limit of " + maxNumObservations + ".");
                }

                lv1Observations = ControlRecruitment.ResizeDataGridTable(lv1Observations, newNumLv1Obs);
                lv2Observations = ControlRecruitment.ResizeDataGridTable(lv2Observations, newNumLv2Obs);

                ((Nmfs.Agepro.CoreLib.TwoStageEmpiricalRecruitment)
                 this.collectionAgeproRecruitmentModels[this.collectionSelectedIndex]).lv1NumObs = newNumLv1Obs;
                ((Nmfs.Agepro.CoreLib.TwoStageEmpiricalRecruitment)
                 this.collectionAgeproRecruitmentModels[this.collectionSelectedIndex]).lv2NumObs = newNumLv2Obs;
                ((Nmfs.Agepro.CoreLib.TwoStageEmpiricalRecruitment)
                 this.collectionAgeproRecruitmentModels[this.collectionSelectedIndex]).SSBBreakVal
                    = Convert.ToInt32(this.textBoxSSBBreakValue.Text);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Can not resize number of Observation(s)." + Environment.NewLine + ex.Message,
                                "AGEPRO", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Example #2
0
        private void buttonSetParameters_Click(object sender, EventArgs e)
        {
            try
            {
                int  newNumRecruitLevelsValue = Convert.ToInt32(spinBoxNumRecruitLevels.Value);
                int  newNumSSBLevelsValue     = Convert.ToInt32(spinBoxNumSSBLevels.Value);
                bool renameProbTableCols      = newNumRecruitLevelsValue > probabilityTable.Columns.Count;

                recruitLevelTable = ControlRecruitment.ResizeDataGridTable(recruitLevelTable, newNumRecruitLevelsValue);
                SSBLevelTable     = ControlRecruitment.ResizeDataGridTable(SSBLevelTable, newNumSSBLevelsValue);

                probabilityTable = ControlRecruitment.ResizeDataGridTable(probabilityTable, newNumSSBLevelsValue,
                                                                          newNumRecruitLevelsValue);

                if (renameProbTableCols)
                {
                    int ncol = 1;
                    foreach (DataColumn dcol in probabilityTable.Columns)
                    {
                        dcol.ColumnName = "PR(" + ncol + ")";
                        ncol++;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Can not readjust markov matrix level(s)." + Environment.NewLine + ex.Message,
                                "AGEPRO", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Example #3
0
        /// <summary>
        /// Changes the number of rows in the observations table, based on the value the
        /// Number of Observations spin box was set to.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected virtual void buttonSetParameters_Click(object sender, EventArgs e)
        {
            try
            {
                int newNumObservationsValue = Convert.ToInt32(this.spinBoxNumObservations.Value);

                //Catch if the number of Observations exceed maxNumObservations limit
                //(in case control couldn't prevent it)
                if (newNumObservationsValue > maxNumObservations)
                {
                    throw new Nmfs.Agepro.CoreLib.InvalidAgeproParameterException(
                              "Number of Observations exceed maximum limit of " + maxNumObservations + ".");
                }
                observationTable = ControlRecruitment.ResizeDataGridTable(observationTable, newNumObservationsValue);
                numObservations  = newNumObservationsValue;
                ((EmpiricalRecruitment)this.collectionAgeproRecruitmentModels[this.collectionSelectedIndex]).numObs
                    = newNumObservationsValue;
                if (this.empiricalSubtype == EmpiricalType.CDFZero)
                {
                    ((EmpiricalCDFZero)this.collectionAgeproRecruitmentModels[this.collectionSelectedIndex]).SSBHinge =
                        Convert.ToDouble(this.textBoxSSBHinge.Text);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Can not resize number of Observation(s)." + Environment.NewLine + ex.Message,
                                "AGEPRO", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
        public void SetFixedRecruitmentControls(EmpiricalRecruitment currentRecruit, Panel panelRecruitModelParameter)
        {
            //create empty obsTable if null
            if (!(currentRecruit.obsTable != null))
            {
                if (!(seqYears != null))
                {
                    currentRecruit.obsTable = currentRecruit.SetNewObsTable(0);
                }
                else
                {
                    currentRecruit.obsTable = currentRecruit.SetNewObsTable(seqYears.Count() - 1);
                }
            }
            else
            {
                //If recruitModel has more rows then resize
                if (currentRecruit.numObs > (this.seqYears.Count() - 1))
                {
                    currentRecruit.obsTable =
                        ControlRecruitment.ResizeDataGridTable(currentRecruit.obsTable, this.seqYears.Count() - 1);
                }
            }

            this.fixedRecruitTable = currentRecruit.obsTable;

            panelRecruitModelParameter.Controls.Clear();
            this.Dock = DockStyle.Fill;
            panelRecruitModelParameter.Controls.Add(this);
        }
Example #5
0
        /// <summary>
        /// Resizes the PStar Levels Data Grid View Table when the spinBoxNumPStarLevels value has been
        /// changed by the user.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void spinBoxNumPStarLevels_ValueChanged(object sender, EventArgs e)
        {
            if (setControlValues == false)
            {
                NumericUpDown newPStarLevel = sender as NumericUpDown;
                ControlRecruitment.ResizeDataGridTable(
                    (DataTable)this.dataGridPStarLevelValues.DataSource, 1, Convert.ToInt32(newPStarLevel.Value));

                //Rename Columns
                for (int colNum = 0; colNum < this.dataGridPStarLevelValues.Columns.Count; colNum++)
                {
                    this.dataGridPStarLevelValues.Columns[colNum].HeaderText = "Level " + (colNum + 1);

                    //Set blank cells to 0
                    if (string.IsNullOrEmpty(this.dataGridPStarLevelValues.Rows[0].Cells[colNum].Value.ToString()))
                    {
                        this.dataGridPStarLevelValues.Rows[0].Cells[colNum].Value = 0;
                    }
                }
            }
        }//end spinBoxNumPStarLevels_ValueChanged
Example #6
0
        /// <summary>
        /// Initiates the Control's "Startup State" or the "Uninitialized Model" phase.
        /// </summary>
        protected void SetupStartupState()
        {
            //AGEPRO Input Data, If any
            inputData = new AgeproInputFile();

            //Load User Controls
            controlGeneralOptions     = new ControlGeneral();
            controlMiscOptions        = new ControlMiscOptions();
            controlBootstrap          = new ControlBootstrap();
            controlFisherySelectivity = new ControlStochasticAge();
            controlDiscardFraction    = new ControlStochasticAge();
            controlNaturalMortality   = new ControlStochasticAge();
            controlBiological         = new ControlBiological(new string[] { string.Empty });
            controlJan1Weight         = new ControlStochasticWeightAge(new int[] { 0, 1 });
            controlSSBWeight          = new ControlStochasticWeightAge(new int[] { 0, 1, -1 });
            controlMidYearWeight      = new ControlStochasticWeightAge(new int[] { 0, 1, -1, -2 });
            controlCatchWeight        = new ControlStochasticWeightAge(new int[] { 0, 1, -1, -2, -3 });
            controlDiscardWeight      = new ControlStochasticWeightAge(new int[] { 0, 1, -1, -2, -3, -4 });
            controlRecruitment        = new ControlRecruitment();
            controlHarvestScenario    = new ControlHarvestScenario();

            //Set General Options Controls (to handle "New Cases")
            controlGeneralOptions.GeneralInputFile = "";
            controlGeneralOptions.GeneralModelId   = "untitled";
            inputData.General.InputFile            = "";
            inputData.CaseID = controlGeneralOptions.GeneralModelId;

            //initially set Number of Ages
            _ = controlGeneralOptions.GeneralFirstAgeClass; //Spinbox Value

            //Biological Stochastic Options
            controlFisherySelectivity.StochasticParameterLabel = "Fishery Selectivity";
            controlFisherySelectivity.IsMultiFleet             = true;
            controlFisherySelectivity.FleetDependency          = StochasticAgeFleetDependency.dependent;
            controlDiscardFraction.StochasticParameterLabel    = "Discard Fraction";
            controlDiscardFraction.IsMultiFleet              = true;
            controlDiscardFraction.FleetDependency           = StochasticAgeFleetDependency.dependent;
            controlNaturalMortality.StochasticParameterLabel = "Natural Mortality";
            controlNaturalMortality.IsMultiFleet             = false;
            controlNaturalMortality.FleetDependency          = StochasticAgeFleetDependency.independent;

            //Weight Age Options
            controlJan1Weight.IsMultiFleet       = false;
            controlJan1Weight.FleetDependency    = StochasticAgeFleetDependency.independent;
            controlSSBWeight.IsMultiFleet        = false;
            controlSSBWeight.FleetDependency     = StochasticAgeFleetDependency.independent;
            controlMidYearWeight.IsMultiFleet    = false;
            controlMidYearWeight.FleetDependency = StochasticAgeFleetDependency.independent;
            controlCatchWeight.IsMultiFleet      = true;
            controlCatchWeight.FleetDependency   = StochasticAgeFleetDependency.dependent;
            controlDiscardWeight.IsMultiFleet    = true;
            controlDiscardWeight.FleetDependency = StochasticAgeFleetDependency.dependent;

            //Set WeightAgeType
            controlJan1Weight.WeightAgeType    = StochasticWeightOfAge.Jan1Weight;
            controlSSBWeight.WeightAgeType     = StochasticWeightOfAge.SSBWeight;
            controlMidYearWeight.WeightAgeType = StochasticWeightOfAge.MidYearWeight;
            controlCatchWeight.WeightAgeType   = StochasticWeightOfAge.CatchWeight;
            controlDiscardWeight.WeightAgeType = StochasticWeightOfAge.DiscardWeight;

            //Weights Option
            controlJan1Weight.ShowJan1WeightsOption    = false;
            controlJan1Weight.ShowSSBWeightsOption     = false;
            controlJan1Weight.showMidYearWeightsOption = false;
            controlJan1Weight.ShowCatchWeightsOption   = false;
            //SSB
            controlSSBWeight.ShowSSBWeightsOption     = false;
            controlSSBWeight.showMidYearWeightsOption = false;
            controlSSBWeight.ShowCatchWeightsOption   = false;
            //Mid-Year
            controlMidYearWeight.showMidYearWeightsOption = false;
            controlMidYearWeight.ShowCatchWeightsOption   = false;
            //Catch-weight
            controlCatchWeight.ShowCatchWeightsOption = false;
        }