public FullFactorialDOEStudy(string name, string description, WorkflowComponent workflow, List <Data> factors, List <decimal> startingValues, List <decimal> stepSizes, List <int> noOfLevels, List <Data> responses)
            : base(name, description, workflow, factors, responses)
        {
            base.StudiedComponent = workflow;

            this.startingValues = startingValues;
            this.stepSizes      = stepSizes;
            this.noOfLevels     = noOfLevels;



            ColumnNames.Add("ID");
            ColumnTypes.Add(DataTypes.INTEGER);
            ColumnFormats.Add(0);
            ColumnUnits.Add("");

            for (int i = 0; i < factors.Count; i++)
            {
                string columnHeader = factors[i].Name;
                ColumnNames.Add(columnHeader);
                if (factors[i] is IntegerData)
                {
                    ColumnTypes.Add(DataTypes.INTEGER);
                    ColumnFormats.Add(0);
                    ColumnUnits.Add(((IntegerData)factors[i]).Unit);
                }
                else if (factors[i] is DoubleData)
                {
                    ColumnTypes.Add(DataTypes.DOUBLE);
                    ColumnFormats.Add(((DoubleData)factors[i]).DecimalPlaces);
                    ColumnUnits.Add(((DoubleData)factors[i]).Unit);
                }
            }
            for (int i = 0; i < responses.Count; i++)
            {
                string columnHeader = responses[i].Name;
                ColumnNames.Add(columnHeader);
                if (responses[i] is IntegerData)
                {
                    ColumnTypes.Add(DataTypes.INTEGER);
                    ColumnFormats.Add(0);
                    ColumnUnits.Add(((IntegerData)responses[i]).Unit);
                }
                else if (responses[i] is DoubleData)
                {
                    ColumnTypes.Add(DataTypes.DOUBLE);
                    ColumnFormats.Add(((DoubleData)responses[i]).DecimalPlaces);
                    ColumnUnits.Add(((DoubleData)responses[i]).Unit);
                }
            }



            TableNames.Add(Name);



            Treatment = new FullFactorial("testFF", "", Project.ProjectPath + "\\DOE.sdf", workflow as Workflow, factors, startingValues, stepSizes, noOfLevels, responses);
            Treatment.CreateFolder();
        }
        public DetOptStudy(string name, string description, string parentName = "")
            : base(name, null, null, description, parentName)
        {
            // Create SQL statements to create tables, sqlStatement1 for OptimAllResults and sqlStatement2 for OptimGenResults
            sqlStatement1  = "create table OptimAllResults (";
            sqlStatement2  = "create table OptimGenResults (";
            sqlStatement1 += "ID int, ";
            sqlStatement2 += "ID int, Category int, ";

            #region Atif
            // Prepare results database
            foreach (var designVariable in OptimisationTemplate.DesignVariables)
            {
                string columnHeader = designVariable.Name;
                ColumnNames.Add(columnHeader);
                sqlStatement1 += columnHeader + " ";
                sqlStatement2 += columnHeader + " ";
                if (designVariable.Data is IntegerData)
                {
                    ColumnTypes.Add(DataTypes.INTEGER);
                    ColumnFormats.Add(0);
                    sqlStatement1 += "int, ";
                    sqlStatement2 += "int, ";
                }
                else if (designVariable.Data is DoubleData)
                {
                    ColumnTypes.Add(DataTypes.DOUBLE);
                    ColumnFormats.Add(((DoubleData)(designVariable.Data)).DecimalPlaces);
                    sqlStatement1 += "float, ";
                    sqlStatement2 += "float, ";
                }
                ColumnUnits.Add(designVariable.Data.Unit);
                MinValues.Add(designVariable.LowerBound);
                MaxValues.Add(designVariable.UpperBound);
            }
            foreach (Objective objective in OptimisationTemplate.Objectives)
            {
                string columnHeader = objective.Name;
                ColumnNames.Add(columnHeader);
                sqlStatement1 += columnHeader + " ";
                sqlStatement2 += columnHeader + " ";
                if (objective.Data is IntegerData)
                {
                    ColumnTypes.Add(DataTypes.INTEGER);
                    ColumnFormats.Add(0);
                    sqlStatement1 += "int, ";
                    sqlStatement2 += "int, ";
                }
                else if (objective.Data is DoubleData)
                {
                    ColumnTypes.Add(DataTypes.DOUBLE);
                    ColumnFormats.Add(((DoubleData)(objective.Data)).DecimalPlaces);
                    sqlStatement1 += "float, ";
                    sqlStatement2 += "float, ";
                }
                ColumnUnits.Add(objective.Data.Unit);
                MinValues.Add(Double.NaN);
                MaxValues.Add(Double.NaN);
            }
            foreach (Aircadia.ObjectModel.Treatments.Optimisers.Formulation.Constraint constraint in OptimisationTemplate.Constraints)
            {
                string columnHeader = constraint.Name;
                ColumnNames.Add(columnHeader);
                sqlStatement1 += columnHeader + " ";
                sqlStatement2 += columnHeader + " ";
                if (constraint.Data is IntegerData)
                {
                    ColumnTypes.Add(DataTypes.INTEGER);
                    ColumnFormats.Add(0);
                    sqlStatement1 += "int, ";
                    sqlStatement2 += "int, ";
                }
                else if (constraint.Data is DoubleData)
                {
                    ColumnTypes.Add(DataTypes.DOUBLE);
                    ColumnFormats.Add(((DoubleData)(constraint.Data)).DecimalPlaces);
                    sqlStatement1 += "float, ";
                    sqlStatement2 += "float, ";
                }
                ColumnUnits.Add(constraint.Data.Unit);
                MinValues.Add(Double.NaN);
                MaxValues.Add(Double.NaN);
            }

            TableNames.Add("OptimAllResults");
            TableNames.Add("OptimGenResults");

            if (OptimisationTemplate.DesignVariables.Count() + OptimisationTemplate.Objectives.Count() + OptimisationTemplate.Constraints.Count() > 0)
            {
                sqlStatement1 = sqlStatement1.Remove(sqlStatement1.Length - 2);
                sqlStatement2 = sqlStatement2.Remove(sqlStatement2.Length - 2);
            }
            sqlStatement1 += ")";
            sqlStatement2 += ")";


            #endregion Atif
        }
