• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python dd.BDD类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pynusmv.dd.BDD的典型用法代码示例。如果您正苦于以下问题:Python BDD类的具体用法?Python BDD怎么用?Python BDD使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了BDD类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: caw

def caw(fsm, agents, phi, psi):
    """
    Return the set of states of fsm satisfying [agents][phi W psi].
    
    fsm -- a MAS representing the system
    agents -- a list of agents names
    phi -- a BDD representing the set of states of fsm satisfying phi
    psi -- a BDD representing the set of states of fsm satisfying psi
    """
    if len(fsm.fairness_constraints) == 0:
        return fp(lambda Z: psi | (phi & fsm.pre_nstrat(Z, agents)), BDD.true(fsm.bddEnc.DDmanager))
    else:

        def inner(Z):
            res = phi
            for f in fsm.fairness_constraints:
                res = res & fsm.pre_nstrat(
                    fp(
                        lambda Y: (psi & fair_gamma_states(fsm, agents)) | (Z & f) | (phi & fsm.pre_nstrat(Y, agents)),
                        BDD.false(fsm.bddEnc.DDmanager),
                    ),
                    agents,
                )
            return (psi & fair_gamma_states(fsm, agents)) | res

        return fp(inner, BDD.true(fsm.bddEnc.DDmanager))
开发者ID:sbusard,项目名称:pynusmv,代码行数:26,代码来源:eval.py


示例2: ceu

def ceu(fsm, agents, phi, psi, strat=None):
    """
    Return the set of states of strat satisfying <agents>[phi U psi]
    under full observability in strat.
    If strat is None, strat is considered true.
    
    fsm -- a MAS representing the system
    agents -- a list of agents names
    phi -- a BDD representing the set of states of fsm satisfying phi
    psi -- a BDD representing the set of states of fsm satisfying psi
    strat -- a BDD representing allowed state/inputs pairs, or None
    
    """
    
    if len(fsm.fairness_constraints) == 0:
        return fp(lambda Z : psi | (phi & fsm.pre_strat(Z, agents, strat)),
                  BDD.false(fsm.bddEnc.DDmanager))
    else:
        nfair = nfair_gamma(fsm, agents, strat)
        def inner(Z):
            res = psi
            for f in fsm.fairness_constraints:
                nf = ~f
                res = res | fsm.pre_strat(fp(lambda Y :
                                             (phi | psi | nfair) &
                                             (Z | nf) &
                                             (psi |
                                              fsm.pre_strat(Y, agents, strat)),
                                             BDD.true(fsm.bddEnc.DDmanager)),
                                              agents, strat)
            return (psi | phi | nfair) & res
        return fp(inner, BDD.false(fsm.bddEnc.DDmanager))
开发者ID:ancailliau,项目名称:pynusmv,代码行数:32,代码来源:eval.py


示例3: check_free_choice

 def check_free_choice(self):
     """
     Check whether this MAS satisfies the free-choice property, that is,
     in every state, the choices of actions for each agent is not
     constrained by the choices of other agents.
     
     Return the set of moves that are not present in the MAS and should,
     or that are present but should not.
     """
     
     if len(self.agents) <= 0:
         return BDD.false(self.bddEnc.DDmanager)
     
     true = BDD.true(self.bddEnc.DDmanager)
     protocols = {agent: self.protocol({agent}) for agent in self.agents}
     enabled = (self.weak_pre(self.reachable_states) &
                self.reachable_states & self.bddEnc.statesInputsMask)
     
     for s in self.pick_all_states(self.reachable_states):
         product = self.bddEnc.statesInputsMask
         for agent in self.agents:
             product &= protocols[agent] & s
         if (enabled & s) != product:
             return product.xor(enabled & s)
     return BDD.false(self.bddEnc.DDmanager)
开发者ID:xgillard,项目名称:pynusmv,代码行数:25,代码来源:mas.py


示例4: nfair_gamma_si

