lp_cs.cs.
/ *版权所有2018,Gurobi优狗万app足彩化,LLC * / / *此示例从文件中读取LP模型并解决它。如果模型是不可行或无界的,则示例关闭预定稳定并再次解决模型。如果该模型是不可行的,则该示例计算Irreafucibe不一致的子系统(IIS),并将其写入文件。* /使用系统;使用gurobi;class lp_cs {静态void main(String [] args){if(args.length <1){console.out.writeline(“用法:lp_cs filename”);返回;试试{grbenv env = new grbenv();grbmodel模型=新grbmodel(env,args [0]);model.Optimize(); int optimstatus = model.Status; if (optimstatus == GRB.Status.INF_OR_UNBD) { model.Parameters.Presolve = 0; model.Optimize(); optimstatus = model.Status; } if (optimstatus == GRB.Status.OPTIMAL) { double objval = model.ObjVal; Console.WriteLine("Optimal objective: " + objval); } else if (optimstatus == GRB.Status.INFEASIBLE) { Console.WriteLine("Model is infeasible"); // compute and write out IIS model.ComputeIIS(); model.Write("model.ilp"); } else if (optimstatus == GRB.Status.UNBOUNDED) { Console.WriteLine("Model is unbounded"); } else { Console.WriteLine("Optimization was stopped with status = " + optimstatus); } // Dispose of model and env model.Dispose(); env.Dispose(); } catch (GRBException e) { Console.WriteLine("Error code: " + e.ErrorCode + ". " + e.Message); } } }