Esempio n. 1
0
def e_ik(itab, ktab, star=0):
    """
    EXAMPLES::
    
        sage: from sage.combinat.symmetric_group_algebra import e_ik
        sage: e_ik([[1,2,3]], [[1,2,3]])
        [1, 2, 3] + [1, 3, 2] + [2, 1, 3] + [2, 3, 1] + [3, 1, 2] + [3, 2, 1]
        sage: e_ik([[1,2,3]], [[1,2,3]], star=1)
        [1, 2] + [2, 1]
    """
    it = Tableau(itab)
    kt = Tableau(ktab)
    if star:
        it = it.restrict(it.size() - star)
        kt = kt.restrict(kt.size() - star)

    if it.shape() != kt.shape():
        raise ValueError, "the two tableaux must be of the same shape"

    mult = permutation_options['mult']
    permutation_options['mult'] = 'l2r'
    
    if kt == it:
        res =  e(it)
    elif (it, kt) in e_ik_cache:
        res = e_ik_cache[(it,kt)]
    else:
        pi = pi_ik(it,kt)
        e_ik_cache[(it,kt)] = e(it)*pi
        res = e_ik_cache[(it,kt)]

    permutation_options['mult'] = mult    
    return res
Esempio n. 2
0
def epsilon(tab, star=0):
    """
    EXAMPLES::
    
        sage: from sage.combinat.symmetric_group_algebra import epsilon
        sage: epsilon([[1,2]])
        1/2*[1, 2] + 1/2*[2, 1]
        sage: epsilon([[1],[2]])
        1/2*[1, 2] - 1/2*[2, 1]
    """
    t = Tableau(tab)

    if star:
        t = t.restrict(t.size() - star)

    mult = permutation_options['mult']
    permutation_options['mult'] = 'l2r'
    
    if t in epsilon_cache:
        res = epsilon_cache[t]
    else:
        if t.size() == 2:
            epsilon_cache[t] = e(t)*(1/kappa(t.shape()))
            res =  epsilon_cache[t]
        elif t == Tableau([[1]]):
            epsilon_cache[t] = e(t)
            res =  epsilon_cache[t]
        else:
            epsilon_cache[t] =  epsilon(t, 1)*e(t)*epsilon(t,1)*( 1 / kappa(t.shape()))
            res = epsilon_cache[t]

    permutation_options['mult'] = mult
    return res
 def construct(self):
     for x in range(4):
         self._freecells.append(FreeCell())
         self._homecells.append(HomePile())
         self._tableaux.append(Tableau())
     for x in range(4):
         self._tableaux.append(Tableau())
Esempio n. 4
0
def epsilon_ik(itab, ktab, star=0):
    """
    EXAMPLES::
    
        sage: from sage.combinat.symmetric_group_algebra import epsilon_ik
        sage: epsilon_ik([[1,2],[3]], [[1,3],[2]])
        1/4*[1, 3, 2] - 1/4*[2, 3, 1] + 1/4*[3, 1, 2] - 1/4*[3, 2, 1]
        sage: epsilon_ik([[1,2],[3]], [[1,3],[2]], star=1)
        Traceback (most recent call last):
        ...
        ValueError: the two tableaux must be of the same shape
    """
    it = Tableau(itab)
    kt = Tableau(ktab)
    if star:
        it = it.restrict(it.size() - star)
        kt = kt.restrict(kt.size() - star)

    if it.shape() != kt.shape():
        raise ValueError, "the two tableaux must be of the same shape"

    mult = permutation_options['mult']
    permutation_options['mult'] = 'l2r'
    if kt == it:
        res = epsilon(itab)
    elif (it, kt) in epsilon_ik_cache:
        res =  epsilon_ik_cache[(it,kt)]
    else:
        epsilon_ik_cache[(it,kt)] = epsilon(it, star+1)*e_ik(it,kt,star)*epsilon(kt, star+1) * (1/kappa(it.shape()))
        res =  epsilon_ik_cache[(it,kt)]

    permutation_options['mult'] = mult
    return res
Esempio n. 5
0
    def check_exist(self, formula, init_states):
        tableau = Tableau(formula, self._atomic_str)
        prod = tableau.product(self._model)

        # return False
        return prod.has_fair_path(tableau.initial_states & init_states,
                                  tableau.fairness_constraints)
