Skip to content
Snippets Groups Projects
Commit 5e4013f5 authored by GATEAU Thibault's avatar GATEAU Thibault
Browse files

[bash] env

parent 1edb9b47
No related branches found
No related tags found
No related merge requests found
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>TP01 - Practice - Introduction to HTN planning</title>
<style>
/* From extension vscode.github */
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
.vscode-dark img[src$=\#gh-light-mode-only],
.vscode-light img[src$=\#gh-dark-mode-only] {
display: none;
}
</style>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex/dist/katex.min.css">
<link href="https://cdn.jsdelivr.net/npm/katex-copytex@latest/dist/katex-copytex.min.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Microsoft/vscode/extensions/markdown-language-features/media/markdown.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Microsoft/vscode/extensions/markdown-language-features/media/highlight.css">
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe WPC', 'Segoe UI', system-ui, 'Ubuntu', 'Droid Sans', sans-serif;
font-size: 14px;
line-height: 1.6;
}
</style>
<style>
.task-list-item {
list-style-type: none;
}
.task-list-item-checkbox {
margin-left: -20px;
vertical-align: middle;
pointer-events: none;
}
</style>
</head>
<body class="vscode-body vscode-light">
<h1 id="tp01---practice---introduction-to-htn-planning">TP01 - Practice - Introduction to HTN planning</h1>
<ul>
<li><a href="#tp01---practice---introduction-to-htn-planning">TP01 - Practice - Introduction to HTN planning</a>
<ul>
<li><a href="#first-hddl">First HDDL</a>
<ul>
<li><a href="#resources">Resources</a></li>
<li><a href="#set-up-project-environment">Set-up project environment</a></li>
<li><a href="#first-plan">First plan</a></li>
<li><a href="#writing-some-tasks-methods-and-literals">Writing some tasks, methods and literals</a></li>
<li><a href="#adding-cost">Adding cost</a>
<ul>
<li><a href="#some-help-if-necessary">Some help if necessary</a>
<ul>
<li><a href="#in-the-domain">in the domain</a></li>
<li><a href="#in-the-problem">in the problem</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#adding-cash-machines">Adding cash machines</a></li>
<li><a href="#travelling-salesman-problem">Travelling salesman problem</a>
<ul>
<li><a href="#writing-a-more-interesting-planning-problem">Writing a more interesting planning problem</a></li>
<li><a href="#some-statistics-and-performance">Some statistics and performance</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<h1 id="first-hddl">First HDDL</h1>
<h2 id="resources">Resources</h2>
<ul>
<li><a href="externalRessources/tutorialPDDL_HDDL.pdf">PDDL and HDDL quick-start tutorial</a></li>
<li><a href="https://github.com/Maumagnaguagno/HyperTensioN">HyperTensioN webpage</a></li>
<li><a href="https://gitlab.isae-supaero.fr/saclab/ssa/intro-htn/-/tree/main/externalRessources">Other resources</a></li>
</ul>
<h2 id="set-up-project-environment">Set-up project environment</h2>
<ul class="contains-task-list">
<li class="task-list-item enabled"><input class="task-list-item-checkbox"type="checkbox"> Clone git repository</li>
</ul>
<pre><code>mkdir -p git &amp;&amp; cd git
git clone https://gitlab.isae-supaero.fr/saclab/ssa/intro-htn.git
cd intro-htn
HTN_PATH=$(pwd)
</code></pre>
<ul class="contains-task-list">
<li class="task-list-item enabled"><input class="task-list-item-checkbox"type="checkbox"> load SI environment</li>
</ul>
<pre><code>cd $HTN_PATH
module load julia/1.9.3
module load anaconda3/2023
</code></pre>
<ul class="contains-task-list">
<li class="task-list-item enabled"><input class="task-list-item-checkbox"type="checkbox"> Test HyperTensioN planner</li>
</ul>
<pre><code>cd $HTN_PATH
cd HyperTensioN
ruby Hype.rb examples/basic/basic.jshop examples/basic/pb1.jshop rb
ruby examples/basic/pb1.jshop.rb
# should print:
#----------------------Tasks-----------------------
#0: swap(banjo kiwi)
#---------------------Planning---------------------
#Time: 4.076957702636719e-05s
#-----------------------Plan-----------------------
#0: drop(kiwi)
#1: pickup(banjo)
</code></pre>
<ul class="contains-task-list">
<li class="task-list-item enabled"><input class="task-list-item-checkbox"type="checkbox"> add some macros for easy execution</li>
</ul>
<pre><code>#HyperTensioN execution command:
function plan {
ruby ${HTN_PATH}/HyperTensioN/Hype.rb $1 $2 $3
}
alias plan='plan'
#Ruby dot:
function planviz {
plan $1 $2 dot
dot -Tpdf &quot;$1&quot;.dot &gt; &quot;$1&quot;.pdf &amp;&amp;
evince &quot;$1&quot;.pdf &amp;
}
alias planviz='planviz'
</code></pre>
<ul class="contains-task-list">
<li class="task-list-item enabled"><input class="task-list-item-checkbox"type="checkbox"> test it with your future HDDL domain</li>
</ul>
<pre><code>cd ${HTN_PATH}/TP01
planviz travelWalkTaxi.hddl gotoPark_problem.hddl
</code></pre>
<h2 id="first-plan">First plan</h2>
<p>Suppose that you want a planner to help you to decide how you will achieve some travelling tasks in a foreign city.</p>
<p>Have a look to the <strong>domain HDDL file</strong> &lt;travelWalkTaxi.hddl&gt; and the <strong>problem HDDL file</strong> &lt;gotoPark_problem.hddl&gt; with your favorite editor</p>
<ul class="contains-task-list">
<li class="task-list-item enabled"><input class="task-list-item-checkbox"type="checkbox"> Check that you can get a valid plan (only one action is performed actually!)</li>
</ul>
<p>In this dummy example, we want to travel from home to the park, corresponding to the goal <strong>Task</strong> in &lt;gotoPark_problem.hddl&gt;: <em>(travel home park)</em></p>
<pre><code>plan travelWalkTaxi.hddl gotoPark_problem.hddl debug
</code></pre>
<p>You should get a dummy plan.</p>
<ul class="contains-task-list">
<li class="task-list-item enabled"><input class="task-list-item-checkbox"type="checkbox"> Check what's happening if the park is not at a short distance from home...</li>
</ul>
<blockquote>
<p>i.e remove '(shortDistance home park)' predicate.</p>
</blockquote>
<h2 id="writing-some-tasks-methods-and-literals">Writing some tasks, methods and literals</h2>
<ul class="contains-task-list">
<li class="task-list-item enabled"><input class="task-list-item-checkbox"type="checkbox"> In the problem file, add an <em>airport</em> location, and try to travel there</li>
</ul>
<p>Note that the airport is not at a <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>s</mi><mi>h</mi><mi>o</mi><mi>r</mi><mi>t</mi><mi>D</mi><mi>i</mi><mi>s</mi><mi>t</mi><mi>a</mi><mi>n</mi><mi>c</mi><mi>e</mi></mrow><annotation encoding="application/x-tex">shortDistance</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">s</span><span class="mord mathnormal">h</span><span class="mord mathnormal" style="margin-right:0.02778em;">or</span><span class="mord mathnormal">t</span><span class="mord mathnormal" style="margin-right:0.02778em;">D</span><span class="mord mathnormal">i</span><span class="mord mathnormal">s</span><span class="mord mathnormal">t</span><span class="mord mathnormal">an</span><span class="mord mathnormal">ce</span></span></span></span> from home or from the park.</p>
<blockquote>
<p>You may create a new <strong>problem HDDL file</strong> &lt;gotoAirport_problem.hddl&gt;</p>
</blockquote>
<p>Now, before taking your flight, you would like to go to the park, and then reach the airport. Update the task list in the problem (or the compound task and methods in the domain?) according to.</p>
<ul class="contains-task-list">
<li class="task-list-item enabled"><input class="task-list-item-checkbox"type="checkbox"> Generate a plan where you're going first to the park, and after to the airport.</li>
</ul>
<blockquote>
<p>You may create a new <strong>problem HDDL file</strong> &lt;gotoAirportFromPark_problem.hddl&gt;</p>
</blockquote>
<h2 id="adding-cost">Adding cost</h2>
<p>Actually, taxi ride is not free. To keep it simple, each travel in taxi will cost you $20, no matter the distance. Begin with $60 cash in your pocket. In this city, taxis only accept cash.</p>
<ul class="contains-task-list">
<li class="task-list-item enabled"><input class="task-list-item-checkbox"type="checkbox"> Model the taxi cost: in the domain, add an action 'pay_driver'</li>
</ul>
<p> </p>
<blockquote>
<p>You may create a new <strong>domain HDDL file</strong> &lt;travelWalkTaxiCost.hddl&gt; and <strong>problem HDDL file</strong> &lt;travelWalkTaxiCost_problem.hddl&gt;</p>
</blockquote>
<p> </p>
<blockquote>
<p>Trick: use a &quot;gauge&quot; for the amount of money, i.e. objects that represent your value (numerable are not implemented yet and would complexify the problem resolution!)</p>
</blockquote>
<p> </p>
<blockquote>
<p>Warning: 'functions' are not implemented in HyperTensioN</p>
</blockquote>
<p><img src="file:////home/tgateau/git/saclab/ssa/intro-htn/TP01/OpenAItaxi.png" alt="OpenAItaxi.png" title="OpenAI Gym tutorial"></p>
<p>Figure 1: <a href="https://www.gocoder.one/blog/rl-tutorial-with-openai-gym/">OpenAI Gym tutorial</a></p>
<p> </p>
<h3 id="some-help-if-necessary">Some help if necessary</h3>
<h4 id="in-the-domain">in the domain</h4>
<p>in a method or task, you will need an artificial precondition to pass from $60 to $40:</p>
<pre><code> (next ?l2 ?l1)
</code></pre>
<pre><code> (:action pay_driver
[...]
:effect (and
(not (money-level ?l2))
(money-level ?l1)
)
)
</code></pre>
<h4 id="in-the-problem">in the problem</h4>
<pre><code>(:objects
...
$0 $20 $40 $60 - Cash
)
(:init
...
(next $60 $40)
(next $40 $20)
(next $20 $0)
(cash-level $20)
)
</code></pre>
<h2 id="adding-cash-machines">Adding cash machines</h2>
<ul class="contains-task-list">
<li class="task-list-item enabled"><input class="task-list-item-checkbox"type="checkbox"> Add more destinations and possibilities</li>
</ul>
<p>For example, add a museum that you actually want to visit since you have time before your flight.</p>
<blockquote>
<p>At each step, for the moment, chack that you have enough cash and that your still getting a valid plan.</p>
</blockquote>
<p>Now, try it again, with only $20 in your wallet: planning should fail if you are visiting a museum far away...</p>
<ul class="contains-task-list">
<li class="task-list-item enabled"><input class="task-list-item-checkbox"type="checkbox"> Add a 'CashMachine' locations and generate a new plan beginning without enough cash.</li>
</ul>
<p>Cash Machines are located at short distance from home, park and museum (apparently we are in a capitalist city). From there, you can retrieve cash. Don't worry, we will not model your bank account.</p>
<blockquote>
<p>You may create a new <strong>domain HDDL file</strong> &lt;travelManyPlaces.hddl&gt; and <strong>problem HDDL file</strong> &lt;travelManyPlaces_problem.hddl&gt;</p>
</blockquote>
<h1 id="travelling-salesman-problem">Travelling salesman problem</h1>
<h2 id="writing-a-more-interesting-planning-problem">Writing a more interesting planning problem</h2>
<ul class="contains-task-list">
<li class="task-list-item enabled"><input class="task-list-item-checkbox"type="checkbox"> Add 10 destinations in the city and visit them all before getting to the airport.</li>
</ul>
<p>E.g add a library, coffee-shop... Some are at short-distance from one another, others not.</p>
<blockquote>
<p>check that you still getting a valid plan.
you may still have to modify your porblem and domain, e.g adding a predicate 'hasBeenVisited' for a location</p>
</blockquote>
<h2 id="some-statistics-and-performance">Some statistics and performance</h2>
<ul class="contains-task-list">
<li class="task-list-item enabled"><input class="task-list-item-checkbox"type="checkbox"> evaluate the performance of the planner</li>
</ul>
<p>&gt;- how many steps for 10 locations?
&gt;- how much CPU time for 10 locations?
&gt;- draw a plot (e.g in Matplotlib) for time and cost according to problem size (e.g: number of locations here)</p>
<p><img src="file:////home/tgateau/git/saclab/ssa/intro-htn/TP01/pddl.png" alt="PDDL.png" title="PDDL"></p>
<script async src="https://cdn.jsdelivr.net/npm/katex-copytex@latest/dist/katex-copytex.min.js"></script>
</body>
</html>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment