Exemple #1
0
        private void AddParameter_Click(object sender, RoutedEventArgs e)
        {
            var parameterInput = new ParameterInput();

            parameterInput.ToDelete += (s, _) => parametersPanel.Children.Remove(s as ParameterInput);
            parametersPanel.Children.Add(parameterInput);
        }
Exemple #2
0
        private string convertWizardInput()
        {
            StringBuilder result = new StringBuilder();

            //result.AppendLine("$variables: " + variableCountBox.Value.Value.ToString() + ";");

            if (parametersPanel.Children.Count > 0)
            {
                result.AppendLine("$parameters:");
                foreach (var pp in parametersPanel.Children)
                {
                    ParameterInput parameterInput = (ParameterInput)pp;
                    if (parameterInput.ParameterValues.Count == 1)
                    {
                        result.AppendFormat("double {0} = {1};{2}", parameterInput.ParameterName, parameterInput.ParameterValues[0], Environment.NewLine);
                    }
                    else
                    {
                        result.AppendFormat("double[] {0} = new double[] {{ {1} }};{2}",
                                            parameterInput.ParameterName,
                                            string.Join(", ", parameterInput.ParameterValues),
                                            Environment.NewLine);
                    }
                }
            }

            result.AppendLine("$function:");
            result.AppendLine(costFunctionTextBox.Text + ";");

            if (constraintsPanel.Children.Count > 0)
            {
                result.AppendLine("$constraints:");
                foreach (var cp in constraintsPanel.Children)
                {
                    ConstraintInput constraintInput = (ConstraintInput)cp;
                    result.AppendFormat("{0} {1} {2};{3}", constraintInput.Lhs, constraintInput.Operator, constraintInput.Rhs, Environment.NewLine);
                }
            }

            return(result.ToString());
        }