python linprog minimization error - simplex method

  • Last Update :
  • Techknowledgy :

Case 1:

res = linprog(c, A_eq = A, b_eq = b, method = 'interior-point')
print('Optimal value:', res.fun, '\nX:', res.x) >>
   Optimal value: 64090.8624935836
X: [4.90908724e+02 1.50821194e-05 3.45454303e+02 7.63635788e+02]

Case 2:

res = linprog(c, A_ub, b_ub, A_eq, b_eq, bounds = (0, None), method = 'interior-point')
print('Optimal value:', res.fun, '\nX:', res.x)
#output:
   >>
   Optimal value: 449999.99988966336
X: [377.22836393 748.5144238 1874.25721154]

Suggestion : 2

Linear programming: minimize a linear objective function subject to linear equality and inequality constraints using the tableau-based simplex method.,The values of the decision variables that minimizes the objective function while satisfying the constraints.,The inequality constraint matrix. Each row of A_ub specifies the coefficients of a linear inequality constraint on x.,The coefficients of the linear objective function to be minimized.

c @ x
A_ub @ x <= b_ub
A_eq @ x == b_eq
lb <= x <= ub

Suggestion : 3

I'm using scipy.optimize.linprog library to anycodings_scipy calculate the minimization using the simplex anycodings_scipy method. I have two cases where I am getting anycodings_scipy error: ,I checked the system and solutions are anycodings_optimization indeed feasible. After reading this anycodings_optimization post, it seems that there are floating anycodings_optimization point issues in linprog, clearly a anycodings_optimization problem of the method. Seems that anycodings_optimization passing method='interior-point' improves anycodings_optimization the algorithm.,There are really some problems in anycodings_optimization linprog with simplex method. I've found anycodings_optimization more than 15 cases that are soluble in anycodings_optimization Matlab but can't be solved by linprog anycodings_optimization with "method=simplex". It can also be anycodings_optimization solved by passing anycodings_optimization "method=interior-point". But the usually anycodings_optimization the simplex method is more popular. Hope anycodings_optimization to fix it.,Having trouble using power query to compare two excel csv's and showing differences (additions/deletions) between two sheets

Maybe someone will find where the problem anycodings_scipy is.

Minimaze: 45 x1 + 54 x2 + 42 x3 + 36 x4

Subject to: x1 + x2 + x3 + x4 = 1600
30 x1 + 60 x2 + 70 x3 + 80 x4 = 100000
30 x1 + 40 x2 + 0x3 + 20 x4 = 30000

The code I wrote:

A = np.array([
   [-30, -60, -70, -80],
   [-30, -40, 0, -20],
   [-1, -1, -1, -1]
])
b = np.array([-100000, -30000, -1600])
c = np.array([45, 54, 42, 36])

res = linprog(c, A_eq = A, b_eq = b, bounds = (0, None))

Here is the second examples:

Minimize: 100 x1 + 50 x2 + 100 x3

Subject to: x1 + x2 + x3 = 3000
28 x1 + 14 x2 + 10 x3 <= 42000
10 x1 + 12 x2 + 6 x3 <= 24000
30 x1 + 20 x2 + 30 x3 >= 75000
10 x1 + 10 x2 + 15 x3 >= 36000

Case 1:

res = linprog(c, A_eq = A, b_eq = b, method = 'interior-point')
print('Optimal value:', res.fun, '\nX:', res.x) >>
   Optimal value: 64090.8624935836
X: [4.90908724e+02 1.50821194e-05 3.45454303e+02 7.63635788e+02]

Case 2:

res = linprog(c, A_ub, b_ub, A_eq, b_eq, bounds = (0, None), method = 'interior-point')
print('Optimal value:', res.fun, '\nX:', res.x)
#output:
   >>
   Optimal value: 449999.99988966336
X: [377.22836393 748.5144238 1874.25721154]

Suggestion : 4

I checked the system and solutions are indeed feasible. After reading this post, it seems that there are floating point issues in linprog, clearly a problem of the method. Seems that passing method='interior-point' improves the algorithm.,There are really some problems in linprog with simplex method. I've found more than 15 cases that are soluble in Matlab but can't be solved by linprog with "method=simplex". It can also be solved by passing "method=interior-point". But the usually the simplex method is more popular. Hope to fix it.

Case 1:

res = linprog(c, A_eq = A, b_eq = b, method = 'interior-point') print('Optimal value:', res.fun, '\nX:', res.x) >> Optimal value: 64090.8624935836 X: [4.90908724e+02 1.50821194e-05 3.45454303e+02 7.63635788e+02]

Case 2:

res = linprog(c, A_ub, b_ub, A_eq, b_eq, bounds = (0, None), method = 'interior-point') print('Optimal value:', res.fun, '\nX:', res.x) #output: >> Optimal value: 449999.99988966336 X: [377.22836393 748.5144238 1874.25721154]

Suggestion : 5

Linear programming: minimize a linear objective function subject to linear equality and inequality constraints using the revised simplex method.,The values of the decision variables that minimizes the objective function while satisfying the constraints.,The coefficients of the linear objective function to be minimized.,The inequality constraint matrix. Each row of A_ub specifies the coefficients of a linear inequality constraint on x.

c @ x
A_ub @ x <= b_ub
A_eq @ x == b_eq
lb <= x <= ub