public RmInitBeh(CMatrix M, int NumBehaviorsDefined, string[] BehaviorNames, int BehaviorIndex) { // 5 is entered as a param for Construct() is due to this form being used to // show the behavior transition as a function of time and current behavior // the associated matrix model of which has 5 more columns in it than the // number of behaviors it models: start time, end time, zero probability + one // for each behavior + T50 and k (slope)). InitializeComponent(); m_behaviorIndex = BehaviorIndex; m_displayType = MBSDEFAULTS.BITMAPDISPLAYTYPE.BEHAVIOR_TRANSITION; Construct(M, NumBehaviorsDefined, BehaviorNames, 5); }
public FrmTransitionTest(MBSDEFAULTS.BITMAPDISPLAYTYPE Type, CMatrix Matrix, string[] BehNameArray, int BehIndex) { InitializeComponent(); if(Type == MBSDEFAULTS.BITMAPDISPLAYTYPE.BEHAVIOR_TRANSITION) Text = BehNameArray[BehIndex] + " (Behavior " + (BehIndex + 1) + ") Transition Trials"; else Text = "Initial Behavior Trials"; m_displayType = Type; m_behaviorIndex = BehIndex; m_matrix = Matrix; m_behaviorNameArray = BehNameArray; m_numBehaviors = Matrix.ColumnCount - 5; Construct(); }
//------------// // Constructor //------------// // 'NumAdditionalColumns' is the column count above the number of behaviors so // must include the first column that represents the starting range of zero of a // behavior and therefore must be 1 or greater. For the initial behavior matrix // 'NumAdditionalColumns' then must be 3 (for the two additional columns for start // time and end time plus the 0 probablility starting column) and for the // behavior translation as a function of time it must be 5 for the same reason // plus the slope and ave time in behavior... or something... public RmInitBeh(CMatrix M, int NumBehaviorsDefined, string[] BehaviorNames) { // The 3 entered as a param for Construct() is due to this form being used to // show initial behavior model. The initial behavior matrix has 3 more // columns in it than the number of behaviors it models: start time, end time, // zero probability + one for each behavior. InitializeComponent(); m_displayType = MBSDEFAULTS.BITMAPDISPLAYTYPE.INITIAL_BEHAVIOR; BehaviorNumberLabel.Visible = false; BehaviorNameLabel.Visible = false; label6.Visible = false; DurationTextBoxMax.Visible = false; DurationTextBoxAve.Visible = false; DurationTextBoxMin.Visible = false; Construct(M, NumBehaviorsDefined, BehaviorNames, 3); }
public FrmTransitionTest(MBSDEFAULTS.BITMAPDISPLAYTYPE Type, CMatrix Matrix, string[] BehNameArray) { InitializeComponent(); Text = "Intitial Behavior Trials"; BehaviorNumberLabel.Visible = false; BehaviorNameLabel.Visible = false; label6.Visible = false; DurationTextBoxMax.Visible = false; DurationTextBoxAve.Visible = false; DurationTextBoxMin.Visible = false; m_displayType = Type; m_behaviorIndex = -1; m_matrix = Matrix; m_behaviorNameArray = BehNameArray; m_numBehaviors = Matrix.ColumnCount - 3; Construct(); }
public Boolean DeleteColumn(int Index) { int i, j, col; CMatrix cpy = new CMatrix(); // Precheck. if(false == CUtil.CheckIndex(ColumnCount, Index)) return false; if(ColumnCount == 1) { m_a = null; m_lastColumnCount = 0; return true; } // Create the matrix cpy.m_a = new double[m_a.Length][]; for(i=0; i<RowCount; i++) cpy.m_a[i] = new double[ColumnCount-1]; // Set the matrix for(i=0; i<RowCount; i++) { for(j=0, col=0; j<ColumnCount; j++) { if(j != Index) { cpy.m_a[i][col] = m_a[i][j]; // The last behavior's probability must be 1.0 if(col == cpy.m_a[i].Length-1) cpy.m_a[i][col] = 1.0; col++; } } } m_a = cpy.m_a; m_lastColumnCount = ColumnCount-1; return true; }
private void CheckClockStartAndEndTimes(CMatrix M) { #if false int lastRow; if(M == null || M.RowCount == 0) return; if(CUtil.TimeIsZeroOr24(M[0][0]) == true && CUtil.TimeIsZeroOr24(M[0][1]) == true) { M[0][0] = 0.0; M[0][1] = 24.0; } #endif }
void Construct(CMatrix M, int NumBehaviorsDefined, string[] BehaviorNames, int NumAdditionalColumns) { int i; // This assert could go away if this form were to ever need to be used for a matrix // without colums but is left in for now because it isn't being used that // way currently. For now at the very least there will always be a need // for 1+ the number of behavior number of columns. Debug.Assert(NumAdditionalColumns >= 1); CopyControls(); m_matrix = M; m_initializing = true; this.Text = m_szTitle; m_numTrials = NORMAL_TRIALS_FACTOR/m_matrix.RowCount; NumTrialsButton.Text = "" + m_numTrials; m_behaviorNameArray = BehaviorNames; m_numBehaviorsDefined = NumBehaviorsDefined; BehaviorCountLabel.Text = "Species Defined Behavior Count: " + NumBehaviorsDefined; MatrixTextBox.Text = M.ConvertToStringB(); MatrixDimensionsLabel.Text = "Matrix Dimensions: " + M.RowCount + "x" + M.ColumnCount; m_szFormatOK = UpdateModel(); RefreshButton.Enabled = false; DoneButton.Enabled = true; NumTrialsButton.Enabled = true; m_initializing = false; //---------------------------// // Display the behavior names //---------------------------// if(m_displayType == MBSDEFAULTS.BITMAPDISPLAYTYPE.INITIAL_BEHAVIOR) { BehaviorNameLabel.Text = ""; BehaviorNumberLabel.Visible = false; } else { BehaviorNameLabel.Text = m_behaviorNameArray[m_behaviorIndex]; BehaviorNumberLabel.Visible = true; BehaviorNumberLabel.Text = "" + "(" + (m_behaviorIndex+1) + ")"; } InitializeBehaviorTransitionAsAFunctionOfTimeBitMapVars(); RunTransitionOverTimeTest(CUtil.CopyMatrix(m_matrix)); // Generate and display initial data for(i=0; i<m_behaviorNameArray.Length; i++) { m_transitionLabelArray[i].Text = m_behaviorNameArray[i]; m_transitionLabelNumberArray[i].Visible = true; } for(; i<NUM_NRML_BUTTONS; i++) { m_transitionLabelArray[i].Text = ""; m_transitionLabelNumberArray[i].Visible = false; } }
private void NumTrialsButton_Click(object sender, EventArgs e) { CMatrix m; string sz; Form1Input dlg = new Form1Input("Set Number Number Of Trials Per Transition Period", ""+m_numTrials); dlg.ShowDialog(this); this.BringToFront(); if(dlg.result == RESLT.OK && dlg.modified == true) { m_numTrials = CStringUtil.SzToIntOrMin1(dlg.dataString); NumTrialsButton.Text = "" + m_numTrials; m = new CMatrix(); sz = CStringUtil.SzForceIntoMatrixDoubleFormat(MatrixTextBox.Text); m.a = CStringUtil.SzMatrixToDouble2DArray(MatrixTextBox.Text); RunTransitionOverTimeTest(CUtil.CopyMatrix(m)); } }
private void RefreshButton_Click(object sender, EventArgs e) { int numAdditionalColumns; CMatrix m = new CMatrix(); string sz = CStringUtil.SzForceIntoMatrixDoubleFormat(MatrixTextBox.Text); if(m_displayType == MBSDEFAULTS.BITMAPDISPLAYTYPE.INITIAL_BEHAVIOR) numAdditionalColumns = 3; else numAdditionalColumns = 5; m.a = CStringUtil.SzMatrixToDouble2DArray(MatrixTextBox.Text); while(m.ColumnCount > m_numBehaviorsDefined + numAdditionalColumns) m.DeleteColumn(m.ColumnCount-1); while(m.ColumnCount < m_numBehaviorsDefined + numAdditionalColumns) m.AddColumn(); MatrixTextBox.Text = m.ConvertToStringB(); DoneButton.Enabled = true; NumTrialsButton.Enabled = true; RefreshButton.Enabled = false; if(true == (m_szFormatOK = UpdateModel())) RunTransitionOverTimeTest(CUtil.CopyMatrix(m)); }
public CMatrix GetCopy() { int i, j; CMatrix cpy = new CMatrix(); cpy.m_a = new double[m_a.Length][]; for(i=0; i<RowCount; i++) cpy.m_a[i] = new double[ColumnCount]; for(i=0; i<RowCount; i++) { for(j=0; j<ColumnCount; j++) cpy.m_a[i][j] = m_a[i][j]; } return cpy; }
public void DeleteRow(int Index) { // Fix: 02/10/09: m_a.Length to m_a[i].Length in inner for loop. int i, j, row; CMatrix cpy = new CMatrix(); if(Index < 0 || Index >= RowCount) return; m_lastColumnCount = ColumnCount; if(RowCount == 1) { m_a = null; return; } // Create the matrix cpy.m_a = new double[m_a.Length-1][]; for(i=0; i<m_a.Length-1; i++) cpy.m_a[i] = new double[m_a[i].Length]; // Set the matrix for(i=0, row = 0; i<m_a.Length; i++) { if(i != Index) { for(j=0; j<m_a[i].Length; j++) // here was the fix { cpy.m_a[row][j] = m_a[i][j]; } row++; } } m_a = cpy.m_a; }
private void RefreshButton_Click(object sender, EventArgs e) { CVector v = new CVector(); CMatrix m = new CMatrix(); int ccnt; string szTemp; szTemp = CStringUtil.SzForceSquareMatrixFormatDouble(BiasTextBox.Text); m.a = CStringUtil.SzMatrixToDouble2DArray(szTemp); BiasTextBox.Text = m.ConvertToStringA(); UdateBiasMatrixModeling(); // Make matrix m into a square matix m.a = CStringUtil.SzMatrixToDouble2DArray(BiasTextBox.Text); // Determin minimum nuber of columns ccnt = m.ColumnCount; if(ccnt < m.RowCount) ccnt = m.RowCount; v.a = CStringUtil.SzVectorToDoubleArray(ProbTurnVectorTextBox.Text); if(m_r.type == DIRECTIONMODELTYPE.VECTOR_DIRBIAS && v.columnCount > ccnt) ccnt = v.columnCount; while(m.RowCount > ccnt) m.DeleteRow(m.RowCount-1); while(m.RowCount < ccnt) m.AddRow(); while(m.ColumnCount > ccnt) m.DeleteColumn(m.ColumnCount-1); while(m.ColumnCount < ccnt) m.AddColumn(); BiasTextBox.Text = m.ConvertToStringA(); UdateBiasMatrixModeling(); while(v.columnCount > ccnt) v.DeleteColumn(v.columnCount-1); while(v.columnCount < ccnt) v.AddColumn(); ProbTurnVectorTextBox.Text = v.ConvertToString(); UpdateProbTurnVectorModeling(); RefreshButton.Enabled = false; OkButton.Enabled = true; }