当前位置: 首页>>代码示例>>Python>>正文


Python plan.Plan类代码示例

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


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

示例1: __init__

class Person:
  def __init__(self, name, boss_name, score):
    self.name = name
    self.score = score
    self.boss_name = boss_name
    self.children = []
    self.attending_plan_cache = None
    self.not_attending_plan_cache = None

  def add_child(self, child):
    self.children.append(child)

  def attending_plan(self):
    if not self.attending_plan_cache:
      self.attending_plan_cache = Plan(self, True)
      for child in self.children:
        self.attending_plan_cache.merge(child.not_attending_plan())
    return self.attending_plan_cache

  def not_attending_plan(self):
    if not self.not_attending_plan_cache:
      self.not_attending_plan_cache = Plan(self, False)
      for child in self.children:
        self.not_attending_plan_cache.merge(child.best_plan())
    return self.not_attending_plan_cache

  def best_plan(self):
    if self.attending_plan().is_better_than(self.not_attending_plan()):
      return self.attending_plan()
    else:
      return self.not_attending_plan()
开发者ID:nanma80,项目名称:partyPlanning,代码行数:31,代码来源:person.py

示例2: all_plans

def all_plans(plans, configs):
    results = {}
    for planfile in plans:
        print('\n' + (' PLAN %s ' % planfile).center(80, '='))
        Plan.parse(planfile).printtree()
        results[planfile] = all_configs(planfile, configs)
    return results
开发者ID:enricobacis,项目名称:pg-distopt,代码行数:7,代码来源:main.py

示例3: sample_plan

    def sample_plan(self, plan_id, plan_length, rho, views, view_values, view_costs, current_view_id):
        remaining_views = dict()
        for v in views:
            remaining_views[v.ID] = v

         # current_view_id = remaining_views.keys()[0] NOW FUNCTION ARGUMENT

        plan = Plan(plan_id)
        # pmf for values
        value_pmf = self._generate_value_pmf(view_values)
        # pmf for costs
        cost_pmf = self._generate_cost_pmf(current_view_id, remaining_views.keys(), rho, view_costs)
        # joint dist
        joint = make_joint(value_pmf, cost_pmf)
        joint.normalize()

        for j in range(plan_length):
            x = joint.random()
            plan.append(remaining_views[x])
            remaining_views.pop(x)

            # sample without replacement
            # adapt both pmfs: value and cost
            value_pmf.unset(x)
            value_pmf.normalize()

            cost_pmf = self._generate_cost_pmf(x, remaining_views.keys(), rho, view_costs)
            # re-generate joint dist
            joint = make_joint(value_pmf, cost_pmf)
            joint.normalize()
        return plan
开发者ID:kunzel,项目名称:viper,代码行数:31,代码来源:planner.py

示例4: CreatePlan

def CreatePlan(command):
    """
    创建指定命令任务
    :param command:
    :return:
    """
    cron = Plan(command)
    cron.command('node ' + path + '/index.js ' + command, every='1.day', at='16:51')
    cron.run('write')
开发者ID:csvwolf,项目名称:Sky_WeiboServices,代码行数:9,代码来源:script.py

示例5: DestroyPlan

def DestroyPlan(command):
    """
    取消指定任务
    :param command:
    :return:
    """
    cron = Plan(command)
    # cron.command('node index.js', every='1.day', at='16:19')
    cron.run('clear')
开发者ID:csvwolf,项目名称:Sky_WeiboServices,代码行数:9,代码来源:script.py

示例6: random_plan

    def random_plan(self):
        p = Plan()

        # Choose start condition AND INSTANTIATE IT:
        start_condition = random.choice(p.Conditionals)()
        start_condition.height = 1

        p.action = start_condition
        p.this_conditionals.append(start_condition)


        done = False
        while not done:
            done = True

            # Update conditionals if not marked (marked = already dealt with)
            # and stop when hitting the max depth
            for c in p.this_conditionals:
                if c.marked == 0:
                    done = False
                    c.marked = 1

                    # Add a random expression:
                    expression = random.choice(p.Expressions)()
                    expression.obs1 = random.choice(p.Observations)
                    expression.obs2 = random.choice(p.Observations)
                    expression.depth = c.depth + 1
                    expression.marked = 1
                    expression.set_map(p)
                    c.expression = expression

                    #  Must add terminal actions if we hit the max depth (minus 2)
                    if c.depth == self.max-2:
                        for key in c.options.keys():
                            axn = random.choice(p.Actions)
                            axn.depth = c.depth + 1
                            c.options[key] = axn

                    # Otherwise, we can add either a terminal action OR another conditional:
                    else:
                        for key in c.options.keys():
                            condition_or_action = random.random()
                            if condition_or_action < .5:
                                new_c = random.choice(p.Conditionals)()
                                new_c.depth = c.depth + 1
                                c.options[key] = new_c
                                p.this_conditionals.append(new_c)
                            else:
                                c.options[key] = random.choice(p.Actions)

        return p