Beispiel #3
0
        public RobustOptimisationStudy(string name, Treatment treatment, ExecutableComponent ec, OptimisationTemplate template, string parentName = "")
            : base(name, null, null, name, parentName)
        {
            Treatment        = treatment;
            StudiedComponent = ec;


            var DesignVariables = template.DesignVariables.Select(v => new RobOptDesignVariable {
                Name = v.Name
            }).ToList();
            var Objectives = template.Objectives.Select(o => new RobOptObjective {
                Name = o.Name, Type = o.Type
            }).ToList();
            var Constraints = template.Constraints.Select(c => new RobOptConstraint {
                Name = c.Name, Type = c.Type, Value = c.Value
            }).ToList();

            robOptTemplate = new RobOptTemplate()
            {
                DesignVariables = DesignVariables, Objectives = Objectives, Constraints = Constraints
            };


            ColumnNames.Add("ID");
            ColumnTypes.Add(DataTypes.INTEGER);
            ColumnFormats.Add(0);
            ColumnUnits.Add("");

            for (int i = 0; i < robOptTemplate.DesignVariables.Count(); i++)
            {
                string columnHeader = robOptTemplate.DesignVariables[i].Name;
                ColumnNames.Add(columnHeader);
                ColumnTypes.Add(DataTypes.DOUBLE);
                ColumnFormats.Add(4);
                ColumnUnits.Add("");
            }
            for (int i = 0; i < robOptTemplate.Objectives.Count(); i++)
            {
                string columnHeader = robOptTemplate.Objectives[i].Name;

                // Loss Function
                ColumnNames.Add(columnHeader + "LF");
                ColumnTypes.Add(DataTypes.DOUBLE);
                ColumnFormats.Add(4);
                ColumnUnits.Add("");
                // Mean
                ColumnNames.Add(columnHeader + "mean");
                ColumnTypes.Add(DataTypes.DOUBLE);
                ColumnFormats.Add(4);
                ColumnUnits.Add("");
                // Variance
                ColumnNames.Add(columnHeader + "var");
                ColumnTypes.Add(DataTypes.DOUBLE);
                ColumnFormats.Add(4);
                ColumnUnits.Add("");
            }
            for (int i = 0; i < robOptTemplate.Constraints.Count(); i++)
            {
                string columnHeader = robOptTemplate.Constraints[i].Name;

                // Loss Function
                ColumnNames.Add(columnHeader + "LF");
                ColumnTypes.Add(DataTypes.DOUBLE);
                ColumnFormats.Add(4);
                ColumnUnits.Add("");
                // Mean
                ColumnNames.Add(columnHeader + "mean");
                ColumnTypes.Add(DataTypes.DOUBLE);
                ColumnFormats.Add(4);
                ColumnUnits.Add("");
                // Variance
                ColumnNames.Add(columnHeader + "var");
                ColumnTypes.Add(DataTypes.DOUBLE);
                ColumnFormats.Add(4);
                ColumnUnits.Add("");
            }


            TableNames.Add("RobOptimAllResults");
            TableNames.Add("RobOptimGenResults");
            Template = template;
        }