Esempio n. 6
0
def run_game():

    # Create deck, hand, tableau.
    deck = Deck()
    hand = Hand(deck)
    tableau = Tableau(tableau_limit)
    trade = Trade()

    game_end = False

    # Main game loop.
    while game_end is False:

        # Choose action.
        # phase = gf.choose_action()

        # Play phases.
        for phase in range(0, 5):
            gf.play_phase(phase, deck, hand, tableau, trade)

        # Check hand limit
        hand.hand_limit(deck)

        # Check for game end.
        game_end = gf.end_check(tableau, scoreboard)

    return scoreboard.get_vp_total(tableau)
Esempio n. 7
0
def e_hat(tab, star=0):
    """
    The Young projection operator, an idempotent in the rational group algebra.

    EXAMPLES::
    
        sage: from sage.combinat.symmetric_group_algebra import e_hat
        sage: e_hat([[1,2,3]])
        1/6*[1, 2, 3] + 1/6*[1, 3, 2] + 1/6*[2, 1, 3] + 1/6*[2, 3, 1] + 1/6*[3, 1, 2] + 1/6*[3, 2, 1]
        sage: e_hat([[1],[2]])
        1/2*[1, 2] - 1/2*[2, 1]

    There are differing conventions for the order of the symmetrizers
    and antisymmetrizers.  This example illustrates our conventions::

        sage: e_hat([[1,2],[3]])
        1/3*[1, 2, 3] + 1/3*[2, 1, 3] - 1/3*[3, 1, 2] - 1/3*[3, 2, 1]
    """
    t = Tableau(tab)
    if star:
        t = t.restrict(t.size()-star)
    if t in ehat_cache:
        res = ehat_cache[t]
    else:
        res = (1/kappa(t.shape()))*e(t)
    return res
Esempio n. 8
0
def e_hat(tab, star=0):
    """
    The Young projection operator corresponding to the Young tableau
    ``tab`` (which is supposed to contain every integer from `1` to
    its size precisely once, but may and may not be standard). This
    is an idempotent in the rational group algebra.

    EXAMPLES::

        sage: from sage.combinat.symmetric_group_algebra import e_hat
        sage: e_hat([[1,2,3]])
        1/6*[1, 2, 3] + 1/6*[1, 3, 2] + 1/6*[2, 1, 3] + 1/6*[2, 3, 1] + 1/6*[3, 1, 2] + 1/6*[3, 2, 1]
        sage: e_hat([[1],[2]])
        1/2*[1, 2] - 1/2*[2, 1]

    There are differing conventions for the order of the symmetrizers
    and antisymmetrizers.  This example illustrates our conventions::

        sage: e_hat([[1,2],[3]])
        1/3*[1, 2, 3] + 1/3*[2, 1, 3] - 1/3*[3, 1, 2] - 1/3*[3, 2, 1]
    """
    t = Tableau(tab)
    if star:
        t = t.restrict(t.size() - star)
    if t in ehat_cache:
        res = ehat_cache[t]
    else:
        res = (1 / kappa(t.shape())) * e(t)
    return res
Esempio n. 9
0
def b(tableau, star=0):
    r"""
    The column projection operator corresponding to the Young tableau
    ``tableau`` (which is supposed to contain every integer from
    `1` to its size precisely once, but may and may not be standard).

    This is the signed sum (in the group algebra of the relevant
    symmetric group over `\QQ`) of all the permutations which
    preserve the column of ``tableau`` (where the signs are the usual
    signs of the permutations). It is called `b_{\text{tableau}}` in
    [EtRT]_, Section 4.2.

    EXAMPLES::

        sage: from sage.combinat.symmetric_group_algebra import b
        sage: b([[1,2]])
        [1, 2]
        sage: b([[1],[2]])
        [1, 2] - [2, 1]
        sage: b([])
        []
        sage: b([[1, 2, 4], [5, 3]])
        [1, 2, 3, 4, 5] - [1, 3, 2, 4, 5] - [5, 2, 3, 4, 1] + [5, 3, 2, 4, 1]

    With the `l2r` setting for multiplication, the unnormalized
    Young symmetrizer ``e(tableau)`` should be the product
    ``b(tableau) * a(tableau)`` for every ``tableau``. Let us check
    this on the standard tableaux of size 5::

        sage: from sage.combinat.symmetric_group_algebra import a, b, e
        sage: all( e(t) == b(t) * a(t) for t in StandardTableaux(5) )
        True
    """
    t = Tableau(tableau)
    if star:
        t = t.restrict(t.size() - star)

    cs = t.column_stabilizer().list()
    n = t.size()

    # This all should be over ZZ, not over QQ, but symmetric group
    # algebras don't seem to preserve coercion (the one over ZZ
    # doesn't coerce into the one over QQ even for the same n),
    # and the QQ version of this method is more important, so let
    # me stay with QQ.
    # TODO: Fix this.
    sgalg = SymmetricGroupAlgebra(QQ, n)
    one = QQ.one()
    P = permutation.Permutation

    # Ugly hack for the case of an empty tableau, due to the
    # annoyance of Permutation(Tableau([]).row_stabilizer()[0])
    # being [1] rather than [] (which seems to have its origins in
    # permutation group code).
    # TODO: Fix this.
    if len(tableau) == 0:
        return sgalg.one()

    cd = dict((P(v), v.sign() * one) for v in cs)
    return sgalg._from_dict(cd)