开发者ID:jtcb,项目名称:flock,代码行数:51,代码来源:evolve.py

示例7: single

def single(planfile, configfile):
    plan, config = Plan.parse(planfile), Config.parse(configfile)
    distplan = best(plan, config)
    cost = distplan.cost(dest=config['CL1'])
    print('Best cost:', cost)
    distplan.printtree(dest=config['CL1'])
    return cost
开发者ID:enricobacis,项目名称:pg-distopt,代码行数:7,代码来源:main.py

示例8: plan_direct

def plan_direct(queue, code, init, Xname, X, Y, tag=None):
    from . import ast_conversion

    assert len(X) == len(Y)
    N = len(X)

    text = """
        ////////// MAIN FUNCTION //////////
        __kernel void fn(
            __global const int *${IN}starts,
            __global const ${INtype} *${IN}data,
            __global const int *${OUT}starts,
            __global ${OUTtype} *${OUT}data
        )
        {
            const int n = get_global_id(0);
            if (n >= ${N}) return;

            __global const ${INtype} *${arg} = ${IN}data + ${IN}starts[n];
            __global ${OUTtype} *${OUT} = ${OUT}data + ${OUT}starts[n];

            /////vvvvv USER DECLARATIONS BELOW vvvvv
${init}

            /////vvvvv USER COMPUTATIONS BELOW vvvvv
${code}
            // END OF FUNC: put nothing after user code, since it can return
        }
        """

    textconf = dict(init=_indent(init, 12),
                    code=_indent(code, 12), N=N, arg=Xname,
                    IN=ast_conversion.INPUT_NAME, INtype=X.cl_buf.ocldtype,
                    OUT=ast_conversion.OUTPUT_NAME, OUTtype=Y.cl_buf.ocldtype,
                    )
    text = Template(text, output_encoding='ascii').render(**textconf)

    full_args = (X.cl_starts, X.cl_buf, Y.cl_starts, Y.cl_buf)
    _fn = cl.Program(queue.context, text).build().fn
    _fn.set_args(*[arr.data for arr in full_args])

    gsize = (N,)
    rval = Plan(queue, _fn, gsize, lsize=None, name="cl_direct", tag=tag)
    rval.full_args = full_args     # prevent garbage-collection
    return rval
开发者ID:bptripp,项目名称:nengo_ocl,代码行数:45,代码来源:clra_nonlinearities.py

示例9: __init__

    def __init__(self, game, y, x):
        """Initialise the player object"""
        super(NPC, self).__init__(game)
        self.y = y
        self.x = x
        self.colour = Constants.COLOUR_WHITE
        self.path = []
        self.square = None
        self.plan = Plan(self)
        self.currentBehaviour = DefaultBehaviour(self)
        self.alive = True
        self.killer = False

        self.dialogue = dialogue.Dialogue(self)
        standardDialogueChoice1 = dialogue.DialogueChoice("Hello!", 
                                                          "Hello to you too!")
        standardDialogueChoice2 = dialogue.DialogueChoice("My name is Kate!", 
                                                          "Fascinating.")
        def responseFunction3(npc, response):
            npc.game.player.notebook.addToKnownNpcs(self)
            actualResponse = "My name is " + npc.firstName + " " + npc.lastName
            actualResponse += ". I live in house number " + str(npc.square.house.number)
            actualResponse += "."
            return actualResponse
        standardDialogueChoice3 = dialogue.DialogueChoice("Who are you?", 
                                                          "",
                                                          responseFunction3)

        standardDialogueChoice4 = dialogue.DialogueChoice("No, hello to YOU!", 
                                                          "We're done talking, freakshow.")
        secondNode = dialogue.DialogueNode()
        secondNode.addChoice(standardDialogueChoice4)

        choicePredicate3 = lambda: not self.game.player.notebook.isNpcKnown(self)
        dialogueRoot = dialogue.DialogueNode()
        dialogueRoot.addChoice(standardDialogueChoice1, None, secondNode)
        dialogueRoot.addChoice(standardDialogueChoice2)
        dialogueRoot.addChoice(standardDialogueChoice3, choicePredicate3)
        self.dialogue.setRootNode(dialogueRoot)

        # Fluffy, plot stuff
        self.gender = random.choice([Gender.MALE, Gender.FEMALE])
        self.firstName = "Dave"
        if self.gender == Gender.MALE:
            self.firstName = names.getMaleFirstName()
        else:
            self.firstName = names.getFemaleFirstName()
        self.lastName = names.getLastName()

        self.eyeColour = random.choice(["green", "blue", "brown"])
        self.hairColour = random.choice(["brown", "red", "blonde"])
        self.description = "They have " + self.eyeColour + " eyes and " + self.hairColour + " hair."

        # Emotions and states
        # TODO: Something with this?
        self.scared = False
        self.answeringDoor = False
