# 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.
The top level
agent is accessible here as root.
- Define the optimization criterion.

Choose Minimize/Maximize option to
minimize/maximize your objective function.

You can enter any Java expression as an objective function,
including an arithmetic expression or method call. 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. If your
function is rather sophisticated, you can define a method, calculating
the function, in the Additional
class code editing field in the
Advanced Java section of the top level agent, and
place the method call in the Objective
edit box. If you use a method, it is called only once after each
simulation rather than numerous times during a simulation. If an
objective function calculation is time-consuming, placing it in a
method is preferred.

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