Difference between revisions of "Optimization"

From Heureka Wiki
Jump to navigation Jump to search
Line 21: Line 21:
 
====Adding a decision variable====
 
====Adding a decision variable====
  
*'''Note'''
 
:Values, in SEK/ha, can obviously be less than zero (negative) for stands and analysis areas in one or several periods. Make sure that this variable has a "RangeType" set to "All" (and not "Default" that only allows for positive values).
 
  
 
====Adding an accounting variable====
 
====Adding an accounting variable====
 +
Accounting variables are preferrably added to the optimization model to improve readability and simplify the writing of constratints. An accounting variable is a ''defined'' - it is function of other decision variable in the model. The definition is actually an equality constraint in the the optimization model.
 +
 +
One example of a useful accounting variable is total harvested volume in a period. This variable can then be used in other constraints.
 +
 +
To add an accounting variable:
 +
# In the Optimization Model window, right-click in the "Variables" section and Select "Add new variable"
 +
# Right-click on the variable and change its name from <code>"DefaultName..."</code> to something more proper.
 +
# To defined an indexed variable, for example to have one variable for each time period, click on Data binding > Sets, and add the index set, for example "periods". The variable name should now have a suffix <code>[p]</code>.
 +
# In the syntax window, type the definition. On the left-hand side, type the expression. On the right-hand side, type the name of the variable. The left and right hand sides should be separated with <code>"=="</code>.
 +
# Example: An ccounting variable for total stand volume is defined, with an index p for time period. Before addign the variable, the parameter <code>volume[i,j,p] which linked to the Heureka result variable Forest Data.Volume Before must have been added. Syntax:
 +
<code>FORALL <p> IN periods DO
 +
        SUM <i,j> IN treatmentunits * alternatives WITH altIncluded[i,j] >= 1:
 +
        volume[i,j,p] * area[i] * x[i,j] == volTot[p]; </code>
 +
#'''Important!''' By default, a variable (decision or accounting) has the property Range set to non-negative. If the accounting variable can be negative, which is the case for example for the total revenue in a time period if costs are larger that revenues, you must changed its Range type to 
 +
Values, in SEK/ha, can obviously be less than zero (negative) for stands and analysis areas in one or several periods. Make sure that this variable has a "RangeType" set to "All" (and not "Default" that only allows for positive values).
  
  

Revision as of 13:59, 20 January 2010


About the optimization tool

The in-built optimization tools is for formulating and solving LP and MIP problems. It is basically a graphical user interface to the ZIMPL optimization modelling language. For solving a problem, external third-party solvers are used and directly linked to the optimization tool. Currently, the solvers available are

  • LPSolve, which is freely available, and
  • ILOG CPLEX, which is a very efficient, state-of-the-art solver. However, it is commercial and requires that the user has a licence.

The linking to SCIP/Soplex is currently under development.

The optimization model is linked to a Heureka-formatted SQL Server database used for storing input data, simulation data, and result data. This enables a seamless integration with the input data required by the optimization model, as well as direct presentation of optimization results in the form of tables, graphs, and maps. This simplifies the analysis and visualization of scenarios or plans of forest development and outputs.

As an alternative to the integrated optimization tool, an AIMMS model has been developed, which may be more suitable for a OR researcher or the very advanced user who needs maximum flexibility or maximum optimization performance. This model is also linked to the same database, but is run as a separate application. It also requires an AIMMS licence.

Instructions

Settings

Applying a LP-optimization model in forest management planning, integer solutions are sometimes of interest. A stand is usually regarded as a treatment unit to be completely treated according to a certain treatment in a certain period. This might be of special interest when it comes to short term-planning, i.e. what to do now and in the next year - couple of years.

