Package Overview
Note: You must have a license for OPNET Development Kit to use the Optimization package.
The Optimization package uses an optimization technique called simulated annealing in an effort to find a globally-optimal solution over a given solution space. Optimality is defined in terms of a client-specified objective function that operates on different possible solutions.
The optimization engine requires the client to maintain a solution state that can support mutations and other necessary functions defined below. This solution state should describe a current solution from which new candidate solutions can be generated and stored by the engine. Additionally, the engine stores a problem state, which is typically not mutated from iteration to iteration, but can be used in the mutation function to generate a new solution state.
The engine iterates over different candidate solutions through the use of a mutation function. An iteration of the engine mutates the current solution to create a new candidate solution, and then evaluates the candidate solution according to the objective function. Should the new objective value fall within the threshold of acceptable objective value differences from the current objective value, the newly mutated candidate solution is selected to be the current solution. This procedure continues until a client-specified number of consecutive mutations do not have low enough objective values to be selected.
The engine also maintains a “best so far” copy of the solution state that has had the best objective value throughout the entire run of the engine. Periodically (according to client specification), the “best so far” copy replaces the current solution and is used as the basis for future mutations. The “best so far” copy is only a copy of the solution state, and not of the problem state.
Architecture
The optimization engine stores two client-provided “states”: The problem state (which typically does not change from iteration to iteration) and the current solution state (which may change as different solutions are selected). To maintain an abstraction layer, the optimization engine has no knowledge of the data types of either of these states. The client, however, must be aware of how these states are declared to properly define the callbacks required by the engine.
Internally, the problem state is stored as a void* in an OptimT_Siman_Handle (handle) and named the problem_state_ptr (psptr). The psptr can be obtained from a handle using Optim_Siman_Problem_State_Get(). The solution state is stored as a void*, and named the solution_state_ptr (ssptr). The ssptr is a structure that holds the state of the current optimization solution and can be obtained from a handle using Optim_Siman_Current_Solution_State_Get().
While the optimization engine treats the ssptr and psptr as black-box objects, it does need to support the following operations as functions of the handle, ssptr, or psptr:
- Calculate objective value of solution state when given a solution state and the problem state
- Create a new mutated solution state from the current solution when given an optimization handle
- Create a copy of a given solution state
- Free the memory used by a given solution state
- Accept a notification when a candidate solution is selected as the current solution for a given optimization handle
- Accept an update after a given optimization handle has performed a client-specified number of iterations
- Accept an update after a given optimization handle has completed a temperature step
- Accept a notification when the engine for a given optimization handle has finished
- Free the memory used by a given problem state
Typical Workflow and Usage
The typical workflow necessary to use the Optim_Siman package properly is as follows:
-
Define a data structure to represent the state of the problem to solve.
-
Define a data structure to represent the state of any possible solution to the problem.
-
Define the nine necessary callbacks described in the Callbacks section above.
-
Write code that calls the Optim_Siman package procedures according to the following typical usage pattern:
a) Create a handle to an instance of the optimization engine by calling Optim_Siman_Solver_Create() with an initialized problem state, an initial solution state, the nine required callbacks, and any appropriate additional configuration options.
b) Set any desired optional configurations of the engine by using one or more of the following functions:
- Optim_Siman_Initial_Mutation_Attempts_Set()
- Optim_Siman_Initial_Mutations_Set()
- Optim_Siman_Initial_Temperature_Range_Fraction_Set()
- Optim_Siman_Nonblocking_Set()
- Optim_Siman_Maximize_Objective_Value()
- Optim_Siman_Minimize_Objective_Value()
- Optim_Siman_Restart_Threshold_Set()
c) Begin execution of the engine by calling Optim_Siman_Solver_Execute() on the previously created optimization handle.
d) During execution of the engine (if running in Non-blocking mode), possibly call Optim_Siman_Pause(), Optim_Siman_Continue(), or Optim_Siman_Stop() to respectively pause, continue, or altogether stop the optimization process, as desired.
e) Inside one of the callbacks or while the engine is not running (either due to a call to Optim_Siman_Pause() or because it has completed execution on its own), possibly call Optim_Siman_Current_Solution_State_Get(), Optim_Siman_Problem_State_Get(), or Optim_Siman_Current_Objective_Value_Get() on the optimization handle to determine information about the optimization’s status.
f) When the engine has completed its execution (either due to a call to Optim_Siman_Stop() or because it has completed its execution on its own), call Optim_Solver_Destroy() to free the memory used by the optimization handle and all of the associated state (including the problem and solution state).