Click or drag to resize

ContinuousOptimizationMaximizeTFunctionParameter Method (FuncDoubleMatrix, TFunctionParameter, Double, DoubleMatrix, TFunctionParameter)

Finds the maximum of the specified parametric objective function.

Namespace:  Novacta.Analytics
Assembly:  Novacta.Analytics (in Novacta.Analytics.dll) Version: 2.0.0
Syntax
public static DoubleMatrix Maximize<TFunctionParameter>(
	Func<DoubleMatrix, TFunctionParameter, double> objectiveFunction,
	DoubleMatrix initialArgument,
	TFunctionParameter functionParameter
)

Parameters

objectiveFunction
Type: SystemFuncDoubleMatrix, TFunctionParameter, Double
The objective function to be maximized.
initialArgument
Type: Novacta.AnalyticsDoubleMatrix
The argument at which the method starts the search for optimality.
functionParameter
Type: TFunctionParameter
The function parameter.

Type Parameters

TFunctionParameter
The type of the function parameter.

Return Value

Type: DoubleMatrix
The argument at which the function is maximized.
Exceptions
ExceptionCondition
ArgumentNullExceptionobjectiveFunction is null.
-or-
initialArgument is null.
ArgumentExceptioninitialArgument is not a row vector.
Remarks

It is assumed that the objectiveFunction will accept row vectors as valid representations of an argument. As a consequence, initialArgument is expected to be a row vector.

Examples

In the following example, function

LaTeX equation

is maximized.

The search for the maximizer starts from the initial argument LaTeX equation.

Maximizing a parametric function.
using System;

namespace Novacta.Analytics.CodeExamples
{
    public class ContinuousOptimizationExample1  
    {
        public void Main()
        {
            // Define the parametric objective function as follows: 
            // f(x, a) = exp(-(x-2)^2) + (a) * exp(-(x+2)^2)).
            static double objectiveFunction(DoubleMatrix x, double alpha)
            {
                double y = 0.0;
                var x_0 = x[0];
                y += Math.Exp(-Math.Pow(x_0 - 2.0, 2.0));
                y += alpha * Math.Exp(-Math.Pow(x_0 + 2.0, 2.0));

                return y;
            }

            // Define the argument at which the method starts 
            // the search for optimality.
            var initialArgument = DoubleMatrix.Dense(1, 1, -6.0);

            // Define the function parameter.
            double functionParameter = .8;

            // Maximize the objective function.
            var maximizer = ContinuousOptimization.Maximize(
                objectiveFunction: objectiveFunction,
                initialArgument: initialArgument,
                functionParameter: functionParameter);

            // Show the results.
            Console.WriteLine();
            Console.WriteLine("The maximizer of the objective function is:");
            Console.WriteLine(maximizer);

            Console.WriteLine();

            Console.WriteLine("The maximum value of the objective function is:");
            Console.WriteLine(objectiveFunction(maximizer, functionParameter));
        }
    }
}

// Executing method Main() produces the following output:
// 
// 
// The maximizer of the objective function is:
// 2.00000859       
// 
// 
// 
// The maximum value of the objective function is:
// 1.000000089948087

See Also