The most straightforward way to obtain integer solutions is to allow only integer values of the decision variable, i.e. constrain the range type of xi, j to "Binary". However, this might lead to infeasible solutions. Another way is to round off to closest integer value (0 or 1), hence forcing the results to be a set of complete treatment programmes for each stand in the analysis area. In menu "Optimization" > "Settings...":

  • The General-tab allows the user to, e.g., selecting "Round to integer solution". Do observe that this is done after solving the optimization problem. Any results shown in the output window will not be rounded off (except the decision variable, with its actual value within parentheses). Results derived from the result database will however be of integer solutions, if this was selected. Optimization results are saved to the database by pressing the "Save"-button in the optimization model builder-window. As an alternative to rounding off, the "Mip Gap" gives an opportunity to accept a solution not certainly optimal. A relative gap of 1% imply that the solution might be one percentage from the optimum. An absolute gap is defined in the same unit as the objective function. The "Time Limit" defines the time, in seconds, for the optimization model to search for a feasible solution.
    • Relative mip gap: Relative optimization tolerance. The optimization algorithm stops when an integer solution is quaranteed to be within this percentage of the true optimal solution.
    • Absolute mip gap: Absolute optimization tolerance (not available in Lp_Solve). The optimization algorithm stops when an integer solution is proven to be within this absolute difference of the optimal solution.
    • Time limit: The maximum time for the solving a problem. If the time limit has been passed but an optimal solutions has not been found, the best solution found is returned. For difficult problems it is possible that no feasible solution is found.
    • Round to integer: If check, decision variables are rounded to the nearest 0/1 integer value.
  • The SCIP/SoPlex Settings-tab: Here you select the SCIp/SoPlex binary file (.exe) that you must have on your disk, see Optimization.

Adding a decision variable

Adding an accounting variable

Accounting variables are preferrably added to the optimization model to improve readability and simplify the writing of constratints. An accounting variable is a defined - it is function of other decision variable in the model. The definition is actually an equality constraint in the the optimization model.

One example of a useful accounting variable is total harvested volume in a period. This variable can then be used in other constraints.

To add an accounting variable:

  1. In the Optimization Model window, right-click in the "Variables" section and Select "Add new variable"
  2. Right-click on the variable and change its name from "DefaultName..." to something more proper.
  3. To defined an indexed variable, for example to have one variable for each time period, click on Data binding > Sets, and add the index set, for example "periods". The variable name should now have a suffix [p].
  4. In the syntax window, type the definition. On the left-hand side, type the expression. On the right-hand side, type the name of the variable. The left and right hand sides should be separated with "==".
  5. Example: An ccounting variable for total stand volume is defined, with an index p for time period. Before addign the variable, the parameter volume[i,j,p] which linked to the Heureka result variable Forest Data.Volume Before must have been added. Syntax:

FORALL

IN periods DO SUM <i,j> IN treatmentunits * alternatives WITH altIncluded[i,j] >= 1: volume[i,j,p] * area[i] * x[i,j] == volTot[p];

  1. Important! By default, a variable (decision or accounting) has the property Range set to non-negative. If the accounting variable can be negative, which is the case for example for the total revenue in a time period if costs are larger that revenues, you must changed its Range type to

Values, in SEK/ha, can obviously be less than zero (negative) for stands and analysis areas in one or several periods. Make sure that this variable has a "RangeType" set to "All" (and not "Default" that only allows for positive values).

Adding a parameter which is linked to a state or revenue variable

  1. In the Optimization Model window, right-click in "Parameters" section and Select "Add new parameter"
  2. Type a name, for example "pulpWood" (without apostrophes)
  3. Let "Heureka result variable" be selected
  4. Click Next
  5. Select Financial Value > PulpWood Volume Total (if this is the variable you are interested in)
  6. Click Finish

To check what Heureka variable a certain parameter is linked to:

  1. Select the parameter
  2. In the Properties window for the parameter (under the syntax window), under Databinding > ResultProperty, you can see what Heureka variable the parameter is bounded to. If you click on it you can change the binding.

Adding a parameter that has a definition

  1. In the Optimization Model window, right-click in "Parameters" section and Select "Add new parameter"
  2. Type a name, for example "totalArea" (without apostrophes)
  3. Select "Formula" as parameter type
  4. Click Next
  5. In the syntax window, type the defiintion, for example sum <i> in treatmentunits: area[i]; (This can be edited later)
  6. Click Finish

Note: When defining an accounting variable (see above), you would also add a definition to the variable itself, such as == VariableName. For a defined parameter, you only type the expression.

====Adding a constraint

Sharing and downloading models