开发者ID:mjdarby,项目名称:RogueDetective,代码行数:57,代码来源:entity.py

示例10: Plan

# Use this file to easily define all of your cron jobs.
#
# It's helpful to understand cron before proceeding.
# http://en.wikipedia.org/wiki/Cron
#
# Learn more: http://github.com/fengsp/plan

import os
from os.path import join as pjoin
from plan import Plan

dir_path = os.path.dirname(os.path.realpath(__file__))

cron = Plan(
    "scripts",
    path=pjoin(dir_path, '../scrape'),
    environment={'DJANGO_SETTINGS_MODULE': 'scrape.settings_production'}
)

# register one command, script or module
#  cron.command('command', every='1.day')
#  cron.script('script.py', path='/web/yourproject/scripts', every='1.month')
#  cron.module('calendar', every='feburary', at='day.3')

cron.command('cd %s && DJANGO_SETTINGS_MODULE=scrape.settings_production $HOME/venv/bin/scrapy crawl eoaient' % (pjoin(dir_path, '../scrape/crawler')),
    every='2.day', at='minute.48')
cron.command('cd %s && DJANGO_SETTINGS_MODULE=scrape.settings_production $HOME/venv/bin/scrapy crawl ck0tp' % (pjoin(dir_path, '../scrape/crawler')),
    every='3.day', at='minute.12')

cron.script('manage.py extoon_info', every='5.hour', at='minute.30')
cron.script('manage.py extoon_description', every='6.hour', at='minute.15')
开发者ID:ikeikeikeike,项目名称:scrape-django-app,代码行数:31,代码来源:extoon.py

示例11: not_attending_plan

 def not_attending_plan(self):
   if not self.not_attending_plan_cache:
     self.not_attending_plan_cache = Plan(self, False)
     for child in self.children:
       self.not_attending_plan_cache.merge(child.best_plan())
   return self.not_attending_plan_cache
开发者ID:nanma80,项目名称:partyPlanning,代码行数:6,代码来源:person.py

示例12: Plan

# Copyright 2014 CourseApp.me All rights reserved
#
# Authors: Paul D'Amora
# run.py runs entirely independent of flask and courseapp as a whole
# it simply write schedule.py to crontab which will contain all periodic tasks

from plan import Plan

cron = Plan()

# Add this script to the cron object and run it every 10 minutes
#cron.script('schedule.py', every='10.minute')

# This file needs to be ran from the terminal
# cron.run takes a bunch of different options
if __name__ == '__main__':
    cron.run('write') # could be 'check', 'write', 'update', 'clear'
开发者ID:pmdamora,项目名称:CourseApp,代码行数:17,代码来源:run.py

示例13: usage

        if opt == '-h':
            usage()

        if opt in ('-o', '--output'):
            output_path = val

        if opt in ('-p', '--pool'):
            pool_path = val

        if opt == "--bootstrap":
            if not os.path.isdir(val):
                fatal("directory does not exist (%s)" % val)

            bootstrap_path = val

    plan = Plan(pool_path=pool_path)
    if bootstrap_path:
        bootstrap_packages = set(iter_packages(bootstrap_path))
        plan |= bootstrap_packages

        for package in bootstrap_packages:
            plan.packageorigins.add(package, 'bootstrap')

    for arg in args:
        if arg == "-" or os.path.exists(arg):
            subplan = Plan.init_from_file(arg, cpp_opts, pool_path)
            plan |= subplan

            for package in subplan:
                plan.packageorigins.add(package, arg)
开发者ID:Dude4Linux,项目名称:fab,代码行数:30,代码来源:cmd_plan_resolve.py

