def create_small_bw_task(): lang = generate_small_fstrips_bw_language() init = tarski.model.create(lang) b1, b2, b3, b4, clear, loc, table = lang.get('b1', 'b2', 'b3', 'b4', 'clear', 'loc', 'table') block, place = lang.get('block', 'place') init.set(loc, b1, b2) # loc(b1) := b2 init.set(loc, b2, b3) # loc(b2) := b3 init.set(loc, b3, table) # loc(b3) := table init.set(loc, b4, table) # loc(b4) := table init.add(clear, b1) # clear(b1) init.add(clear, b4) # clear(b4) init.add(clear, table) # clear(table) src = lang.variable('src', block) dest = lang.variable('dest', place) x = lang.variable('x', block) y = lang.variable('y', block) clear_constraint = forall( x, equiv(neg(clear(x)), land(x != table, exists(y, loc(y) == x)))) G = land(loc(b1) == b2, loc(b2) == b3, loc(b3) == b4, loc(b4) == table) problem = fs.Problem("tower4", "blocksworld") problem.language = lang problem.init = init problem.goal = G problem.constraints += [clear_constraint] problem.action('move', [src, dest], land(clear(src), clear(dest)), [fs.FunctionalEffect(loc(src), dest)]) return problem
def create_small_task(): upp = create_small_language() dummy_sheet = upp.constant('dummy-sheet', upp.sheet_t) sheet1 = upp.constant('sheet1', upp.sheet_t) M = tsk.model.create(upp) M.evaluator = evaluate M.add(upp.Uninitialized) M.add(upp.Location, dummy_sheet, upp.some_finisher_tray) M.add(upp.Prevsheet, sheet1, dummy_sheet) M.add(upp.Sheetsize, sheet1, upp.letter) M.add(upp.Location, sheet1, upp.some_feeder_tray) M.set(upp.total_cost(), 0) sheet = upp.variable('sheet', upp.sheet_t) prevsheet = upp.variable('prevsheet', upp.sheet_t) precondition = land( upp.Available(upp.finisher2_rsrc), upp.Prevsheet(sheet, prevsheet), upp.Location(prevsheet, upp.some_finisher_tray), upp.Sheetsize(sheet, upp.letter), upp.Location(sheet, upp.finisher2_entry_finisher1_exit)) effects = [ fs.DelEffect(upp.Available(upp.finisher2_rsrc)), fs.DelEffect(upp.Location(sheet, upp.finisher2_entry_finisher1_exit)), fs.AddEffect(upp.Location(sheet, upp.some_finisher_tray)), fs.AddEffect(upp.Stackedin(sheet, upp.finisher2_tray)), fs.AddEffect(upp.Available(upp.finisher2_rsrc)), fs.IncreaseEffect(upp.total_cost(), 8000) ] problem = fs.Problem() problem.name = "fun" problem.language = upp problem.init = M problem.goal = top problem.action('Finisher2-Stack-Letter', [sheet, prevsheet], precondition, effects) problem.metric = fs.OptimizationMetric(upp.total_cost(), fs.OptimizationType.MINIMIZE) return problem
def create_small_task(): upp = parcprinter.create_small_language() dummy_sheet = upp.constant('dummy-sheet', upp.sheet_t) sheet1 = upp.constant('sheet1', upp.sheet_t) M = tsk.model.create(upp) M.evaluator = evaluate M.add(upp.Uninitialized) M.add(upp.Location, dummy_sheet, upp.some_finisher_tray) M.add(upp.Prevsheet, sheet1, dummy_sheet) M.add(upp.Sheetsize, sheet1, upp.letter) M.add(upp.Location, sheet1, upp.some_feeder_tray) sheet = upp.variable('sheet', upp.sheet_t) prevsheet = upp.variable('prevsheet', upp.sheet_t) precondition = land(upp.Available(upp.finisher2_rsrc), upp.Prevsheet(sheet, prevsheet), upp.Location(prevsheet, upp.some_finisher_tray), upp.Sheetsize(sheet, upp.letter), upp.Location(sheet, upp.finisher2_entry_finisher1_exit)) # MRJ: note that the positive effects should be under an extra X op, as per the # "deletes before adds" semantics, effects = [fs.DelEffect(upp.Available(upp.finisher2_rsrc)), fs.DelEffect(upp.Location(sheet, upp.finisher2_entry_finisher1_exit)), fs.AddEffect(upp.Location(sheet, upp.some_finisher_tray)), fs.AddEffect(upp.Stackedin(sheet, upp.finisher2_tray)), fs.AddEffect(upp.Available(upp.finisher2_rsrc)) ] P = fs.Problem() P.name = "fun" P.language = upp P.init = M P.goal = top P.action('Finisher2-Stack-Letter', [sheet, prevsheet], precondition, effects) return P
def create_4blocks_task(): bw = generate_bw_loc_and_clear(4) M = tarski.model.create(bw) loc = bw.get_function('loc') clear = bw.get_predicate('clear') b1, b2, b3, b4 = [bw.get_constant('b{}'.format(k)) for k in range(1, 5)] table = bw.get_constant('table') hand = bw.get_constant('hand') M.setx(loc(b1), b2) # loc(b1) := b2 M.setx(loc(b2), b3) # loc(b2) := b3 M.setx(loc(b3), table) # loc(b3) := table M.setx(loc(b4), table) # loc(b4) := table M.setx(loc(table), table) M.setx(loc(hand), hand) M.add(clear, b1) # clear(b1) M.add(clear, b4) # clear(b4) M.add(clear, hand) # handempty G = land(loc(b1) == b2, loc(b2) == b3, loc(b3) == b4, loc(b4) == table) P = fs.Problem() P.name = "tower4" P.domain_name = "blocksworld" P.language = bw P.init = M P.goal = G # P.constraints += [clear_constraint] # @NOTE: These are the state variables associated with the constraint above P.state_variables = [ ] # [StateVariable(clear(dest), [tb]) for tb in [tb1, tb2, tb3, tb4, table]] b = bw.variable('b', bw.Object) P.action( 'pick_up', [b], land(clear(b), clear(hand), loc(b) == table, b != hand, b != table), [ fs.FunctionalEffect(loc(b), hand), fs.DelEffect(clear(b)), fs.DelEffect(clear(hand)) ]) P.action('put_down', [b], land(loc(b) == hand, b != table, b != hand), [ fs.FunctionalEffect(loc(b), table), fs.AddEffect(clear(b)), fs.AddEffect(clear(hand)) ]) src = bw.variable('src', bw.Object) dest = bw.variable('dest', bw.Object) P.action( 'stack', [src, dest], land( loc(src) == hand, clear(dest), src != dest, src != table, src != hand, dest != table, dest != hand), [ fs.FunctionalEffect(loc(src), dest), fs.DelEffect(clear(dest)), fs.AddEffect(clear(src)), fs.AddEffect(clear(hand)) ]) P.action( 'unstack', [src, dest], land(clear(hand), loc(src) == dest, clear(src), src != dest, src != table, src != hand, dest != table, dest != hand), [ fs.FunctionalEffect(loc(src), hand), fs.DelEffect(clear(src)), fs.AddEffect(clear(dest)), fs.DelEffect(clear(hand)) ]) return P