コード例 #1
0
ファイル: test_yaposib.py プロジェクト: coin-or/yaposib
def unbounded(solver):
    """
    returns the following problem

    0  <= x <= 4
    -1 <= y <= 1
    0  <= z
    0  <= w

    maximize obj = x + 4*y + 9*z + w
    such that:
    c1: x+y <= 5
    c2: x+z >= 10
    c3: -y+z == 7
    c4: w >= 0
    """
    prob = yaposib.Problem(solver)
    obj = prob.obj
    obj.name = "unbounded"
    obj.maximize = True
    # names
    cols = prob.cols
    for i in range(4):
        cols.add(yaposib.vec([]))
    cols[0].name = "x"
    cols[1].name = "y"
    cols[2].name = "z"
    cols[3].name = "w"
    # lowerbounds
    for col in cols:
        col.lowerbound = 0
    cols[1].lowerbound = -1
    # upperbounds
    cols[0].upperbound = 4
    cols[1].upperbound = 1
    # constraints
    rows = prob.rows
    rows.add(yaposib.vec([(0,1),(1,1)]))
    rows.add(yaposib.vec([(0,1),(2,1)]))
    rows.add(yaposib.vec([(1,-1),(2,1)]))
    rows.add(yaposib.vec([(3,1)]))
    # constraints bounds
    rows[0].upperbound = 5
    rows[1].lowerbound = 10
    rows[2].lowerbound = 7
    rows[2].upperbound = 7
    rows[3].lowerbound = 0
    # constraints names
    rows[0].name = "c1"
    rows[1].name = "c2"
    rows[2].name = "c3"
    rows[3].name = "c4"
    # obj
    prob.obj[0] = 1
    prob.obj[1] = 4
    prob.obj[2] = 9
    prob.obj[3] = 1
    return prob
コード例 #2
0
def unbounded(solver):
    """
    returns the following problem

    0  <= x <= 4
    -1 <= y <= 1
    0  <= z
    0  <= w

    maximize obj = x + 4*y + 9*z + w
    such that:
    c1: x+y <= 5
    c2: x+z >= 10
    c3: -y+z == 7
    c4: w >= 0
    """
    prob = yaposib.Problem(solver)
    obj = prob.obj
    obj.name = "unbounded"
    obj.maximize = True
    # names
    cols = prob.cols
    for i in range(4):
        cols.add(yaposib.vec([]))
    cols[0].name = "x"
    cols[1].name = "y"
    cols[2].name = "z"
    cols[3].name = "w"
    # lowerbounds
    for col in cols:
        col.lowerbound = 0
    cols[1].lowerbound = -1
    # upperbounds
    cols[0].upperbound = 4
    cols[1].upperbound = 1
    # constraints
    rows = prob.rows
    rows.add(yaposib.vec([(0, 1), (1, 1)]))
    rows.add(yaposib.vec([(0, 1), (2, 1)]))
    rows.add(yaposib.vec([(1, -1), (2, 1)]))
    rows.add(yaposib.vec([(3, 1)]))
    # constraints bounds
    rows[0].upperbound = 5
    rows[1].lowerbound = 10
    rows[2].lowerbound = 7
    rows[2].upperbound = 7
    rows[3].lowerbound = 0
    # constraints names
    rows[0].name = "c1"
    rows[1].name = "c2"
    rows[2].name = "c3"
    rows[3].name = "c4"
    # obj
    prob.obj[0] = 1
    prob.obj[1] = 4
    prob.obj[2] = 9
    prob.obj[3] = 1
    return prob
コード例 #3
0
ファイル: test_yaposib.py プロジェクト: coin-or/yaposib
def mip(solver):
    """
    returns the following problem

    0  <= x <= 4
    -1 <= y <= 1
    0  <= z

    minimize obj = x + 4*y + 9*z
    such that:
    c1: x+y <= 5
    c2: x+z >= 10
    c3: -y+z == 7.5

    z integer
    """
    prob = yaposib.Problem(solver)
    obj = prob.obj
    obj.name = "mip"
    obj.maximize = False
    # names
    cols = prob.cols
    for i in range(3):
        cols.add(yaposib.vec([]))
    cols[0].name = "x"
    cols[1].name = "y"
    cols[2].name = "z"
    # lowerbounds
    for col in cols:
        col.lowerbound = 0
    cols[1].lowerbound = -1
    # upperbounds
    cols[0].upperbound = 4
    cols[1].upperbound = 1
    # integer variables
    cols[2].integer = True
    # constraints
    rows = prob.rows
    rows.add(yaposib.vec([(0,1),(1,1)]))
    rows.add(yaposib.vec([(0,1),(2,1)]))
    rows.add(yaposib.vec([(1,-1),(2,1)]))
    # constraints bounds
    rows[0].upperbound = 5
    rows[1].lowerbound = 10
    rows[2].lowerbound = 7.5
    rows[2].upperbound = 7.5
    # constraints names
    rows[0].name = "c1"
    rows[1].name = "c2"
    rows[2].name = "c3"
    # obj
    prob.obj[0] = 1
    prob.obj[1] = 4
    prob.obj[2] = 9
    return prob
コード例 #4
0
def mip(solver):
    """
    returns the following problem

    0  <= x <= 4
    -1 <= y <= 1
    0  <= z

    minimize obj = x + 4*y + 9*z
    such that:
    c1: x+y <= 5
    c2: x+z >= 10
    c3: -y+z == 7.5

    z integer
    """
    prob = yaposib.Problem(solver)
    obj = prob.obj
    obj.name = "mip"
    obj.maximize = False
    # names
    cols = prob.cols
    for i in range(3):
        cols.add(yaposib.vec([]))
    cols[0].name = "x"
    cols[1].name = "y"
    cols[2].name = "z"
    # lowerbounds
    for col in cols:
        col.lowerbound = 0
    cols[1].lowerbound = -1
    # upperbounds
    cols[0].upperbound = 4
    cols[1].upperbound = 1
    # integer variables
    cols[2].integer = True
    # constraints
    rows = prob.rows
    rows.add(yaposib.vec([(0, 1), (1, 1)]))
    rows.add(yaposib.vec([(0, 1), (2, 1)]))
    rows.add(yaposib.vec([(1, -1), (2, 1)]))
    # constraints bounds
    rows[0].upperbound = 5
    rows[1].lowerbound = 10
    rows[2].lowerbound = 7.5
    rows[2].upperbound = 7.5
    # constraints names
    rows[0].name = "c1"
    rows[1].name = "c2"
    rows[2].name = "c3"
    # obj
    prob.obj[0] = 1
    prob.obj[1] = 4
    prob.obj[2] = 9
    return prob
コード例 #5
0
ファイル: test_yaposib.py プロジェクト: coin-or/yaposib
def integer_infeasible(solver):
    """
    returns the following problem

    0  <= x <= 4
    -1 <= y <= 1
    0  <= z <= 10

    no objective
    constraints:
    c1: x+y <= 5.2
    c2: x+z >= 10.3
    c3: -y+z == 7.4

    x, y, z integer
    """
    prob = yaposib.Problem(solver)
    obj = prob.obj
    obj.name = "integer_infeasible"
    obj.maximize = False
    # names
    cols = prob.cols
    for i in range(3):
        cols.add(yaposib.vec([]))
    cols[0].name = "x"
    cols[1].name = "y"
    cols[2].name = "z"
    # integer variables
    for col in cols:
        col.integer = True
    # lowerbounds
    for col in cols:
        col.lowerbound = 0
    cols[1].lowerbound = -1
    # upperbounds
    cols[0].upperbound = 4
    cols[1].upperbound = 1
    cols[2].upperbound = 10
    # constraints
    rows = prob.rows
    rows.add(yaposib.vec([(0,1),(1,1)]))
    rows.add(yaposib.vec([(0,1),(2,1)]))
    rows.add(yaposib.vec([(1,-1),(2,1)]))
    # constraints bounds
    rows[0].upperbound = 5.2
    rows[1].lowerbound = 10.3
    rows[2].lowerbound = 7.4
    rows[2].upperbound = 7.4
    # constraints names
    rows[0].name = "c1"
    rows[1].name = "c2"
    rows[2].name = "c3"
    return prob
コード例 #6
0
def integer_infeasible(solver):
    """
    returns the following problem

    0  <= x <= 4
    -1 <= y <= 1
    0  <= z <= 10

    no objective
    constraints:
    c1: x+y <= 5.2
    c2: x+z >= 10.3
    c3: -y+z == 7.4

    x, y, z integer
    """
    prob = yaposib.Problem(solver)
    obj = prob.obj
    obj.name = "integer_infeasible"
    obj.maximize = False
    # names
    cols = prob.cols
    for i in range(3):
        cols.add(yaposib.vec([]))
    cols[0].name = "x"
    cols[1].name = "y"
    cols[2].name = "z"
    # integer variables
    for col in cols:
        col.integer = True
    # lowerbounds
    for col in cols:
        col.lowerbound = 0
    cols[1].lowerbound = -1
    # upperbounds
    cols[0].upperbound = 4
    cols[1].upperbound = 1
    cols[2].upperbound = 10
    # constraints
    rows = prob.rows
    rows.add(yaposib.vec([(0, 1), (1, 1)]))
    rows.add(yaposib.vec([(0, 1), (2, 1)]))
    rows.add(yaposib.vec([(1, -1), (2, 1)]))
    # constraints bounds
    rows[0].upperbound = 5.2
    rows[1].lowerbound = 10.3
    rows[2].lowerbound = 7.4
    rows[2].upperbound = 7.4
    # constraints names
    rows[0].name = "c1"
    rows[1].name = "c2"
    rows[2].name = "c3"
    return prob
コード例 #7
0
ファイル: test_yaposib.py プロジェクト: coin-or/yaposib
def duals_and_slacks(solver):
    """
    returns the following problem

    0  <= x <= 5
    -1 <= y <= 1
    0  <= z

    Minimize obj = x + 4 y + 9 z
    constraints:
    c1: x+y <= 5
    c2: x+z >= 10
    c3: -y+z == 7
    """
    prob = yaposib.Problem(solver)
    obj = prob.obj
    obj.name = "duals_and_slacks"
    obj.maximize = False
    # names
    cols = prob.cols
    for i in range(3):
        cols.add(yaposib.vec([]))
    cols[0].name = "x"
    cols[1].name = "y"
    cols[2].name = "z"
    # lowerbounds
    for col in cols:
        col.lowerbound = 0
    cols[1].lowerbound = -1
    # upperbounds
    cols[0].upperbound = 5
    cols[1].upperbound = 1
    # constraints
    rows = prob.rows
    rows.add(yaposib.vec([(0,1),(1,1)]))
    rows.add(yaposib.vec([(0,1),(2,1)]))
    rows.add(yaposib.vec([(1,-1),(2,1)]))
    # constraints bounds
    rows[0].upperbound = 5
    rows[1].lowerbound = 10
    rows[2].lowerbound = 7
    rows[2].upperbound = 7
    # constraints names
    rows[0].name = "c1"
    rows[1].name = "c2"
    rows[2].name = "c3"
    # obj
    prob.obj[0] = 1
    prob.obj[1] = 4
    prob.obj[2] = 9
    return prob
