feasopt_vb.vb.


feasopt_vb.vb.


“版权所有2021,Gurobi优化狗万app足彩,LLC”此示例从文件中读取MIP模型,将人工“变量添加到每个约束,然后最小化”人工变量的总和“。具有目标零的解决方案对应于输入模型的可行解决方案。“我们也可以使用Feasrelax功能来进行。在此示例中,我们“使用Minrelax = 1,即优化返回的模型找到一个解决方案,最小化原始目标,而是只能从最小化人工变量的总和中的那些解决方案中。导入gurobi导入系统类feasopt_vb共享子主(byval args作为string())如果args.length <1那么console.writelinegrbmodel(erg,args(0))'创建副本用来使用feasrelax的功能稍后dim feasmodel1作为新grbmodel(feasmodel)'清除目标feasmodel.setobjective(new grblinexpr())'添加slack变量dim c作为grbconstr()= feasmodel.getConstrs()对于I作为Integer = 0到C.length  -  1次Sense作为Char = C(i).sense如果sense <>“>”c,则将ChrbCon()= new grbconstr()= new grbconstr()= new grbconstr()= new grbconstr()= new grbconstr(){c(i)} Dim coeffs作为double()= new double(){-1} feasmodel.addvar(0.0,grb.invinity,1.0,grb.continuous,_ constrs,coeffs,_“Artn_”&C(i).constrname)结束如果是sense <>“c,则将Dim dimbrs作为grbconstr()= new grbconstr(){c(i)} dim coeffs作为double()= new double(){1} feasmodel.addvar(0.0,grb.infinity,1.0,grb.Continuous,_ Constrs,CoEffs,_“Artp_”&C(i).constrname)结束如果下一步优化修改模型feasmodel.optimize()feasmodel.write(“feasopt.lp”)'使用feasrelax feature * / feasmodel1.feasrelax(grb.feasrelax_linear,true,false,true)feasmodel1.write(“feasopt1.lp”)feasmodel1.ptimize()'处置模型和env feasmodel1.dispose()feasmodel.dispose()env.dispose()捕获e作为grbexception console.writeline(“错误代码:”&e.errorcode&“)。“&e.message)结束尝试结束子结束类