# Method Gurobi bug for NMaximize

Consider the following linear maximization problem. NMaximize using Method->Gurobi fails to include xs[4]=1 as a part of the solution. NMaximize using Method->Authomatic finds the correct solution. Any help and thoughts would be of tremendous help!

I do not want to switch to Method->Authomatic as the code below is a small piece of a larger program where hundreds of thousands of similar maximization problems happen. An increase in speed with Gurobi is essential here.

xstable = Array[xs, 5];

(*Objective*)

obj = 0.6971463902012777  xs[1] + 1.233843291836281  xs[2] + 0.1770771502382662  xs[3] + 1.3537719900647005*^-7  xs[4] + 1.1394947011844099  xs[5];

(*Constraints*)

constr = {0.19905000000000017  xs[1] + 1.2342600000000008  xs[2] <= 1.242651942876121, xs[1] + xs[2] + xs[3] + xs[4] + xs[5] <= 5, 1 >= xs[1] >= 0, 1 >= xs[2] >= 0, 1 >= xs[3] >= 0, 1 >= xs[4] >= 0,1 >= xs[5] >= 0}

outputG = NMaximize[{obj, constr}, xstable \[Element] Integers, AccuracyGoal -> 20, PrecisionGoal -> 20, MaxIterations -> 10000, Method -> "Gurobi"];

outputA = NMaximize[{obj, constr}, xstable \[Element] Integers, AccuracyGoal -> 20, PrecisionGoal -> 20, MaxIterations -> 10000, Method -> Automatic];

NumberForm[outputG, 10]
NumberForm[outputA, 10]
NumberForm[obj /. {xs[1] -> 0, xs[2] -> 1, xs[3] -> 1, xs[4] -> 1, xs[5] -> 1}, 10]


Output:

 {2.550415143258957, {xs[1] -> 0, xs[2] -> 1,xs[3] -> 1, xs[4] -> 0, xs[5] -> 1}}

{2.550415278636156, {xs[1] -> 0, xs[2] -> 1, xs[3] -> 1, xs[4] -> 1, xs[5] -> 1}}

2.550415279

• Gurobi Optimizer is an external commercial solver, which is not automatically available in Mathematica. Hence, it will be difficult for us to determine what's the cause of your problem. I suggest you first see whether the problem lies in the Gurobi Optimizer (can you use this software directly, outside Mathematica?). If it works fine, then you should probably contact Wolfram Technical Support. Commented Aug 1 at 16:02
• Note that a license is required: "NMaximize::opmlicwf: The method Gurobi cannot be used since a valid license could not be found. See get a license for Gurobi." Commented Aug 1 at 16:04
• Thank you. I will contact Wolfram Technical Support Commented Aug 11 at 12:56