Exemplo n.º 1
0
def model(N):
    m = Model()
    coords = [arange(N), arange(N)]
    x = m.add_variables(coords=coords)
    y = m.add_variables(coords=coords)
    m.add_constraints(x - y >= arange(N))
    m.add_constraints(x + y >= 0)
    m.add_objective((2 * x).sum() + y.sum())
    m.solve(SOLVER)
    return
Exemplo n.º 2
0
def test_nan_in_objective():
    m = Model()

    x = m.add_variables(name="x")
    y = m.add_variables(name="y")

    m.add_constraints(2 * x + 6 * y, ">=", np.nan)
    m.add_constraints(4 * x + 2 * y, ">=", 3)

    m.add_objective(np.nan * y + x)
    with pytest.raises(ValueError):
        m.solve()
Exemplo n.º 3
0
def model(n, solver, integerlabels):
    m = Model()
    if integerlabels:
        N, M = [arange(n), arange(n)]
    else:
        N, M = [arange(n).astype(float), arange(n).astype(str)]
    x = m.add_variables(coords=[N, M])
    y = m.add_variables(coords=[N, M])
    m.add_constraints(x - y >= N)
    m.add_constraints(x + y >= 0)
    m.add_objective((2 * x).sum() + y.sum())
    m.solve(solver)
    return