Home > other >  Using the Python scipy library linprog function problems
Using the Python scipy library linprog function problems

Time:11-11

 the from scipy import optimize as op 
The import numpy as np
C=np. Array ([430, 550, 680, 700, 510, 590, 890, 685, 395, 425, 910, 450])
Aub=np. Array ([[1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0] to [0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0] to [0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0] to [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1]]).
Bub=np. Array ([70, 100, 105, 75])
,1,1,1,0,0,0,0,0,0,0,0 Aeq=np. Array ([[1], [0,0,0,0,1,1,1,1,0,0,0,0], [0,0,0,0,0,0,0,0,1,1,1,1]])
Beq=np. Array ([105, 160, 85])
Bounds=((0100), 0100 (0), (0100), 0100 (0), (0100), 0100 (0), (0100), 0100 (0), (0100), 0100 (0), (0100), 0100 (0))

Res=op. Linprog (c, A_eq=Aeq, B_eq=Beq, bounds=bounds, the options={" disp ": True})
Print (res)


An error
TypeError: linprog () got an unexpected keyword argument 'B_eq'

Linprog use reference site

The questions and data



Excuse me each bosses, there was a problem in the format of is me? But I am in accordance with the reference site to

CodePudding user response:

B to lowercase
 the from scipy import optimize as op 
The import numpy as np
C=np. Array ([430, 550, 680, 700, 510, 590, 890, 685, 395, 425, 910, 450])
Aub=np. Array ([[1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0] to [0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0] to [0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0] to [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1]]).
Bub=np. Array ([70, 100, 105, 75])
,1,1,1,0,0,0,0,0,0,0,0 Aeq=np. Array ([[1], [0,0,0,0,1,1,1,1,0,0,0,0], [0,0,0,0,0,0,0,0,1,1,1,1]])
Beq=np. Array ([105, 160, 85])
Bounds=((0100), 0100 (0), (0100), 0100 (0), (0100), 0100 (0), (0100), 0100 (0), (0100), 0100 (0), (0100), 0100 (0))

Res=op. Linprog (c, A_eq=Aeq, b_eq=Beq, bounds=bounds, the options={" disp ": True})
Print (res)

CodePudding user response:

 the from scipy import optimize as op 
The import numpy as np
C=np. Array ([430, 550, 680, 700, 510, 590, 890, 685, 395, 425, 910, 450])
A_ub=np. Array ([[1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0] to [0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0] to [0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0] to [0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1]]).
B_ub=np. Array ([70, 100, 105, 75])
,1,1,1,0,0,0,0,0,0,0,0 A_eq=np. Array ([[1], [0,0,0,0,1,1,1,1,0,0,0,0], [0,0,0,0,0,0,0,0,1,1,1,1]])
B_eq=np. Array ([105, 160, 85])
Bounds=((0100), 0100 (0), (0100), 0100 (0), (0100), 0100 (0), (0100), 0100 (0), (0100), 0100 (0), (0100), 0100 (0))

Res=op. Linprog (c, A_ub, B_ub A_eq, B_eq, bounds=bounds, the options={" disp ": True})
Print (res)


Thank you very much for the answer of, like this can solve the above problems, so, could you tell me why variable case will affect the function of parameter identification
  • Related