Ejemplo n.º 1
0
        private void AddConstraint_Click(object sender, RoutedEventArgs e)
        {
            var constraintInput = new ConstraintInput();

            constraintInput.ToDelete += (s, _) => constraintsPanel.Children.Remove(s as ConstraintInput);
            constraintsPanel.Children.Add(constraintInput);
        }
Ejemplo n.º 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());
        }