private void button_ROP_objective_set_Click(object sender, EventArgs e)
        {
            // Validity check of data:
            double MissingData = 0;

            if (textBox_ROP_objective_Prb.Text == "")
            {
                MessageBox.Show("Please enter desired satisfaction probability value");
                MissingData = 1;
            }

            if (MissingData == 0)
            {
                //Formulation Option 1:
                if (radioButton_ROP_FormulationOption1.Checked == true)
                {
                    UncertaintyObjectiveData    = new string[7];
                    UncertaintyObjectiveData[0] = dataObj.Name;
                    UncertaintyObjectiveData[1] = Convert.ToString(0);//Coefficient k
                    if (comboBox_ROP_objective_minmax_FormulationOption1.Text == "To be minimised")
                    {
                        UncertaintyObjectiveData[2] = "minimise";
                    }
                    else if (comboBox_ROP_objective_minmax_FormulationOption1.Text == "To be maximised")
                    {
                        UncertaintyObjectiveData[2] = "maximise";
                    }
                    UncertaintyObjectiveData[3] = "0";        //Requested probability - NA
                    UncertaintyObjectiveData[4] = "None";     //Distributional assumption - NA
                    UncertaintyObjectiveData[5] = "quantile"; //Metric - NA

                    if (comboBox_ROP_objective_minmax_FormulationOption1.SelectedItem as string == "To be minimised")
                    {
                        var des_set = new OP_Input_set("min", 1.0, "max", 0.0, "desobj", "obj", "Data", dataObj.Name, "k_coeff", UncertaintyObjectiveData[1], "LossFuncSign", UncertaintyObjectiveData[6], "Probability", UncertaintyObjectiveData[3], "Distribution", UncertaintyObjectiveData[4], "Metric", UncertaintyObjectiveData[5]);
                        options = des_set;
                    }
                    else
                    {
                        var des_set = new OP_Input_set("min", 1.0, "max", 0.0, "desobj", "obj", "Data", dataObj.Name, "k_coeff", UncertaintyObjectiveData[1], "LossFuncSign", UncertaintyObjectiveData[6], "Probability", UncertaintyObjectiveData[3], "Distribution", UncertaintyObjectiveData[4], "Metric", UncertaintyObjectiveData[5]);
                        options = des_set;
                    }
                }
                //Formulation Option 2:
                else if (radioButton_ROP_FormulationOption2.Checked == true)
                {
                    UncertaintyObjectiveData    = new string[7];
                    UncertaintyObjectiveData[0] = dataObj.Name;
                    UncertaintyObjectiveData[1] = textBox_ROP_FormulationOption2K.Text;//Coefficient k
                    if (comboBox_ROP_objective_minmax_FormulationOption2.Text == "To be minimised")
                    {
                        UncertaintyObjectiveData[2] = "minimise";
                    }
                    else if (comboBox_ROP_objective_minmax_FormulationOption2.Text == "To be maximised")
                    {
                        UncertaintyObjectiveData[2] = "maximise";
                    }
                    UncertaintyObjectiveData[3] = "0";                                      //Requested probability - NA
                    UncertaintyObjectiveData[4] = "None";                                   //Distributional assumption - NA
                    UncertaintyObjectiveData[5] = "quantile";                               //Metric - NA
                    UncertaintyObjectiveData[6] = comboBox_ROP_FormulationOption2Sign.Text; //Sign in Loss Function

                    if (comboBox_ROP_objective_minmax_FormulationOption2.SelectedItem as string == "To be minimised")
                    {
                        var des_set = new OP_Input_set("min", 1.0, "max", 0.0, "desobj", "obj", "Data", dataObj.Name, "k_coeff", UncertaintyObjectiveData[1], "LossFuncSign", UncertaintyObjectiveData[6], "Probability", UncertaintyObjectiveData[3], "Distribution", UncertaintyObjectiveData[4], "Metric", UncertaintyObjectiveData[5]);
                        options = des_set;
                    }
                    else
                    {
                        var des_set = new OP_Input_set("min", 0.0, "max", 1.0, "desobj", "obj", "Data", dataObj.Name, "k_coeff", UncertaintyObjectiveData[1], "LossFuncSign", UncertaintyObjectiveData[6], "Probability", UncertaintyObjectiveData[3], "Distribution", UncertaintyObjectiveData[4], "Metric", UncertaintyObjectiveData[5]);
                        options = des_set;
                    }
                }
                //Formulation Option 3:
                else if (radioButton_ROP_FormulationOption3.Checked == true)
                {
                    // Computing the coefficient k:
                    double coefficient_k = k_calculation(Convert.ToDouble(textBox_ROP_objective_Prb.Text), comboBox_ROP_objective_DstrbnAssmptn.Text);
                    // Storing variable information:
                    UncertaintyObjectiveData    = new string[7];
                    UncertaintyObjectiveData[0] = dataObj.Name;
                    UncertaintyObjectiveData[1] = Convert.ToString(coefficient_k);
                    if (comboBox_ROP_objective_minmax_FormulationOption3.Text == "To be minimised")
                    {
                        UncertaintyObjectiveData[2] = "minimise";
                    }
                    else if (comboBox_ROP_objective_minmax_FormulationOption3.Text == "To be maximised")
                    {
                        UncertaintyObjectiveData[2] = "maximise";
                    }
                    UncertaintyObjectiveData[3] = textBox_ROP_objective_Prb.Text;            //Requested probability
                    UncertaintyObjectiveData[4] = comboBox_ROP_objective_DstrbnAssmptn.Text; //Distributional assumption
                    UncertaintyObjectiveData[5] = comboBox_ROP_objective_Metric.Text;        //Metric
                    UncertaintyObjectiveData[6] = comboBox_ROP_FormulationOption3Sign.Text;  //Sign in Loss Function

                    if (comboBox_ROP_objective_minmax_FormulationOption3.SelectedItem as string == "To be minimised")
                    {
                        var des_set = new OP_Input_set("min", 1.0, "max", 0.0, "desobj", "obj", "Data", dataObj.Name, "k_coeff", UncertaintyObjectiveData[1], "LossFuncSign", UncertaintyObjectiveData[6], "Probability", UncertaintyObjectiveData[3], "Distribution", UncertaintyObjectiveData[4], "Metric", UncertaintyObjectiveData[5]);
                        options = des_set;
                    }
                    else
                    {
                        var des_set = new OP_Input_set("min", 0.0, "max", 1.0, "desobj", "obj", "Data", dataObj.Name, "k_coeff", UncertaintyObjectiveData[1], "LossFuncSign", UncertaintyObjectiveData[6], "Probability", UncertaintyObjectiveData[3], "Distribution", UncertaintyObjectiveData[4], "Metric", UncertaintyObjectiveData[5]);
                        options = des_set;
                    }
                }
            }


            Close();
        }
        private void button_ROP_VarSetup_Set_Click(object sender, EventArgs e)
        {
            // Validity check of data:
            double MissingData = 0;

            if (textBox_ROP_VarSetup_Prb.Text == "")
            {
                MessageBox.Show("Please enter satisfaction probability");
                MissingData = 1;
            }
            else if (textBox_ROP_VarSetup_MinVal.Text == "")
            {
                MessageBox.Show("Please enter lower bound");
                MissingData = 1;
            }
            else if (textBox_ROP_VarSetup_MaxVal.Text == "")
            {
                MessageBox.Show("Please enter upper bound");
                MissingData = 1;
            }
            else if (textBox_ROP_VarSetup_PDFparameter1.Text == "")
            {
                if (comboBox_ROP_VarSetup_PDF.Text != "Normal")
                {
                    MessageBox.Show("Please enter first PDF parameter");
                    MissingData = 1;
                }
            }
            else if (textBox_ROP_VarSetup_PDFparameter2.Text == "")
            {
                MessageBox.Show("Please enter second PDF parameter");
                MissingData = 1;
            }
            else if (textBox_ROP_VarSetup_PDFparameter3.Text == "")
            {
                if (comboBox_ROP_VarSetup_PDF.Text == "User defined")
                {
                    MessageBox.Show("Please enter the third PDF parameter");
                    MissingData = 1;
                }
            }

            if (MissingData == 0)
            {
                if (comboBox_ROP_VarSetup_PDF.Text == "Normal")
                {
                    textBox_ROP_VarSetup_PDFparameter1.Text = "";

                    // Computing the central moments according to the chosen PDF:
                    double IICM  = Math.Pow(Convert.ToDouble(textBox_ROP_VarSetup_PDFparameter2.Text), 2); //The variance, not the standard deviation!!!!
                    double IIICM = 0;
                    double IVCM  = 3;
                    // Computing the coefficient k:
                    double x_k = X_k_approximation_Normal_PDF(Convert.ToDouble(textBox_ROP_VarSetup_Prb.Text));
                    // Defining the robust lower variable bound:
                    double ROB_LB = Convert.ToDouble(textBox_ROP_VarSetup_MinVal.Text) + Math.Sqrt(IICM) * x_k;
                    // Defining the robust lower variable bound:
                    double ROB_UB = Convert.ToDouble(textBox_ROP_VarSetup_MaxVal.Text) - Math.Sqrt(IICM) * x_k;
                    // Storing variable information:
                    UncertaintyVariableData    = new string[8];
                    UncertaintyVariableData[0] = dataObj.Name;
                    UncertaintyVariableData[1] = Convert.ToString(IICM);
                    UncertaintyVariableData[2] = Convert.ToString(IIICM);
                    UncertaintyVariableData[3] = Convert.ToString(IVCM);
                    //UncertaintyVariableData[4] = textBox_ROP_VarSetup_StartVal.Text;
                    UncertaintyVariableData[5] = Convert.ToString(ROB_LB);
                    UncertaintyVariableData[6] = Convert.ToString(ROB_UB);
                    UncertaintyVariableData[7] = textBox_ROP_VarSetup_Prb.Text;

                    if (ROB_LB >= ROB_UB)
                    {
                        MessageBox.Show("Lower bound larger than upper bound. Please revise the provided information.");
                    }
                    else
                    {
                        var des_set = new OP_Input_set("min", ROB_LB, "max", ROB_UB, "desobj", "des", "Data", dataObj.Name, "Probability", Convert.ToDouble(textBox_ROP_VarSetup_Prb.Text), "Distribution", comboBox_ROP_VarSetup_PDF.Text, "IICM", IICM);
                        options = des_set;
                        Close();
                    }
                }
                if (comboBox_ROP_VarSetup_PDF.Text == "Triangular")
                {
                    // Getting the parameter values provided by the user:
                    double d1 = Convert.ToDouble(textBox_ROP_VarSetup_PDFparameter1.Text);
                    double d2 = Convert.ToDouble(textBox_ROP_VarSetup_PDFparameter2.Text);
                    double d3 = d1 - d2;

                    // Computing the central moments:
                    double IICM  = ((d1 + d2) * (d1 + d2) * (1 - (d1 + d3) * (d2 - d3) / ((d1 + d2) * (d1 + d2)))) / 18;
                    double IIICM = Math.Sqrt(2) / 5 * (d2 - d1 - 2 * d3) * (-2 * d1 - d2 - d3) * (-d1 - 2 * d2 + d3) / Math.Pow(((d1 + d2) * (d1 + d2) * (1 - (d1 + d3) * (d2 - d3) / ((d1 + d2) * (d1 + d2)))), (3.0 / 2.0));
                    double IVCM  = 12.0 / 5;
                    double LB    = Convert.ToDouble(textBox_ROP_VarSetup_MinVal.Text); // Lower variable bound (deterministic)
                    double UB    = Convert.ToDouble(textBox_ROP_VarSetup_MaxVal.Text); // Upper variable bound (deterministic)

                    // Computing the robust variable bounds distance from the deterministic ones:
                    double Prb = Convert.ToDouble(textBox_ROP_VarSetup_Prb.Text);
                    Cursor.Current = Cursors.WaitCursor;
                    double x_k_minus = StandardTriangularPDF_inv(1 - Prb, d1, d2);
                    double x_k_plus  = StandardTriangularPDF_inv(Prb, d1, d2);
                    Cursor.Current = Cursors.Default;

                    // Defining the robust lower variable bound:
                    double ROB_LB = LB + (d1 - x_k_minus * (d1 + d2));
                    // Defining the robust upper variable bound:
                    double ROB_UB = UB - (x_k_plus * (d1 + d2) - d1);
                    // Storing variable information:
                    UncertaintyVariableData    = new string[8];
                    UncertaintyVariableData[0] = dataObj.Name;
                    UncertaintyVariableData[1] = Convert.ToString(IICM);
                    UncertaintyVariableData[2] = Convert.ToString(IIICM);
                    UncertaintyVariableData[3] = Convert.ToString(IVCM);
                    //UncertaintyVariableData[4] = textBox_ROP_VarSetup_StartVal.Text;
                    UncertaintyVariableData[5] = Convert.ToString(ROB_LB);
                    UncertaintyVariableData[6] = Convert.ToString(ROB_UB);
                    UncertaintyVariableData[7] = textBox_ROP_VarSetup_Prb.Text;

                    if (ROB_LB >= ROB_UB)
                    {
                        MessageBox.Show("Lower bound larger than upper bound. Please revise the provided information.");
                    }
                    else
                    {
                        var des_set = new OP_Input_set("min", ROB_LB, "max", ROB_UB, "desobj", "des", "Data", dataObj.Name, "Probability", Convert.ToDouble(textBox_ROP_VarSetup_Prb.Text), "Distribution", comboBox_ROP_VarSetup_PDF.Text, "Parameter1", d1, "Parameter2", d2);
                        options = des_set;
                        Close();
                    }
                }
                if (comboBox_ROP_VarSetup_PDF.Text == "Beta")
                {
                    //Temporary:
                    MessageBox.Show("Work in progress...");
                    return;

                    double A = Convert.ToDouble(textBox_ROP_VarSetup_PDFparameter1.Text);
                    double B = Convert.ToDouble(textBox_ROP_VarSetup_PDFparameter2.Text);
                    // Computing the central moments according to the chosen PDF:
                    double IICM  = (A + B) / (Math.Pow(A + B, 2) * (A + B + 1)); //Is it the variance or standard deviation? Check!!!
                    double IIICM = (2 * (B - A) * Math.Sqrt(A + B + 1)) / ((A + B + 2) * Math.Sqrt(A * B));
                    double IVCM  = 3 * (((Math.Pow(A, 2) * (B + 2) + 2 * Math.Pow(B, 2) + A * B * (B - 2)) * (A + B + 1)) / (A * B * (A + B + 2) * (A + B + 3)) - 1);
                    double LB    = Convert.ToDouble(textBox_ROP_VarSetup_MinVal.Text); // Lower variable bound (deterministic)
                    double UB    = Convert.ToDouble(textBox_ROP_VarSetup_MaxVal.Text); // Upper variable bound (deterministic)

                    // Computing the robust variable bounds distance from the deterministic ones:
                    double Prb = Convert.ToDouble(textBox_ROP_VarSetup_Prb.Text);
                    Cursor.Current = Cursors.WaitCursor;
                    double x_k_minus = BetaCDF_inv(1 - Prb, A, B);
                    double x_k_plus  = BetaCDF_inv(Prb, A, B);
                    Cursor.Current = Cursors.Default;

                    // Defining the robust lower variable bound:
                    double ROB_LB = LB + x_k_minus * (UB - LB);
                    // Defining the robust upper variable bound:
                    double ROB_UB = LB + x_k_plus * (UB - LB);
                    // Storing variable information:
                    UncertaintyVariableData    = new string[8];
                    UncertaintyVariableData[0] = dataObj.Name;
                    UncertaintyVariableData[1] = Convert.ToString(IICM);
                    UncertaintyVariableData[2] = Convert.ToString(IIICM);
                    UncertaintyVariableData[3] = Convert.ToString(IVCM);
                    //UncertaintyVariableData[4] = textBox_ROP_VarSetup_StartVal.Text;
                    UncertaintyVariableData[5] = Convert.ToString(ROB_LB);
                    UncertaintyVariableData[6] = Convert.ToString(ROB_UB);
                    UncertaintyVariableData[7] = textBox_ROP_VarSetup_Prb.Text;

                    if (ROB_LB >= ROB_UB)
                    {
                        MessageBox.Show("Lower bound larger than upper bound. Please revise the provided information.");
                    }
                    else
                    {
                        var des_set = new OP_Input_set("min", ROB_LB, "max", ROB_UB, "desobj", "des", "Data", dataObj.Name, "Probability", Convert.ToDouble(textBox_ROP_VarSetup_Prb.Text), "Distribution", comboBox_ROP_VarSetup_PDF.Text, "Parameter1", A, "Parameter2", B);
                        options = des_set;
                        Close();
                    }
                }
                if (comboBox_ROP_VarSetup_PDF.Text == "Gamma")
                {
                    MessageBox.Show("Work in progress...");
                    return;
                }
                if (comboBox_ROP_VarSetup_PDF.Text == "User defined")
                {
                    // Storing the central moments according to the chosen PDF:
                    double IICM  = Convert.ToDouble(textBox_ROP_VarSetup_PDFparameter1.Text);//The variance, not the standard deviation!!!!
                    double IIICM = Convert.ToDouble(textBox_ROP_VarSetup_PDFparameter2.Text);
                    double IVCM  = Convert.ToDouble(textBox_ROP_VarSetup_PDFparameter3.Text);

                    // Checking the second and fourth moments provided are positive:
                    if (IICM < 0)
                    {
                        MessageBox.Show("The second central moment has to be positive");
                    }
                    else if (IVCM < 0)
                    {
                        MessageBox.Show("The fourth central moment has to be positive");
                    }
                    else
                    {
                        // Computing the coefficient k:
                        double Prb          = Convert.ToDouble(textBox_ROP_VarSetup_Prb.Text);
                        string DistrAssumpt = comboBox_ROP_VarSetup_DstrbnAssmptn.Text;
                        double x_k          = K_calculation(Prb, DistrAssumpt);

                        // Defining the robust lower variable bound:
                        double ROB_LB = Convert.ToDouble(textBox_ROP_VarSetup_MinVal.Text) + Math.Sqrt(IICM) * x_k;
                        // Defining the robust lower variable bound:
                        double ROB_UB = Convert.ToDouble(textBox_ROP_VarSetup_MaxVal.Text) - Math.Sqrt(IICM) * x_k;

                        // Storing variable information:
                        UncertaintyVariableData    = new string[8];
                        UncertaintyVariableData[0] = dataObj.Name;
                        UncertaintyVariableData[1] = Convert.ToString(IICM);
                        UncertaintyVariableData[2] = Convert.ToString(IIICM);
                        UncertaintyVariableData[3] = Convert.ToString(IVCM);
                        //UncertaintyVariableData[4] = textBox_ROP_VarSetup_StartVal.Text;
                        UncertaintyVariableData[5] = Convert.ToString(ROB_LB);
                        UncertaintyVariableData[6] = Convert.ToString(ROB_UB);
                        UncertaintyVariableData[7] = textBox_ROP_VarSetup_Prb.Text;

                        if (ROB_LB >= ROB_UB)
                        {
                            MessageBox.Show("Lower bound larger than upper bound. Please revise the provided information.");
                        }
                        else
                        {
                            var des_set = new OP_Input_set("min", ROB_LB, "max", ROB_UB, "desobj", "des", "Data", dataObj.Name, "Probability", Convert.ToDouble(textBox_ROP_VarSetup_Prb.Text), "Distribution", comboBox_ROP_VarSetup_PDF.Text, "IICM", IICM, "IIICM", IIICM, "IVCM", IVCM);
                            options = des_set;
                            Close();
                        }
                    }
                }
            }
        }