Beispiel #4
0
        //public DOEplusURQStudy(string name, string description, Model worflow, List<Data> factors, List<Data> responses)
        public DOEplusURQStudy(string name, string description, List <string> names, Treatment treatment, FullFactorial fullFactorialDOE, WorkflowComponent worflow)
            : base(name, description)
        {
            TreatmentURQ     = treatment;
            this.names       = names; //DOE factors
            Treatment        = treatment;
            StudiedComponent = worflow;

            FullFactorialDOE = fullFactorialDOE;



            var DesignVariables = new List <RobOptDesignVariable>();

            for (int i = 0; i < ((string[, ])(Treatment.input_options.setuplist[0])).GetLength(0); i++)
            {
                var designVariable = new RobOptDesignVariable
                {
                    Name = ((string[, ])(Treatment.input_options.setuplist[0]))[i, 0]
                };
                //designVariable.LowerBound = ;
                //designVariable.UpperBound = ;
                DesignVariables.Add(designVariable);
            }
            var Objectives = new List <RobOptObjective>();

            for (int i = 0; i < ((string[, ])(Treatment.input_options.setuplist[1])).GetLength(0); i++)
            {
                var objective = new RobOptObjective
                {
                    Name = ((string[, ])(Treatment.input_options.setuplist[1]))[i, 0]
                };
                if (((string[, ])(Treatment.input_options.setuplist[1]))[i, 2] == "minimise")
                {
                    objective.Type = ObjectiveType.Minimise;
                }
                else if (((string[, ])(Treatment.input_options.setuplist[1]))[i, 2] == "maximise")
                {
                    objective.Type = ObjectiveType.Maximise;
                }
                Objectives.Add(objective);
            }
            var Constraints = new List <RobOptConstraint>();

            for (int i = 0; i < ((string[, ])(Treatment.input_options.setuplist[2])).GetLength(0); i++)
            {
                var constraint = new RobOptConstraint
                {
                    Name = ((string[, ])(Treatment.input_options.setuplist[2]))[i, 0]
                };
                if (((string[, ])(Treatment.input_options.setuplist[2]))[i, 2] == "<=")
                {
                    constraint.Type = ConstraintType.LessThanOrEqual;
                }
                else if (((string[, ])(Treatment.input_options.setuplist[2]))[i, 2] == ">=")
                {
                    constraint.Type = ConstraintType.GreatorThanOrEqual;
                }
                constraint.Value = Convert.ToDouble(((string[, ])(Treatment.input_options.setuplist[2]))[i, 3]);
                Constraints.Add(constraint);
            }
            robOptTemplate = new RobOptTemplate()
            {
                DesignVariables = DesignVariables, Objectives = Objectives, Constraints = Constraints
            };



            ColumnNames.Add("ID");
            ColumnTypes.Add(DataTypes.INTEGER);
            ColumnFormats.Add(0);
            ColumnUnits.Add("");

            for (int i = 0; i < this.names.Count; i++)
            {
                string columnHeader = this.names[i];
                ColumnNames.Add(columnHeader);
                ColumnTypes.Add(DataTypes.DOUBLE);
                ColumnFormats.Add(4);
                ColumnUnits.Add("");
            }


            for (int i = 0; i < robOptTemplate.DesignVariables.Count(); i++)
            {
                if (!this.names.Contains(robOptTemplate.DesignVariables[i].Name))
                {
                    string columnHeader = robOptTemplate.DesignVariables[i].Name;
                    ColumnNames.Add(columnHeader);
                    ColumnTypes.Add(DataTypes.DOUBLE);
                    ColumnFormats.Add(4);
                    ColumnUnits.Add("");
                }
            }
            for (int i = 0; i < robOptTemplate.Objectives.Count(); i++)
            {
                string columnHeader = robOptTemplate.Objectives[i].Name;

                // Loss Function
                ColumnNames.Add(columnHeader + "LF");
                ColumnTypes.Add(DataTypes.DOUBLE);
                ColumnFormats.Add(4);
                ColumnUnits.Add("");
                // Mean
                ColumnNames.Add(columnHeader + "mean");
                ColumnTypes.Add(DataTypes.DOUBLE);
                ColumnFormats.Add(4);
                ColumnUnits.Add("");
                // Variance
                ColumnNames.Add(columnHeader + "var");
                ColumnTypes.Add(DataTypes.DOUBLE);
                ColumnFormats.Add(4);
                ColumnUnits.Add("");
            }
            for (int i = 0; i < robOptTemplate.Constraints.Count(); i++)
            {
                string columnHeader = robOptTemplate.Constraints[i].Name;

                // Loss Function
                ColumnNames.Add(columnHeader + "LF");
                ColumnTypes.Add(DataTypes.DOUBLE);
                ColumnFormats.Add(4);
                ColumnUnits.Add("");
                // Mean
                ColumnNames.Add(columnHeader + "mean");
                ColumnTypes.Add(DataTypes.DOUBLE);
                ColumnFormats.Add(4);
                ColumnUnits.Add("");
                // Variance
                ColumnNames.Add(columnHeader + "var");
                ColumnTypes.Add(DataTypes.DOUBLE);
                ColumnFormats.Add(4);
                ColumnUnits.Add("");
            }



            TableNames.Add("DOE");
        }