1

I am trying to minimize the following equation:

P_ch_max = min(22, E_need*m_int) where E_need*m_int can be bigger or lower than 22 depending on the data.

I am using the following equations in pyomo to do it:

m.C6 = ConstraintList()
for t in m.ts2:
    m.C6.add(expr = m.char_power - m.var_E_need[0,t]*m_int  <= 100*m.Y[t])
    m.C6.add(expr = m.var_E_need[0,t]*m_int - m.char_power <= 100 * (1-m.Y[t]))
    m.C6.add(expr = m.var_P_ch_max[0,t] <= m.var_E_need[0,t]*m_int  )
    m.C6.add(expr = m.var_P_ch_max[0,t]  <= m.char_power)
    m.C6.add(expr = m.var_P_ch_max[0,t] >= m.var_E_need[0,t]*m_int - 100*(1-m.Y[t]))
    m.C6.add(expr = m.var_P_ch_max[0,t]  >= m.char_power - 100*m.Y[t])

m.char_power = 22; m.Y is a boolean; 100 is my big` in this case

When I substitute the values of Y manually, these equations make sense: When Y=0 I get that P_ch_max<= 22 and P_ch_max>= 22 which would make P_ch_max == 22. When Y=1 I get that P_ch_max<= E_need*m_int and P_ch_max>= E_need*m_int which would make P_ch_max = E_need*m_int.

However, when I run the code in pyomo it says it's unfeasible or unbounded and I don't understand why. Is there any other way to do this? Or can you tell me if I am doing something wrong pls?

toyota Supra
  • 3,181
  • 4
  • 15
  • 19
  • You don't show all of your code... Your problem might be in your objective function if you are using `min()` which is non-linear and cannot be used in a pyomo expression. – AirSquid Jul 04 '22 at 22:17
  • I am not using min() in my objective function! its simply just: m.obj = Objective(expr = sum_bids_V1G, sense=maximize) – Martim Perestrelo Jul 05 '22 at 12:09

1 Answers1

0

It's pretty difficult to unwind your equations and figure out why it is infeasible. But you can do a couple things rather quickly to tackle this.

First, you can start to "comment out" constraints and see if you can get the model breathing (such that the solver doesn't complain about infeasibility), and then investigate from there.

Second, if you think you know a feasible solution (as you suggest in your comment about plugging in), then just plug in your values by assigning them and then display your model and it should stand out very quickly which constraints are violated. For example:

import pyomo.environ as pyo

m = pyo.ConcreteModel()

m.x = pyo.Var()

m.c1 = pyo.Constraint(expr=m.x >= 5)

m.x = 4

m.display()

Yields:

Model unknown

  Variables:
    x : Size=1, Index=None
        Key  : Lower : Value : Upper : Fixed : Stale : Domain
        None :  None :     4 :  None : False : False :  Reals

  Objectives:
    None

  Constraints:
    c1 : Size=1
        Key  : Lower : Body : Upper
        None :   5.0 :    4 :  None
[Finished in 210ms]
AirSquid
  • 10,214
  • 2
  • 7
  • 31