# Defining an Objective Function

The goal of the optimization process is to find the parameter
values that result in a maximum or minimum of a function called the
objective function. *Objective function* is a
mathematical expression describing the relationship of the optimization
parameters or the result of an operation (such as simulation) that uses
the optimization parameters as inputs. The optimization objective is
the objective function plus optimization criterion. The latter
determines whether the goal of the optimization is to minimize or
maximize the value of the objective function.

To define the
objective function

- In the Projects
view,
click the optimization experiment.
- In the Properties
view, specify the objective function in the Objective edit box. You can enter any Java expression as an objective function. Since the
expression
is
considered to be in context of the top-level agent, it can
access variables and parameters of the top-level agent. The top-level
agent is accessible here as root. If your
algorithm is rather sophisticated, you can define a function in the
top-level agent (e.g. Main), and
place the function call in the Objective
edit box. Example: root.totalCost().
- Define the optimization criterion. Choose Minimize/Maximize option to
minimize/maximize your objective function.

The OptQuest Engine obtains a sample of the objective function
at the end of each simulation. The engine analyzes a sample, modifies
optimization parameters according to its optimization algorithm, and
starts a new simulation.
Therefore, optimization is an iterative process where:

- The OptQuest Engine calculates possible solutions for the
parameters
- The objective function and constraints are evaluated using
the suggested solutions
- The results are analyzed by the OptQuest Engine, and a new
set of possible solutions is calculated

#### Related topics