Exemple #1
0
        /// <summary>
        ///     Creates a new objective function specified through a string.
        /// </summary>
        /// <param name="function">
        ///     A <see cref="Expression{TDelegate}" /> containing
        ///     the function in the form of a lambda expression.
        /// </param>
        public QuadraticObjectiveFunction(Expression <Func <double> > function)
        {
            var    terms = new Dictionary <Tuple <string, string>, double>();
            double scalar;

            QuadraticExpressionParser.ParseExpression(terms, function.Body, out scalar);

            initialize(terms);
        }
Exemple #2
0
        /// <summary>
        ///     Creates a new objective function specified through a string.
        /// </summary>
        /// <param name="function">
        ///     A <see cref="System.String" /> containing
        ///     the function in the form similar to "ax²+b".
        /// </param>
        /// <param name="culture">
        ///     The culture information specifying how
        ///     numbers written in the <paramref name="function" /> should
        ///     be parsed. Default is CultureInfo.InvariantCulture.
        /// </param>
        public QuadraticObjectiveFunction(string function, CultureInfo culture)
        {
            var terms = QuadraticExpressionParser.ParseString(function, culture);

            initialize(terms);
        }