I'm working in a LP problem with the PuLP Library and I have some strange that I can't explain by myself. I have nearly 100 variables and constraints, and I want to put it in my model, but I can't. It tells me
RecursionError: maximum recursion depth exceeded in comparison
First, I've tried to parse it in a for loop:
for cent_artic in df_demand['REQUIRED']:
display(df_offers[df_offers['REQUIRED']==cent_artic])
lista = list(df_ofertas1[df_ofertas1['REQUERIDO']==cent_artic]['OFERTADO'])
display(lista)
prob += lpSum(lista) >= cent_artic_dict[cent_artic], "Restriccion para cent_artic "+cent_artic
And the RecursionError showed up.
I've tried to pass only one restriction to the problem:
prob += lpSum(['c-1_a-2757_p-13','c-1_a-2757_p-12','c-1_a-2757_p-188']) >= cent_artic_dict['c-1_a-2757']
And it's the same. I can't understand why Python tell me something about a Error of Recursion, if I try to pass only one equation...
cent_artic_dict = {'c-5_a-17372_p-188': var_c_5_a_17372_p_188,
'c-179_a-2757_p-188': var_c_179_a_2757_p_188,
'c-18_a-17372_p-188': var_c_18_a_17372_p_188,
'c-26_a-2757_p-18': var_c_26_a_2757_p_18,
'c-41_a-2757_p-18': var_c_41_a_2757_p_18,
'c-156_a-2757_p-188': var_c_156_a_2757_p_188,
'c-24_a-17372_p-188': var_c_24_a_17372_p_188,
...
}
Now, the dataframe of df_offers have a shape of (89,6). At the beginning, it was (89,21)
Could anybody explain why I'm having the RecursionError? Thank you.
I've seen another question about it, but it doesn't have answer, only an advice
I have very little idea what you are doing but i can point out that
prob += lpSum(['c-1_a-2757_p-13','c-1_a-2757_p-12','c-1_a-2757_p-188']) >= cent_artic_dict['c-1_a-2757']
is not valid because lpSum
needs lists of LpVariables
not strings