Esempio n. 10
0
 def __init__(self, strategy, visual=False, screen=None):
     S = getattr(strategies, strategy)
     strategy = S()
     self.tableau = Tableau()
     self.redeals = 2
     self.strategy = strategy
     self.visual = visual
     self.screen = screen
Esempio n. 11
0
def a(tableau, star=0):
    r"""
    The row projection operator corresponding to the Young tableau
    ``tableau`` (which is supposed to contain every integer from
    `1` to its size precisely once, but may and may not be standard).

    This is the sum (in the group algebra of the relevant symmetric
    group over `\QQ`) of all the permutations which preserve
    the rows of ``tableau``. It is called `a_{\text{tableau}}` in
    [EtRT]_, Section 4.2.

    REFERENCES:

    .. [EtRT] Pavel Etingof, Oleg Golberg, Sebastian Hensel, Tiankai
       Liu, Alex Schwendner, Dmitry Vaintrob, Elena Yudovina,
       "Introduction to representation theory",
       :arXiv:`0901.0827v5`.

    EXAMPLES::

        sage: from sage.combinat.symmetric_group_algebra import a
        sage: a([[1,2]])
        [1, 2] + [2, 1]
        sage: a([[1],[2]])
        [1, 2]
        sage: a([])
        []
        sage: a([[1, 5], [2, 3], [4]])
        [1, 2, 3, 4, 5] + [1, 3, 2, 4, 5] + [5, 2, 3, 4, 1] + [5, 3, 2, 4, 1]
    """
    t = Tableau(tableau)
    if star:
        t = t.restrict(t.size() - star)

    rs = t.row_stabilizer().list()
    n = t.size()

    # This all should be over ZZ, not over QQ, but symmetric group
    # algebras don't seem to preserve coercion (the one over ZZ
    # doesn't coerce into the one over QQ even for the same n),
    # and the QQ version of this method is more important, so let
    # me stay with QQ.
    # TODO: Fix this.
    sgalg = SymmetricGroupAlgebra(QQ, n)
    one = QQ.one()
    P = permutation.Permutation

    # Ugly hack for the case of an empty tableau, due to the
    # annoyance of Permutation(Tableau([]).row_stabilizer()[0])
    # being [1] rather than [] (which seems to have its origins in
    # permutation group code).
    # TODO: Fix this.
    if len(tableau) == 0:
        return sgalg.one()

    rd = dict((P(h), one) for h in rs)
    return sgalg._from_dict(rd)
Esempio n. 12
0
    def epsilon_ik(self, itab, ktab, star=0):
        """
        Return the seminormal basis element of ``self`` corresponding to the
        pair of tableaux ``itab`` and ``ktab``.

        EXAMPLES::

            sage: QS3 = SymmetricGroupAlgebra(QQ, 3)
            sage: a = QS3.epsilon_ik([[1,2,3]], [[1,2,3]]); a
            1/6*[1, 2, 3] + 1/6*[1, 3, 2] + 1/6*[2, 1, 3] + 1/6*[2, 3, 1] + 1/6*[3, 1, 2] + 1/6*[3, 2, 1]
            sage: QS3.dft()*vector(a)
            (1, 0, 0, 0, 0, 0)
            sage: a = QS3.epsilon_ik([[1,2],[3]], [[1,2],[3]]); a
            1/3*[1, 2, 3] - 1/6*[1, 3, 2] + 1/3*[2, 1, 3] - 1/6*[2, 3, 1] - 1/6*[3, 1, 2] - 1/6*[3, 2, 1]
            sage: QS3.dft()*vector(a)
            (0, 0, 0, 0, 1, 0)
        """
        it = Tableau(itab)
        kt = Tableau(ktab)

        stn = StandardTableaux_size(self.n)

        if it not in stn:
            raise TypeError("it must be a standard tableau of size %s" %
                            self.n)

        if kt not in stn:
            raise TypeError("kt must be a standard tableau of size %s" %
                            self.n)

        if it.shape() != kt.shape():
            raise ValueError("it and kt must be of the same shape")

        BR = self.base_ring()
        z_elts = {}
        epik = epsilon_ik(it, kt, star=star)
        for m, c in epik._monomial_coefficients.iteritems():
            z_elts[m] = BR(c)
        z = self._from_dict(z_elts)

        if permutation_options['mult'] == 'l2r':
            return z
        else:
            return z.map_support(lambda x: x.inverse())
