New answers tagged

3

If you look at the output log, you'll see a primal infeasibility value of 2.0 (which is the sum of the absolute values of the violations in the two values you noted). That just means it will take more than one iteration to find an initial feasible solution. In other words, your iteration limit is too small.


5

Constraints 1 and 2 ensure that there is an edge going in and out of every node. Constraint 3 works as a subtour elimination and along with the above constraints ensures that there is no subtour and as a result, you must enter and leave the depot. A simple illustration is to assume there are only 3 nodes. So: $ V = \{0, 1, 2\}$ and $ N = \{1,2\}$. Let's ...


1

I have added a more general question and answer that address the modeling aspect, independent of solver: How to linearize membership in a finite set You can apply this with $S=\{0,3,5\}$, $S=\{0,1,3,5\}$, and so on.


2

You can do something like this: possible_values = [10, 15] # add binary variables b = m.addVars(len(possible_values), vtype="B") # b[0] + b[1] == 1 m.addConstr(b.sum() == 1) # add indicator constraints: for i, val in enumerate(possible_values): # if b[i] == 1, then x.prod(f) == val m.addConstr((b[i] == 1) >> (x.prod(f) == val)) ...


1

thanks for all your answers. I just wanted to say that the problem was in fact related to the Gurobi license file. I contacted Gurobi and they could reproduce the error and they just gave me a new license. Now everything is okay again.


1

The problem is that you create a tuplelist of a list. The function addVars returns a list of variables objects already. This means, you should be able to simply do: contribution = LinExpr(coefficients, bns)


1

Here is a small variation of RobPratt's answer. I will use two sets, as an example. Two sets of constants are given: $S_1 = \lbrace x_{1,1}, x_{1,2}, x_{1,3} \rbrace$ and $S_2 = \lbrace x_{2,1}, x_{2,2} \rbrace$. The goal is to choose 1 item from each set and ensure the sum of all items chosen is 100. Make one binary variables per item: $b_{1,1}, b_{1,2}, b_{...


3

Given values $v_i$ with index set $I$ (for example, $I=\{1,2,3,4,5\}$ with $v=[10,20,50,60,30]$), you can enforce $x=v_i$ for some $i\in I$ by introducing binary variables $y_i$ and imposing linear constraints \begin{align} \sum_{i\in I} y_i &= 1 \tag1 \\ \sum_{i\in I} v_i y_i &= x \tag2 \end{align} Constraint $(1)$ chooses exactly one $i$ with $y_i=...


3

This does not look like a license issue. This is a Pyomo error code. You should share some more info about the error message and other output before. If your new license is stored in C:\gurobi\gurobi.lic, Gurobi will find the license automatically and there is usually nothing else required to make it work. Update: To test the license, it is better to either ...


1

You need to put the new licence in your terminal and run it Installation To install this license on a computer where Gurobi Optimizer is installed, copy and paste the following command to the Start/Run menu (Windows only) or a command/terminal prompt (any system like mac): Let's assume your licence is as follows grbgetkey 58eab684-cd60-12eb-b669-0242ac120002 ...


1

For timing within the gurobi solver, maybe you can call <optimizer>.solve() method with report_timing=True, as described in pyomo's documentation at https://pyomo.readthedocs.io/en/stable/library_reference/solvers/gurobi_persistent.html I haven't used Gurobi before. If gurboipy logs the starting and ending time of the optimization, then you can ...


3

Yes, you can. For example, with Pyomo package, the gurobi solver is selected using the following code: opt = SolverFactory("gurobi", solver_io='python') opt.options["NonConvex"] = 2 opt.options['MIPGap'] = 0.01 opt.options['SolCount'] = 2 results = opt.solve(model, load_solutions=True, tee=True) The attributes of gurobi solver can be ...


Top 50 recent answers are included