Skip to content
Advertisement

How could constraints be dynamically constructed in gekko?

I’m a newbie in gekko, and want to use it in my linear programming problems.

I have variable names, costs, minimum and maximum bounds in separate dictionaries (my_vars, Cost, Min and Max) with variable names as their keys, and the objective is minimizing total cost with determining the amount of variables satisfying the constraints.

I did as below;

JavaScript

Here I’d like to use variable original names instead of xi, is there any way?

it continues as;

JavaScript

Also I have constraint’s left hand side (LHS) (coefficients of variables) and right hand side (RHS) numbers in two pandas data frame files, and like to construct equations using a for loop.

I don’t know how to do this?

Advertisement

Answer

Here is one way to use your dictionary values to construct the problem:

JavaScript

This produces a solution:

JavaScript

Here are a few examples of efficient linear programming with Gekko by exploiting problem sparsity.

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