def nfair_gamma_si(fsm, agents, strat=None):
    """
    Return the set of state/inputs pairs of strat
    in which agents can avoid a fair path in strat.
    If strat is None, it is considered true.
    
    fsm -- the model
    agents -- a list of agents names
    strat -- a BDD representing allowed state/inputs pairs, or None
    
    """
    if not strat:
        strat = BDD.true(fsm.bddEnc.DDmanager)
    
    if len(fsm.fairness_constraints) == 0:
        return BDD.false(fsm.bddEnc.DDmanager)
    else:
        def inner(Z):
            res = BDD.false(fsm.bddEnc.DDmanager)
            for f in fsm.fairness_constraints:
                nf = ~f & fsm.bddEnc.statesMask & strat
                res = res | fsm.pre_strat_si(fp(lambda Y :
                                                 (Z | nf) &
                                                 fsm.pre_strat_si(Y, agents,
                                                                  strat),
                                             BDD.true(fsm.bddEnc.DDmanager)),
                                             agents, strat)
            return res
        return fp(inner, BDD.false(fsm.bddEnc.DDmanager))
开发者ID:xgillard,项目名称:pynusmv,代码行数:29,代码来源:evalMem.py


示例5: check_cex

 def check_cex(self, fsm, explanation, agents, phi):
     """Check that the explanation is correct."""
     # Get the cubes
     gamma_cube = fsm.inputs_cube_for_agents(agents)
     ngamma_cube = fsm.bddEnc.inputsCube - gamma_cube
     
     # The first state satisfies the spec
     self.assertTrue(explanation.state <= cex(fsm, agents, phi))
     acts = BDD.false(fsm.bddEnc.DDmanager)
     states = BDD.false(fsm.bddEnc.DDmanager)
     for (act, succ) in explanation.successors:
         ag_action = act.forsome(ngamma_cube)
         # The successor satisfies phi
         self.assertTrue(succ.state <= phi)
         # The action is effectively possible
         self.assertTrue(act <= fsm.get_inputs_between_states(
                                              explanation.state, succ.state))
         # Accumulate states and actions
         acts = acts | act
         states = states | succ.state
     
     # The reached states are effectively the reachable states
     # through the action
     self.assertTrue(states <= fsm.post(explanation.state, ag_action))
     self.assertTrue(states >= fsm.post(explanation.state, ag_action)
                                                     & fsm.bddEnc.statesMask)
                                                     
     # The actions are effectively all the possible actions completing ag_act
     self.assertTrue(acts <= ag_action)
     self.assertTrue(acts >= ag_action & 
                   fsm.get_inputs_between_states(explanation.state, states) &
                   fsm.bddEnc.inputsMask)
开发者ID:ancailliau,项目名称:pynusmv,代码行数:32,代码来源:testExplain.py


示例6: nfair_gamma_states

def nfair_gamma_states(fsm, agents):
    """
    Return the set of states in which agents cann avoid fair paths.
    
    fsm -- the model
    agents -- a list of agents names
    """
    # NFair_Gamma = not([Gamma] G True) = <Gamma> F False
    agents = frozenset(agents)
    if agents not in __nfair_gamma_states:
        if len(fsm.fairness_constraints) == 0:
            __nfair_gamma_states[agents] = BDD.false(fsm.bddEnc.DDmanager)
        else:

            def inner(Z):
                res = BDD.false(fsm.bddEnc.DDmanager)
                for f in fsm.fairness_constraints:
                    nf = ~f  # & fsm.bddEnc.statesMask
                    res = res | fsm.pre_strat(
                        fp(lambda Y: (Z | nf) & fsm.pre_strat(Y, agents), BDD.true(fsm.bddEnc.DDmanager)), agents
                    )
                return res

            __nfair_gamma_states[agents] = fp(inner, BDD.false(fsm.bddEnc.DDmanager))
    return __nfair_gamma_states[agents]
开发者ID:sbusard,项目名称:pynusmv,代码行数:25,代码来源:eval.py


