3

I'm recently using gurobi(java) in eclipse, I'm sure I have successfully got a license and everything was fine when I used gurobi to solve LP problems like that:

public LP(int n, int[]s, int[][]b) throws GRBException
{
    ...
    env = new GRBEnv("LPRelaxation.log");
    model = new GRBModel(env);
}

Then I added a QP part to my program and the error occurs:

public QP() throws GRBException
{
    env = new GRBEnv("LPRelaxation.log");
    model = new GRBModel(env);
}

The error:

Exception in thread "main" gurobi.GRBException: No Gurobi license found (user asus, host OWEN-ASUS, hostid fccf6a77)
at gurobi.GRBEnv.<init>(GRBEnv.java:20)
at methods.QP.<init>(QP.java:16)
....
Owen
  • 57
  • 3
  • 11
  • There is not much we can do here, except for leading you to [the official docs on license-checks](https://www.gurobi.com/documentation/7.0/quickstart_mac/testing_your_license.html) (i just linked some mac-based doc; search the docs for your OS). – sascha Jul 05 '17 at 19:54
  • 2
    It seems that I was using `env=new GRBEnv()` too many times so it caused a problem, now I've changed it and it works again, thx! – Owen Jul 06 '17 at 03:25
  • Now the problem is clear: I didn't use `env.dispose()` after I finish using the Gurobi environment. This way I may open too many environments and cause a problem. The official doc is [here](http://www.gurobi.com/documentation/7.0/refman/java_grbenv_dispose.html). – Owen Jul 10 '17 at 13:16
  • Typically, you should use one Gurobi environment (GRBEnv object) per program. You can have multiple models (GRBModel objects) for a single Gurobi environment. – Greg Glockner Jul 10 '17 at 22:19
  • Yeah that makes sense! I didn't think of this way before, and now it works. – Owen Jul 12 '17 at 00:08

1 Answers1

2

set the environment variable GRB_LICENSE_FILE with the path to license key file

reference: https://www.gurobi.com/documentation/8.1/quickstart_mac/testing_your_license.html