Maximum number of elements in LineExp for free trial?
AnsweredHi all,
I want to make a model that helps me to determine where to aim on the dartboard. The dartboard consists of x and y coordinates. These values range from -170 to 170.
Let's say that the possible actions / aiming location on the dartboard are formulated as follows:
actions = [[random.randrange(-170, 171, 1), random.randrange(-170, 171, 1)] for i in range(1000)]
Next, I have a dictionary named p that has three key fields. The first key represents the x-coordinate (as a string), the second key the y-axis (as a string) and the 3rd key is the possible outcome {S1, S2, S3, .. D1, D2, D3, ..., T1, T2, T3, ..., SB, DB}
If the score is 2, the only legal dart outcome is D1. The goal is to determine the aiming location, xy coordinates, that gives the highest probability of throwing D1. I create the following model:
m = gurobi.Model()
m.Params.LogToConsole = 0
m.Params.PoolSearchMode = 2
m.Params.PoolSolutions = 10000
m.Params.PoolGap = 0
legal_zs = ['D1']
# action
xy_vars = [m.addVar(vtype=gurobi.GRB.BINARY, name=f'{action[0]}|{action[1]}') for action in actions]
# there is only a single throw / action outcome
m.addConstr(gurobi.quicksum(xy_vars) == 1)
m.update()
# z
z_vars = m.addVars(legal_zs, lb=1, ub=1, vtype=gurobi.GRB.BINARY, name='z')
m.update()
# p
p_vars = m.addVars(legal_zs, lb=0, ub=1, vtype=gurobi.GRB.CONTINUOUS, name='p')
# p bust
p_bust_var = m.addVar(lb=0, ub=1, vtype=gurobi.GRB.CONTINUOUS, name='p_bust')
p_bust_var_div = m.addVar(lb=0, ub=1, vtype=gurobi.GRB.CONTINUOUS, name='p_bust_div')
m.addConstr(p_bust_var == 1 - gurobi.quicksum(p_vars))
m.addConstr(p_bust_var * p_bust_var_div == 1)
m.update()
# constraint
m.addConstrs(p_vars[z_var] == gurobi.quicksum(p[str(action[0])][str(action[1])][z_var] * xy_var
for action, xy_var in zip(actions, xy_vars)) for z_var in z_vars)
# basically the above loops over all the possible aiming locations and retrieves the probability
# of throwing D1. I multiply these values with the binary variable to determine later the highest prob
m.optimize()
Inspecting m before optimizing shows:
<gurobi.Model MIP instance Unnamed: 3 constrs, 1005 vars, Parameter changes: LogToConsole=0, PoolSolutions=10000, PoolSearchMode=2, PoolGap=0.0>
However, when I try to optimize I get an error:
GurobiError: Model too large for size-limited license; visit https://www.gurobi.com/free-trial for a full license
However, the model has clearly less than 2000 vars and constraints. Is there also a maximum number of elements in a LineExpr? I am not sure what is causing this error. Please advice, thank you!
-
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 why not try our AI Gurobot?. -
Hi Huib,
For quadratic problems, the limited-size pip license allows for only 200 variables, see How do I resolve an "Model too large for size-limited Gurobi license" error?
If you are an academic, you can get a free academic license which does not hold the size limitation.
If you are a commercial user, you can apply for a free trial.
In any case, when applying for a license, please use either an email connected to your university or your company.
Best regards,
Jaromił0 -
Hi Jaromił,
Thanks for responding! I noticed the limits in the documentation, yes. But I am not sure why my model violates them? There are no quadratic terms in my model I believe.
Can you check what's going on?
0 -
Hi Huib,
The constraint
p_bust_var * p_bust_var_div == 1
is a quadratic one because \(\texttt{p_bust_var}\) and \(\texttt{p_bust_var_div}\) are both optimization variables.
Best regards,
Jaromił0 -
Gotcha. I included that constraint based on your article. Later in the script I need to divided a term by p_bust_var. Is there any other way to satisfy the vars limitations and divide by p_bust_var?
0 -
Both constraints are expressed in the form of p_bust_var so I can write
m.addConstr(p_bust_var_div == 1 / (1 - gurobi.quicksum(p_vars)))
Then I don't have a quadratic model anymore correct. However, this yields the following error.
GurobiError: Divisor must be a constant
Still the division problem, any tips?
0 -
Hi Huib,
Unfortunately, there is no way to avoid using bilinear terms when trying to reformulate division. However, you could use a piecewise-linear approximation of the function.
Best regards,
Jaromił0
Post is closed for comments.
Comments
7 comments