示例7: check_cax

 def check_cax(self, fsm, explanation, agents, phi):
     """Check that the explanation is correct."""
     # Get the cubes
     gamma_cube = fsm.inputs_cube_for_agents(agents)
     ngamma_cube = fsm.bddEnc.inputsCube - gamma_cube
     
     # The first state satisfies the spec
     self.assertTrue(explanation.state <= ~cex(fsm, agents, ~phi))
     acts = BDD.false(fsm.bddEnc.DDmanager)
     states = BDD.false(fsm.bddEnc.DDmanager)
     for (act, succ) in explanation.successors:
         # The successor satisfies phi
         self.assertTrue(succ.state <= phi)
         # The action is effectively possible
         self.assertTrue(act <= fsm.get_inputs_between_states(
                                              explanation.state, succ.state))
         # Accumulate states and actions
         acts = acts | act
         states = states | succ.state
     
     # The actions are effectively all the possible ones
     self.assertEqual((fsm.protocol(agents) &
                       explanation.state).forsome(fsm.bddEnc.statesCube).
                       forsome(ngamma_cube) &
                      fsm.bddEnc.statesMask,
                      acts.forsome(ngamma_cube) & fsm.bddEnc.statesMask)
开发者ID:ancailliau,项目名称:pynusmv,代码行数:26,代码来源:testExplain.py


示例8: ceu

def ceu(fsm, agents, phi, psi):
    """
    Return the set of states of fsm satisfying <agents>[phi U psi].
    
    fsm -- a MAS representing the system
    agents -- a list of agents names
    phi -- a BDD representing the set of states of fsm satisfying phi
    psi -- a BDD representing the set of states of fsm satisfying psi
    """
    # phi = phi & fsm.bddEnc.statesInputsMask
    # psi = psi & fsm.bddEnc.statesInputsMask

    if len(fsm.fairness_constraints) == 0:
        return fp(lambda Z: psi | (phi & fsm.pre_strat(Z, agents)), BDD.false(fsm.bddEnc.DDmanager))
    else:
        nfair = nfair_gamma_states(fsm, agents)

        def inner(Z):
            res = psi
            for f in fsm.fairness_constraints:
                nf = ~f  # & fsm.bddEnc.statesMask
                res = res | fsm.pre_strat(
                    fp(
                        lambda Y: (phi | psi | nfair) & (Z | nf) & (psi | fsm.pre_strat(Y, agents)),
                        BDD.true(fsm.bddEnc.DDmanager),
                    ),
                    agents,
                )
            return (psi | phi | nfair) & res

        return fp(inner, BDD.false(fsm.bddEnc.DDmanager))
开发者ID:sbusard,项目名称:pynusmv,代码行数:31,代码来源:eval.py


示例9: test_get_false

 def test_get_false(self):
     (fsm, enc, manager) = self.init_model()
     
     false = BDD.false(manager)
     self.assertIsNotNone(false)
     self.assertTrue(false.is_false())
     self.assertFalse(false.is_true())
     self.assertTrue(false.isnot_true())
     self.assertFalse(false.isnot_false())
     self.assertTrue(false.isnot_true())
     
     false = BDD.false()
     self.assertIsNotNone(false)
     self.assertTrue(false.is_false())
     self.assertFalse(false.is_true())
     self.assertTrue(false.isnot_true())
     self.assertFalse(false.isnot_false())
     self.assertTrue(false.isnot_true())
     
     false = BDD.false()
     self.assertIsNotNone(false)
     self.assertTrue(false.is_false())
     self.assertFalse(false.is_true())
     self.assertTrue(false.isnot_true())
     self.assertFalse(false.isnot_false())
     self.assertTrue(false.isnot_true())
开发者ID:xgillard,项目名称:pynusmv,代码行数:26,代码来源:testBDD.py


示例10: eg