コード例 #8
0
ファイル: test_yaposib.py プロジェクト: coin-or/yaposib
def feasability_only(solver):
    """
    returns the following problem

    0  <= x <= 4
    -1 <= y <= 1
    0  <= z

    no objective
    constraints:
    c1: x+y <= 5
    c2: x+z >= 10
    c3: -y+z == 7.5

    z integer
    """
    prob = yaposib.Problem(solver)
    obj = prob.obj
    obj.name = "feasability_only"
    obj.maximize = False
    # names
    cols = prob.cols
    for i in range(3):
        cols.add(yaposib.vec([]))
    cols[0].name = "x"
    cols[1].name = "y"
    cols[2].name = "z"
    # lowerbounds
    for col in cols:
        col.lowerbound = 0
    cols[1].lowerbound = -1
    # upperbounds
    cols[0].upperbound = 4
    cols[1].upperbound = 1
    # integer variables
    cols[2].integer = True
    # constraints
    rows = prob.rows
    rows.add(yaposib.vec([(0,1),(1,1)]))
    rows.add(yaposib.vec([(0,1),(2,1)]))
    rows.add(yaposib.vec([(1,-1),(2,1)]))
    # constraints bounds
    rows[0].upperbound = 5
    rows[1].lowerbound = 10
    rows[2].lowerbound = 7.5
    rows[2].upperbound = 7.5
    # constraints names
    rows[0].name = "c1"
    rows[1].name = "c2"
    rows[2].name = "c3"
    return prob
コード例 #9
0
def duals_and_slacks(solver):
    """
    returns the following problem

    0  <= x <= 5
    -1 <= y <= 1
    0  <= z

    Minimize obj = x + 4 y + 9 z
    constraints:
    c1: x+y <= 5
    c2: x+z >= 10
    c3: -y+z == 7
    """
    prob = yaposib.Problem(solver)
    obj = prob.obj
    obj.name = "duals_and_slacks"
    obj.maximize = False
    # names
    cols = prob.cols
    for i in range(3):
        cols.add(yaposib.vec([]))
    cols[0].name = "x"
    cols[1].name = "y"
    cols[2].name = "z"
    # lowerbounds
    for col in cols:
        col.lowerbound = 0
    cols[1].lowerbound = -1
    # upperbounds
    cols[0].upperbound = 5
    cols[1].upperbound = 1
    # constraints
    rows = prob.rows
    rows.add(yaposib.vec([(0, 1), (1, 1)]))
    rows.add(yaposib.vec([(0, 1), (2, 1)]))
    rows.add(yaposib.vec([(1, -1), (2, 1)]))
    # constraints bounds
    rows[0].upperbound = 5
    rows[1].lowerbound = 10
    rows[2].lowerbound = 7
    rows[2].upperbound = 7
    # constraints names
    rows[0].name = "c1"
    rows[1].name = "c2"
    rows[2].name = "c3"
    # obj
    prob.obj[0] = 1
    prob.obj[1] = 4
    prob.obj[2] = 9
    return prob
コード例 #10
0
def feasability_only(solver):
    """
    returns the following problem

    0  <= x <= 4
    -1 <= y <= 1
    0  <= z

    no objective
    constraints:
    c1: x+y <= 5
    c2: x+z >= 10
    c3: -y+z == 7.5

    z integer
    """
    prob = yaposib.Problem(solver)
    obj = prob.obj
    obj.name = "feasability_only"
    obj.maximize = False
    # names
    cols = prob.cols
    for i in range(3):
        cols.add(yaposib.vec([]))
    cols[0].name = "x"
    cols[1].name = "y"
    cols[2].name = "z"
    # lowerbounds
    for col in cols:
        col.lowerbound = 0
    cols[1].lowerbound = -1
    # upperbounds
    cols[0].upperbound = 4
    cols[1].upperbound = 1
    # integer variables
    cols[2].integer = True
    # constraints
    rows = prob.rows
    rows.add(yaposib.vec([(0, 1), (1, 1)]))
    rows.add(yaposib.vec([(0, 1), (2, 1)]))
    rows.add(yaposib.vec([(1, -1), (2, 1)]))
    # constraints bounds
    rows[0].upperbound = 5
    rows[1].lowerbound = 10
    rows[2].lowerbound = 7.5
    rows[2].upperbound = 7.5
    # constraints names
    rows[0].name = "c1"
    rows[1].name = "c2"
    rows[2].name = "c3"
    return prob