Esempio n. 13
0
def pi_ik(itab, ktab):
    """
    EXAMPLES::
    
        sage: from sage.combinat.symmetric_group_algebra import pi_ik
        sage: pi_ik([[1,3],[2]], [[1,2],[3]])
        [1, 3, 2]
    """
    it = Tableau(itab)
    kt = Tableau(ktab)

    p = [None]*kt.size()        
    for i in range(len(kt)):
        for j in range(len(kt[i])):
            p[ it[i][j] -1 ] = kt[i][j]

    QSn = SymmetricGroupAlgebra(QQ, it.size())
    p = permutation.Permutation(p)
    return QSn(p)
Esempio n. 14
0
    def _build_tableau(self):
        ncons = self.lp.A_fpi.shape[0]
        opmat = np.vstack((np.zeros((1, ncons)), np.identity(ncons)))
        opmat = np.asmatrix(opmat, np.float64)

        lpmat = np.vstack((np.hstack((self.lp.c_fpi.T * (-1), [[0.0]])),
                           np.hstack((self.lp.A_fpi, self.lp.b_fpi))))
        tableau = np.asmatrix(np.hstack((opmat, lpmat)))

        return Tableau(tableau)
Esempio n. 15
0
 def setUp(self):
     # variables
     pre_var = [(0, True), (0, False), (0, False), (0, True), (0, True)]
     self.vars = [Variable(*v) for v in pre_var]
     # row lines
     pre_row = [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [1, 1, -1, 0, 0],
                [2, -1, 0, -1, 0], [-1, 2, 0, 0, -1]]
     self.rows = [RowLine(r) for r in pre_row]
     # tableau
     self.table = Tableau(self.vars, self.rows)
def print_full_typology(rankings):
    """Print the full set of results: ranking, winner, and winner type."""
    for ranking in rankings:
        constraint_ranking = ConstraintSet(ranking)
        print("----------------------------------")
        print(constraint_ranking)
        print("----------------------------------")
        for inputs in gen.inputs():
            tableau = Tableau(inputs, constraint_ranking,
                              gen.candidates(inputs))
            print(inputs, tableau.winners, tableau.typology)
Esempio n. 17
0
def creation_tableau_joueur(dimension: int, nom_joueur: str):
    """ Fonction servant a creer un objet Tableau et un objet Joueur et attribuer a Joueur le tableau
    PRE:
        - dimension = int
        - nom_joueur = str
    POST :
        - création objet plateau_joueur de classe Tableau(dimension)
        - creation d'un tableau dans l'objet plateau_joueur
        - creation d'un objet Joueur possedant un nom et un objet Tableau
        - retourne l'objet de classe Joueur
    """
    plateau_joueur = Tableau(dimension)
    plateau_joueur.creation_tableau()
    return Joueur(nom_joueur, plateau_joueur)
Esempio n. 18
0
    def get_exists_nodes(self, formula):
        tableau = Tableau(formula, self._atomic_str)
        prod = tableau.product(self._model)
        print('#relations', prod.count_relations())
        print(
            '#reachable states',
            prod.count_reachable_states(tableau.initial_states
                                        & self._model.atomic))

        states = prod.find_fair_nodes(tableau.initial_states,
                                      tableau.fairness_constraints)
        states = bdd_utils.only_consider_prims(states, self._model.msb)
        bdd_utils.print_debug_bdd('states', states)
        return states
