How to setup a constraint that depends on interim minimized function?

108 views Asked by At

I am trying to setup a constraint which depends on the minimized function value.

The problem I have is of the following nature:

fmin = minimize (d1x1 +d2x2 ... +d5x5)

Where I want to optmize with following constraints:

x1+X2+x3+x4+x5 = 1

0.003 <x1 .. X5  < 0.05

d1x1/fmin = y1
(d2x2+d3x4)/fmin = y2
(d4x4+d5x5)/fmin = y3

Here in this case y1.. yn are scalar constants.

   The problem I am having is that I dont know how to setup the A_ub or A_eq 
   In linprog so that B_ub = y1*fmin for d1x1 for example. 

So somehow I need to define:

x1d1/fmin = y1 as one of the constraints.

Here the optimal value vector will be (d1 .. dn). However, this must also satisfy the constraint d1/minimized(d1.. dn) = y1 as an example here.

How should I set this up ? What kind of optimizer do I use ?

I am able to do this very easily using excel solver - but now I want to code this in python. I am trying using scipy.linprog but I am not sure if this is a linear programming problem or do I need to use another approach. I am not able to think of a way to setup the constraints in linprog for this problem. Can anyone help me ?

1

There are 1 answers

1
Karsten W. On BEST ANSWER

Assuming that d1, ..., dn are scalar constants too, then for instance the constraint

d1*x1/fmin==y1

can be rewritten as

d1*x1==y1*d1*x1+y1*d2*x2+...+y1*dn*xn

This can be normalized to

(d1-y1*d1)*x1 - y1*d2*x2 - y1*d3*x3 - ... - y1*dn*xn == 0

which can be used as input for a linear solver.