示例14: receivePlanSyncResponse

    def receivePlanSyncResponse(self, sender, otherPlan):
        """callback for the plan synchronisation"""
        with self.mutex:
            myID = self.plan.ids[-1]
            otherID = otherPlan["ID"]["value"]
            if myID == otherID:
                return

            logger.info("I'm executing plan %s. %s is executing %s" % (self.plan.ids, sender, otherPlan["ID"]))
            
            if self.newPlanToImport is not None:
                newID = json.loads(self.newPlanToImport)["ID"]["value"]
                if newID != otherID:
                    logger.warning("I'm executing %s. I received a new plan %s and a previous plan %s. Ignoring this one" % (myID,otherID,newID))
                else:
                    logger.info("Ignoring this plan since I have already ask for its use")
                return

            if myID in otherPlan["ID"]["parents"]:
                logger.info("The other has repaired and I was not notified. I need to update my plan")
                
                agents = set([a["agent"] for a in otherPlan["actions"].values() if "agent" in a])
                
                logger.info("List of agents in this plan : %s " % agents)
                plansDict = {}
                
                #Prevent the removal of coms time
                otherPlan["current-time"] = (time.time() - self.beginDate)
                p = Plan(json.dumps(otherPlan), self.agent)
                
                #Check that all my communications are still in the plan
                droppedComs = set() #In my current plan
                foreignDroppedCom = set() #In the remote plan
                
                for k,a in self.plan.actions.items():
                    if a["agent"] == self.agent:
                        if k in p.actions and a["name"] == p.actions[k]["name"]:
                            continue #Ok, my action is still here
                        elif k not in p.actions and "communicate" in a["name"]:
                            #self.dropCommunication(a["name"])
                            droppedComs.add(a["name"])
                        else:
                            logger.error("My action %s (%s) is not in the new plan" % (a["name"],k))
                
                for k,a in p.actions.items():
                    if a["agent"] == self.agent:
                        if k in self.plan.actions and a["name"] == self.plan.actions[k]["name"]:
                            continue #Ok, my action is still here
                        if "communicate-meta" in a["name"]:
                            comName = a["name"]
                            if comName in self.droppedComs or a["name"]:
                                #I already dropped this com.
                                logger.warning("They kept a com that I dropped %s (%s)" % (a["name"],k))
                                foreignDroppedCom.add(k)
                            else:
                                logger.error("They added an com action for me %s (%s)" % (a["name"],k))
                                logger.error("%s not in %s" % (comName, self.droppedComs))
                        else:
                            logger.error("They added an action for me %s (%s)" % (a["name"],k))
                            for k1,a1 in self.plan.actions.items():
                                if a1["name"] == a["name"]: logger.error("I have this action with key %s" % k1)
                
                for k,a in self.plan.actions.items():
                    if "communicate-meta" in a["name"] and k not in p.actions:
                        droppedComs.add(a["name"])
                
                for c in droppedComs:
                    self.dropCommunication(c)
                
                if foreignDroppedCom:
                    logger.info("Imported plan before removing a foreign com: %s" % json.dumps(otherPlan))
    
                    for c in foreignDroppedCom:
                        logger.info("Removing action %s (%s)" % (otherPlan["actions"][c], c))
                        logger.info("Length before %s" % len(otherPlan["actions"]))
                        otherPlan = Plan.removeAction(otherPlan, c) #remove the com meta for actions that I dropped
                        logger.info("Length after %s" % len(otherPlan["actions"]))

                    logger.info("Imported plan after removing a foreign com: %s" % json.dumps(otherPlan))
                    p = Plan(json.dumps(otherPlan), self.agent)
                
                for a in agents:
                    if a != self.agent:
                        plansDict[a] = p.getLocalJsonPlan(a)
                plansDict[self.agent] = self.plan.getLocalJsonPlan(self.agent, currentTime=(time.time() - self.beginDate))
                p = Plan.mergeJsonPlans(plansDict, idAgent = sender)
                p["current-time"] = plansDict[self.agent]["current-time"]
                
                # See if the plan is still temporally valid. It could be a problem if I added a ub for a com
                # while the other robot was late : both constraints are problematic. In this case, drop my
                # current com or the com of the other robot
                try:
                    _ = Plan(json.dumps(p), self.agent)
                except PlanImportError as e:
                    logger.warning("The fused plan will not be valid. Try to drop a current com")
                    for action in p["actions"].values():
                    #for name,_,_ in self.ongoingActions:
                        name = action["name"]
                        if self.agent not in name: continue
                        #if not (action["startTp"] in p["absolute-time"] and not action["endTp"] in p["absolute-time"]):continue
#.........这里部分代码省略.........
开发者ID:lesire,项目名称:metal,代码行数:101,代码来源:supervisor_ros.py

示例15: Plan

from plan import Plan


cron = Plan(__name__)

cron.script('test', every='5.minute')

cron.run('update')
开发者ID:MikeMouse,项目名称:gt_g_apps,代码行数:8,代码来源:test_plan.py


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