Python Forum
regarding lpvariable - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: regarding lpvariable (/thread-22760.html)



regarding lpvariable - rin109 - Nov-26-2019

Hi,
How do I write the code for a dependent decision variable for linear programming?

I want to minimize the cost.
and I wrote: Lp_prob = p.LpProblem('Problem', p.LpMinimize)

For example,
A factory can produce up to 10 products in a month.
so: njan = LpVariable("n", lowBound = 0, upBound = 10)

A factory has an additional cost for $100 if more than 5 products are produced. ($100 regardless of how much more)
I tried using
if n >= 5:
addjan = 100,
else:
addjan = 0
after my objective function, but it won't work

Is there anyway I can let the objective function considers the if statement for decision variables?
Thank you. Sorry for poor English.