Skip to content
Advertisement

mixed integer programming optimization

I am trying to understand how gekko and its different types of custom variables work. So I wrote a very simple optimization problem, but it won’t find the optimal solution, at least this is what i think the error message means.

The code is a simple set switch combination (braco_gas and braco_eh, both binaries) multiplied by some weights (vazao and volume, both continuos).

I want to find which combination of switches and weights yields the maximum objective value. See below the objective:

Objective = vazao_gas * braco_gas_1 + volume_gas * braco_gas_2 + vazao_eh * braco_eh_1 + volume_eh * braco_eh_2

See the code below:

JavaScript

Following the error message:

JavaScript

Advertisement

Answer

The problem is currently unbounded (see Objective: -1.E+15).

Use m.Intermediate() instead of m.MV(). An MV (Manipulated Variable) is a degree of freedom that the optimizer can use to achieve an optimal objective among all of the feasible solutions. Because tempo_b1, tempo_b2, and tempo_total all have equations associated with solving them, they need to either be:

  • Regular variables with m.Var() and a corresponding m.Equation() definition
  • Intermediate variables with m.Intermediate() to define the variable and equation with one line.

Here is the solution to the simple Mixed Integer Linear Programming (MINLP) optimization problem.

JavaScript
JavaScript

The complete script:

JavaScript

Additional tutorials are available in the documentation or in the 18 example problems (with videos).

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement