Skip to content

MILP Equations (PML)

MILP Equations (PML)

The MILP model is formulated in parallel with the algebraic model in the PML. The two parts of the MILP model are the objective function according to which optimization is performed, e.g., operating costs, and the constraints to be met, e.g., energy balances.

Follow the instructions for the correct Declaration of linear variables.

The MILP model is formed from equations that are also written in the PML.

Target Function Contributions

The objective function is the sum of all target function contributions. It is always minimized. A target function contribution has a model (type of contribution), which is assigned to a specific cost function. A target function contribution has the following PML syntax:

target.Type Linear Term

Example
target.Operation price_Electricity * lP_electric

In the above example, the term electricity price times electrical power is part of the objective function Operating costs. If you choose to optimize for CO2 emissions instead of Operating costs, for example, the target function contributions of type target.Operation are ignored.

The unit of the linear term must correspond to the unit of the contribution type (in the example: EUR/a).

Default Target Function Contributions

The following target functions are available preconfigured in the software.

TypeUnitDescription
AnnualTEUR/aAnnualized Overall Cost
CO2t/aCO2 Emission
InvestTEURInvestment Costs
NPVTEURNet Present Value
OperationTEUR/aCost of Operation
OtherTEUR/aUser-defined Cost
PrimaryEnergykWPrimary Energy

The target function contributions in different components are combined by addition to form a target function (objective function). Within a component, target function contributions can also be assigned to other contribution types. The variable this.contribution_type is used for this purpose. The following table shows as an example of this the various cost contributions of the Fuel_Tariff component: In the second line, the annualized total costs (Annual) are assigned to the contribution type Annualized operating costs (Operation), in the third line, the net present value (NPV) is calculated from the annualized total costs scaled by the annuity present value factor (RBF).

target.Operationin.lH_dot_chem * price_TT;
target.Annual this.Operation;
target.NPVthis.Annual * .economy.RBF;

Above, it was described how you assign a contribution to the target function. If you want to read the value of the target function itself, for example to constrain it, you can retrieve the following variables: .targetInvest, .targetOperation or .targetCO2.

Example

CO2_total = .targetCO2;
.targetCO2 <= 1000 [t/a];

User-defined Costs

The User-defined costs item is modeled in the respective components. All those user-defined target function contributions that cannotdbe assigned to the main types target.Operation, target.NPV, etc., are managed under this. Each target cost contribution named by the user and formulated in the model description is assigned to the User-defined costs component, e.g.,

target.MyCosts lcosts*10;

The assignment to User-defined costs is indicated by the message [8236] in the Simulator window under Log level 3 Details. The target function contribution must be convertible to [EUR/a].

An additional cost function can be defined for an energy system in which quantities other than the preset ones are relevant.

For example, a system can be optimized to generate as little noise as possible. To do this, a cost function target.Noise is defined, and contributions are added in all relevant components. For example, you can add in the model description of a boiler:

target.Noise 3 [EUR/kWh] * lQ_dot_heat;

and the noisier gas turbine would be assigned the contribution:

target.Noise 15 [EUR/kWh] * lP_el;

In the subsequent optimization according to the objective function User-defined costs, the mode of operation is determined in such a way that the costs for noise pollution are the lowest. Of course, all other constraints still apply, e.g., that the demands must be met, etc. The optimization only concerns the degrees of freedom in the system that go beyond this.

One scenario for modeling User-defined costs is actor-based optimization. If the model contains several actors (stakeholders), the overall optimum is always calculated as the result, in which the lowest costs are incurred in the entire system, or the greatest profits are achieved. If, however, only certain costs or profits are to be considered, copy the existing cost calculations from the appropriate components and insert them under MyCosts. For the Fuel component, it may look like this:

Original:

Self modeled:

In the subsequent optimization according to the objective function User-defined costs, only the contribution from MyCosts is evaluated and minimized.

Equations for Constraints

The objective function is minimized subject to constraints. The constraints are to be formulated as equations or inequalities of the syntax ==, >= or <=. For example, energy balances represent typical constraint equations, and maximum plant capacities are typical inequalities formulated as constraints.

Examples

lH_dot_in + lH_dot_aus == lH_dot_chem + lP_el ;

lP_el <= P_el_max ;

All equations with a double equals or inequal sign enter the MILP as constraints and therefore must conform to a linear structure. The used optimizable variables (design variables) can only be added or subtracted among each other.
Algebraic variables enter the optimization model as coefficients and must be determined before solving the MILP problem.

Example
Eta is a coefficient (algebraic, declared as Number ), and the value is already known before the optimization: 80 %.
lP_el and lH_dot_chem are design variables declared as Linear Number.

lP_el == eta * lH_dot_chem ;

For MILP, multiplication of two optimizable variables (design variables declared as Linear Number) is not allowed as this is a nonlinear formulation.

Wrong:
lP_el * lQ_dot_heat == lH_dot_chem ;

If an optimization variable is equated to an algebraic one in a linear equation (e.g., lP == P_max ;), the algebraic variable is to be understood as a coefficient and — in contrast to the use of the optimization result variable in the algebraic system of equations P = lP — must be known before optimization.

Common mistakes when creating MILP models

Missing Coefficients of the MILP

A coefficient of the MILP (algebraic Number variable) is not known at the time of solving. The following message appears in the Simulator window.

Click on the blue link underdetermined coefficients. Then, on the right side of the Simulator window, scroll under the Unsolvable tab in the Variable window until you find a variable for which no value is displayed (see the following figure).

The example shown corresponds to the equation shown above in Section 3:

lP_el == eta * lH_dot_chem ;

However, by mistake, the efficiency eta was not calculated or entered here before the optimization.

Nonlinear Equations

If you mistakenly use a nonlinear formulation for two optimization variables (linear numbers, design variables), a message indicates this.

Back To Top