trying to make input_oriented VRS(BCC) model on python
Awaiting user inputi'm new to use gurobi
Code
def solve_DEA(target, verbose=True):
df_main = pd.read_csv('./df_31_1_Main.csv')
inattr = df_main.columns[1:7]
outattr = df_main.columns[7:]
dmus = [k for k in range(51)]
inputs = df_main.iloc[:,1:7].to_dict('index')
outputs = df_main.iloc[:,7:].to_dict('index')
### Create LP model
model = gp.Model('VRS_model')
# Decision variables
wout = model.addVars(outattr, name="outputWeight")
win = model.addVars(inattr, name="inputWeight")
u_vrs =model.addVars(dmus, name ="u_vrs")
model.update()
# Constraints
ratios = model.addConstrs( ( gp.quicksum(outputs[h][r]*wout[r] - u_vrs[target] for r in outattr )
- gp.quicksum(inputs[h][i]*win[i] for i in inattr )
<= 0 for h in dmus ), name='ratios' )
normalization = model.addConstr((gp.quicksum(inputs[target][i]*win[i] for i in inattr ) == 1 ),
name='normalization')
# Objective function
model.setObjective( gp.quicksum(outputs[target][r]*wout[r] - u_vrs[target] for r in outattr ), GRB.MAXIMIZE)
# Run optimization engine
if not verbose:
model.params.OutputFlag = 0
model.optimize()
# Print results
print(f"\nThe efficiency of target DMU {target} is {round(model.objVal,3)}")
print("__________________________________________________________________")
print(f"The weights for the inputs are:")
for i in inattr:
print(f"For {i}: {round(win[i].x,3)} ")
print("__________________________________________________________________")
print(f"The weights for the outputs are")
for r in outattr:
print(f"For {r} is: {round(wout[r].x,3)} ")
return model.objVal
Data
this is my part of data the total num of data is 51
the output of this code is same with CCR(CRS)model(from gurobi efficiency analysis)
what is my problem?
0
-
Official comment
This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum, or try Gurobot, our chatbot interface offering instant, expert-level support. -
Could you please edit your post such that the data part can be copy-pasted?
the output of this code is same with CCR(CRS)model(from gurobi efficiency analysis)
what is my problem?Could you please elaborate what exactly is wrong with your model? What is the CCR(CRS) model?
0
Post is closed for comments.
Comments
2 comments