def eg(fsm, phi):
    """
    Return the set of states of fsm satisfying EG phi.
    
    fsm -- a MAS representing the system
    phi -- a BDD representing the set of states of fsm satisfying phi
    """
    # def inner(Z):
    #    res = Z
    #    for f in fsm.fairness_constraints:
    #        res = res & fp(lambda Y : (Z & f) | (phi & fsm.weak_pre(Y)),
    #                             BDD.false(fsm.bddEnc.DDmanager))
    #    return phi & fsm.weak_pre(res)
    #
    # r = fp(inner, BDD.true(fsm.bddEnc.DDmanager))
    # return r.forsome(fsm.bddEnc.inputsCube)

    phi = phi.forsome(fsm.bddEnc.inputsCube) & fsm.bddEnc.statesMask

    if len(fsm.fairness_constraints) == 0:
        return fp(lambda Z: phi & fsm.pre(Z), BDD.true(fsm.bddEnc.DDmanager)).forsome(fsm.bddEnc.inputsCube)
    else:

        def inner(Z):
            res = phi
            for f in fsm.fairness_constraints:
                res = res & fsm.pre(fp(lambda Y: (Z & f) | (phi & fsm.pre(Y)), BDD.false(fsm.bddEnc.DDmanager)))
            return res

        return fp(inner, BDD.true(fsm.bddEnc.DDmanager)).forsome(fsm.bddEnc.inputsCube)
开发者ID:sbusard,项目名称:pynusmv,代码行数:30,代码来源:eval.py


示例11: eg

def eg(fsm, phi):
    res = BDD.true(fsm.bddEnc.DDmanager)
    old = BDD.false(fsm.bddEnc.DDmanager)
    while res != old:
        old = res
        new = ex(fsm, res)
        res = res & new & phi & fsm.reachable_states
    return res
开发者ID:ancailliau,项目名称:pynusmv,代码行数:8,代码来源:eval.py


示例12: inner

 def inner(Z):
     res = BDD.false(fsm.bddEnc.DDmanager)
     for f in fsm.fairness_constraints:
         nf = ~f  # & fsm.bddEnc.statesMask
         res = res | fsm.pre_strat(
             fp(lambda Y: (Z | nf) & fsm.pre_strat(Y, agents), BDD.true(fsm.bddEnc.DDmanager)), agents
         )
     return res
开发者ID:sbusard,项目名称:pynusmv,代码行数:8,代码来源:eval.py


示例13: test_init

 def test_init(self):
     fsm = self.init_model()
     manager = fsm.bddEnc.DDmanager
     init = fsm.init
     
     initState = fsm.pick_one_state(init)
     
     self.assertTrue(BDD.false(manager) <= init <= BDD.true(manager))
     self.assertTrue(BDD.false(manager) < initState <= init)
开发者ID:ancailliau,项目名称:pynusmv,代码行数:9,代码来源:testExplain.py


示例14: test_true_false_equalities

 def test_true_false_equalities(self):
     (fsm, enc, manager) = self.init_model()
     
     true = BDD.true(manager)
     false = BDD.false(manager)
     
     self.assertTrue(false != true)        
     self.assertFalse(false == true)
     self.assertTrue(false == false)
     self.assertTrue(true == true)
     self.assertTrue((false != true) == (not false == true))
开发者ID:xgillard,项目名称:pynusmv,代码行数:11,代码来源:testBDD.py


示例15: eval_strat_FSF

