Python Forum
Pulp Linear Programming
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pulp Linear Programming
#1
Hello,
I am trying to code this program

Quote:Find y ∈R^m
minimising y·ve
subject to M'*y ≥ 1 and y ≥ 0

And I wrote this code, but I don't know how I can define matrix as a variable. Can you please show me how can I define matrix as a variable in Pulp
import pulp as p 
  
# Create a LP Minimization problem 
Lp_prob = p.LpProblem('Problem', p.LpMinimize)  
  
# Create problem Variables  
y = p.LpVariable("y", lowBound = 0)   # Create a variable y >= 0. Here y is the matrix
  
# Objective Function 
Lp_prob += y*ve #ve is the matrix
  
# Constraints: 
Lp_prob +=M.T*y >= 1  #M is the (64*64)matrix 
Lp_prob += y>=0
  
# Display the problem 
print(Lp_prob) 
  
status = Lp_prob.solve()   # Solver 
print(p.LpStatus[status])   # The solution status 
  
# Printing the final solution 
print(p.value(x), p.value(y), p.value(Lp_prob.objective)) 
And my second problem is that:
Quote:Lp_prob = p.LpProblem('Problem', p.LpMinimize)
AttributeError: 'float' object has no attribute 'LpProblem'
How can I solve this problem?
Reply
#2
Your query will probably get answered at some point on this forum, but I think this question will be answered sooner by the authors of pulp. You can get their email links here: https://pypi.org/project/PuLP/
(left sidebar, subject: statistics)
Reply
#3
Thank you very much. I wrote one of the authors. Hope he can answer as soon as possible because it is a bit urgent
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Energy optimization with pulp MartinRK80 0 624 Nov-21-2023, 04:24 PM
Last Post: MartinRK80
  Dijkstra in PuLP optimisation Problem tarrymarufu 2 2,200 Mar-09-2020, 12:46 PM
Last Post: tarrymarufu
  How to build linear regression by implementing Gradient Descent using only linear alg PythonSpeaker 1 2,189 Dec-01-2019, 05:35 PM
Last Post: Larz60+
  Ifs in PuLP priscila24 0 2,210 Oct-30-2017, 09:02 PM
Last Post: priscila24

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020