Esempio n. 19
0
    def solve(self, verbose = False):
        if verbose:
            print("The input linear program is:\n")
            print("Maximize %s" % vect_vars(self.c))
            print("Such that:")

            for k, row in enumerate(self.A):
                print("\t%s <= %s" % (vect_vars(row), str(self.b[k])))

            print("\t" + ", ".join(["x%i" % (i + 1) for i in range(self.n)]) + " are non-negative\n")

        T = self.T = Tableau(self.c, self.A, self.b, self.pivot)
        phase_one_objective = T.initialize_basis()

        # PHASE 1
        if T.nb_additional_vars > 0:
            if verbose:
                print("=== PHASE 1 ===")
                print("Added %i new positive variables." % T.nb_additional_vars)
                print("Now trying to maximize: %s" % vect_vars(phase_one_objective))

            T.set_objective_vector(phase_one_objective)
            T.phase(verbose)

            if T.opt != 0:
                print("This linear program is INFEASIBLE.")
                self.log()
                return

            else:
                T.remove_additional_vars()
                if verbose:
                    print("Found a basic feasible solution.: %s" % T.get_solution())
                    print("Removed additional variables from the tableau.\n")
                    print("=== PHASE 2 ===")

        # PHASE 2
        T.set_objective_vector(self.c)
        R = T.phase(verbose)

        if R == FeasibleResult.BOUNDED:
            print("This linear problem is FEASIBLE and BOUNDED.")
            print("One optimal solution is: %s" % T.get_solution())
            print("The value of the objective for this solution is: %s" % str(-T.opt))

        else:
            print("This linear problem is FEASIBLE but UNBOUNDED.")

        self.log()
Esempio n. 20
0
def e(tableau, star=0):
    """
    The unnormalized Young projection operator.

    EXAMPLES::
    
        sage: from sage.combinat.symmetric_group_algebra import e
        sage: e([[1,2]])
        [1, 2] + [2, 1]
        sage: e([[1],[2]])
        [1, 2] - [2, 1]

    There are differing conventions for the order of the symmetrizers
    and antisymmetrizers.  This example illustrates our conventions::

        sage: e([[1,2],[3]])
        [1, 2, 3] + [2, 1, 3] - [3, 1, 2] - [3, 2, 1]
    """
    t = Tableau(tableau)
    if star:
        t = t.restrict(t.size()-star)

    mult = permutation_options['mult']
    permutation_options['mult'] = 'l2r'
    
    if t in e_cache:
        res = e_cache[t]
    else:
        rs = t.row_stabilizer().list()
        cs = t.column_stabilizer().list()
        n = t.size()

        QSn = SymmetricGroupAlgebra(QQ, n)
        one = QQ(1)
        P = permutation.Permutation

        rd = dict((P(h), one) for h in rs)
        sym = QSn._from_dict(rd)

        cd = dict((P(v), v.sign()*one) for v in cs)
        antisym = QSn._from_dict(cd)

        res = antisym*sym

        e_cache[t] = res

    permutation_options['mult'] = mult    
    return res
Esempio n. 21
0
def test1():
    print 'Test 1'
    r1 = [2, 1, -2, '<', 8]
    r2 = [4, -1, 2, '>', 2]
    r3 = [2, 3, -1, '>', 4]

    r = list()
    r.append(r1)
    r.append(r2)
    r.append(r3)

    f = [-2, 1, -1]

    tableau = Tableau(f, r)

    simplex = Simplex(tableau)

    simplex.execute()

    print 'Solution: ' + str(simplex.solution)
Esempio n. 22
0
    def _build_aux_tableau(self):
        num_cons = self._tableau.A.shape[0]
        aux_c = np.zeros_like(self._tableau.ct)
        aux_c = np.asmatrix(
            np.hstack((np.zeros((1, num_cons)), aux_c, np.ones(
                (1, num_cons)))), np.float64)
        b_neglines = np.where(float_comp(self._tableau.b, 0.0, less=True))[0]
        opmat = np.asmatrix(np.identity(num_cons), np.float64)
        aux_opA = np.hstack((opmat, self._tableau.A))
        aux_opA[b_neglines, :] = aux_opA[b_neglines, :] * (-1)
        aux_opA = np.hstack((aux_opA, np.identity(aux_opA.shape[0])))
        aux_b = np.copy(self._tableau.b)
        aux_b[b_neglines, :] = aux_b[b_neglines, :] * (-1)

        aux_tab_mat = np.vstack((np.hstack(
            (aux_c, [[0.0]])), np.hstack((aux_opA, aux_b))))

        aux_tab = Tableau(aux_tab_mat)

        return aux_tab
Esempio n. 23
0
def main():

    logging.debug(
        '\n ======================== \n =   Reading Data   = \n ========================'
    )

    vars_and_restrictions = input()
    vars_and_restrictions = vars_and_restrictions.split()

    r = int(vars_and_restrictions[0])
    v = int(vars_and_restrictions[1])

    logging.debug("Number of restrictions: {}".format(r))
    logging.debug("Number of variables: {}".format(v))

    c_input = input()
    c_list = list(c_input.split())
    c = []
    for i in range(len(c_list)):
        c.append(float(c_list[i]))

    logging.debug("Costs vector: {}".format(c))

    a = []
    b = []
    for i in range(r):
        line = input().split()
        a_row = []
        for j in range(len(line)):
            if j < v:
                a_row.append(float(line[j]))
            else:
                b.append(float(line[j]))
        a.append(a_row)

    logging.debug("Matrix A[]: {}".format(a))
    logging.debug("Vector B[]: {}".format(b))

    tableau = Tableau(r, v, c, a, b)
    Tableau.print_tableau(tableau.matrix_tableau)
    Simplex.do_simplex(tableau)
Esempio n. 24
0
def solucaoIlimitada():
    print 'Solucao Ilimitada'
    r1 = [4, 1, '>=', 20]
    r2 = [1, 2, '>=', 10]
    r3 = [1, 0, '>=', 2]

    r = list()
    r.append(r1)
    r.append(r2)
    r.append(r3)

    f = [-1, -2]

    tableau = Tableau(f, r)

    simplex = Simplex(tableau)

    simplex.execute()

    print 'Solution: ' + str(simplex.solution)
    print simplex.tableau
Esempio n. 25
0
def input1():
    print ''
    r1 = [1, 1, '>=', 2]
    r2 = [1, 2, '>=', 5]
    # r3 = [5,3,'<=',15]

    r = list()
    r.append(r1)
    r.append(r2)
    # r.append(r3)

    f = [-1, -1]

    tableau = Tableau(f, r)

    simplex = Simplex(tableau)

    simplex.execute()

    print 'Solution: ' + str(simplex.solution)
    print simplex.tableau
Esempio n. 26
0
def degenerationExample():
    print 'Exemplo de degeneracao'
    r1 = [1, 0, '<=', 3]
    r2 = [0, 1, '<=', 4]
    r3 = [4, 3, '<=', 12]

    r = list()
    r.append(r1)
    r.append(r2)
    r.append(r3)

    f = [-5, -2]

    tableau = Tableau(f, r)

    simplex = Simplex(tableau)

    simplex.execute()

    print 'Solution: ' + str(simplex.solution)
    print simplex.tableau
Esempio n. 27
0
def test6():
    print 'Test 6'
    r1 = [1, 2, 4, -1, '=', 6]
    r2 = [2, 3, -1, 4, '<=', 12]
    r3 = [1, 0, 1, 1, '<=', 4]

    r = list()
    r.append(r1)
    r.append(r2)
    r.append(r3)

    f = [-2, -1, -5, 3]

    tableau = Tableau(f, r)

    simplex = Simplex(tableau)

    simplex.execute()

    print 'Solution: ' + str(simplex.solution)
    print simplex.tableau
Esempio n. 28
0
def test5():
    print 'Test 3'
    r1 = [1, 0, 0, '<', 1]
    r2 = [20, 1, 0, '<', 100]
    r3 = [200, 20, 1, '<', 10000]

    r = list()
    r.append(r1)
    r.append(r2)
    r.append(r3)

    f = [-100, -10, -1]

    tableau = Tableau(f, r)

    simplex = Simplex(tableau)

    simplex.execute()

    print 'Solution: ' + str(simplex.solution)
    print simplex.tableau
Esempio n. 29
0
def test4():
    print 'Test 3'
    r1 = [4, 1, '<', 21]
    r2 = [2, 3, '>', 13]
    r3 = [-1, 1, '=', 1]

    r = list()
    r.append(r1)
    r.append(r2)
    r.append(r3)

    f = [-6, 1]

    tableau = Tableau(f, r)

    simplex = Simplex(tableau)

    simplex.execute()

    print 'Solution: ' + str(simplex.solution)
    print simplex.tableau
Esempio n. 30
0
def test3():
    print 'Test 3'
    r1 = [1, 2, '<', 6]
    r2 = [-2, 1, '<', 4]
    r3 = [5, 3, '<', 15]

    r = list()
    r.append(r1)
    r.append(r2)
    r.append(r3)

    f = [-5, -4]

    tableau = Tableau(f, r)

    simplex = Simplex(tableau)

    simplex.execute()

    print 'Solution: ' + str(simplex.solution)
    print simplex.tableau