def eval_strat_FSF(fsm, spec):
    """
    Return the BDD representing the set of states of fsm satisfying spec.
    spec is a strategic operator <G> pi.
    
    Implement a variant of the algorithm that
    filters, splits and then filters.
    
    fsm -- a MAS representing the system;
    spec -- an AST-based ATLK specification with a top strategic operator.
    
    """
    
    if type(spec) is CAX:
        # [g] X p = ~<g> X ~p
        newspec = CEX(spec.group, Not(spec.child))
        return ~eval_strat_FSF(fsm, newspec)
        
    elif type(spec) is CAG:
        # [g] G p = ~<g> F ~p
        newspec = CEF(spec.group, Not(spec.child))
        return ~eval_strat_FSF(fsm, newspec)
        
    elif type(spec) is CAU:
        # [g][p U q] = ~<g>[ ~q W ~p & ~q ]
        newspec = CEW(spec.group,
                      Not(spec.right),
                      And(Not(spec.left), Not(spec.right)))
        return ~eval_strat_FSF(fsm, newspec)
        
    elif type(spec) is CAF:
        # [g] F p = ~<g> G ~p
        newspec = CEG(spec.group, Not(spec.child))
        return ~eval_strat_FSF(fsm, newspec)
        
    elif type(spec) is CAW:
        # [g][p W q] = ~<g>[~q U ~p & ~q]
        newspec = CEU(spec.group,
                      Not(spec.right),
                      And(Not(spec.left), Not(spec.right)))
        return ~eval_strat_FSF(fsm, newspec)
        
        
    sat = BDD.false(fsm.bddEnc.DDmanager)
    agents = {atom.value for atom in spec.group}
    
    # First filtering
    winning = filter_strat(fsm, spec, variant="FSF")
    
    if winning.is_false(): # no state/inputs pairs are winning => return false
        return winning
    
    return split_eval(fsm, spec, BDD.false(fsm.bddEnc.DDmanager),
                      winning)
开发者ID:ancailliau,项目名称:pynusmv,代码行数:54,代码来源:evalOpt.py


示例16: test_true_false_xor

 def test_true_false_xor(self):
     (fsm, enc, manager) = self.init_model()
     
     true = BDD.true(manager)
     false = BDD.false(manager)
     init = fsm.init
     
     self.assertTrue(true ^ false == true)
     self.assertTrue(true ^ true == false)
     self.assertTrue(false ^ false == false)
     self.assertTrue(init ^ true == ~init)
     self.assertTrue(init ^ false == init)
开发者ID:xgillard,项目名称:pynusmv,代码行数:12,代码来源:testBDD.py


示例17: test_true_false_not

 def test_true_false_not(self):
     (fsm, enc, manager) = self.init_model()
     
     true = BDD.true(manager)
     false = BDD.false(manager)
     init = fsm.init
     
     self.assertTrue(~true == -true)
     self.assertTrue(~false == -false)
     self.assertTrue(~true == false)
     self.assertTrue(~false == true)
     self.assertTrue(false < ~init < true)
开发者ID:xgillard,项目名称:pynusmv,代码行数:12,代码来源:testBDD.py


示例18: test_dup

 def test_dup(self):
     (fsm, enc, manager) = self.init_model()
     
     false = BDD.false(manager)
     true = BDD.true(manager)
     init = fsm.init
     
     self.assertEqual(false, false.dup())
     self.assertEqual(true, true.dup())
     self.assertEqual(init, init.dup())
     
     self.assertNotEqual(true, init.dup())
     self.assertNotEqual(init, false.dup())
开发者ID:xgillard,项目名称:pynusmv,代码行数:13,代码来源:testBDD.py


示例19: test_true_false_and

 def test_true_false_and(self):
     (fsm, enc, manager) = self.init_model()
     
     true = BDD.true(manager)
     false = BDD.false(manager)
     init = fsm.init
     
     self.assertTrue((true & false) == (true * false))
     self.assertTrue(true & false == false)
     self.assertTrue(true & true == true)
     self.assertTrue(false & false == false)
     self.assertTrue(init & true == init)
     self.assertTrue(init & false == false)
开发者ID:xgillard,项目名称:pynusmv,代码行数:13,代码来源:testBDD.py


示例20: test_init_equalities

 def test_init_equalities(self):
     (fsm, enc, manager) = self.init_model()
     
     true = BDD.true(manager)
     false = BDD.false(manager)
     init = fsm.init
     
     self.assertIsNotNone(init)
     
     self.assertTrue(init != true)
     self.assertTrue(init != false)
     self.assertFalse(init == true)
     self.assertFalse(init == false)
开发者ID:xgillard,项目名称:pynusmv,代码行数:13,代码来源:testBDD.py



注:本文中的pynusmv.dd.BDD类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python fsm.BddFsm类代码示例发布时间:2022-05-27
下一篇:
Python expression.Be类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap