Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>David</title>
- <meta name="description" content="The HTML5 Herald">
- <meta name="author" content="SitePoint">
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
- </head>
- <body>
- <p>ciao</p>
- </body>
- <script>
- var domText = "(define (domain myDomain)\
- (:requirements :strips :equality :typing)\
- (:types \
- Service - Thing\
- Capability\
- Object - Thing\
- Location\
- Boolean\
- )\
- (:predicates \
- (provides ?srv - Service ?c - Capability) \
- (heated ?o - Object ?b - Boolean)\
- (processed ?o - Object ?b - Boolean)\
- (cooled ?o - Object ?b - Boolean)\
- (movable ?o - Object ?b - Boolean)\
- (at ?t - Thing ?l - Location)\
- (carries ?s - Service ?o - Object)\
- )\
- (:action cool\
- :parameters (?srv - Service ?o - Object ?l - Location)\
- :precondition (and (provides ?srv cooling) (at ?srv ?l) (at ?o ?l) (processed ?o true) )\
- :effect (and (cooled ?o true) (not(cooled ?o false)) (increase (total-cost) 1))\
- )\
- (:action convert\
- :parameters (?srv - Service ?o - Object ?l - Location)\
- :precondition (and (provides ?srv converting) (at ?srv ?l) (at ?o ?l) )\
- :effect (and (heated ?o true) (processed ?o true) (cooled ?o true) (not(heated ?o false)) (not(processed ?o false)) (not(cooled ?o false)) (increase (total-cost) 5))\
- )\
- (:action heat\
- :parameters (?srv - Service ?o - Object ?l - Location)\
- :precondition (and (provides ?srv heating) (at ?srv ?l) (at ?o ?l) )\
- :effect (and (heated ?o true) (not(heated ?o false)) (increase (total-cost) 1))\
- )\
- (:action process\
- :parameters (?srv - Service ?o - Object ?l - Location)\
- :precondition (and (provides ?srv processing) (at ?srv ?l) (at ?o ?l) (heated ?o true) )\
- :effect (and (processed ?o true) (not(processed ?o false)) (increase (total-cost) 1))\
- )\
- (:action unload\
- :parameters (?srv - Service ?o - Object ?l - Location)\
- :precondition (and (provides ?srv unloading) (at ?srv ?l) (carries ?srv ?o) )\
- :effect (and (at ?o ?l) (not(carries ?srv ?o)) (increase (total-cost) 1))\
- )\
- (:action load\
- :parameters (?srv - Service ?o - Object ?l - Location)\
- :precondition (and (provides ?srv loading) (at ?srv ?l) (at ?o ?l) (movable ?o true) (not(carries ?srv ?o)) )\
- :effect (and (carries ?srv ?o) (not(at ?o ?l)) (increase (total-cost) 1))\
- )\
- (:action move\
- :parameters (?srv - Service ?from - Location ?to - Location)\
- :precondition (and (provides ?srv movement) (at ?srv ?from) )\
- :effect (and (at ?srv ?to) (not(at ?srv ?from)) (increase (total-cost) 1))\
- )\
- (:functions (total-cost))\
- )"
- var probText= "(define (problem myProblem)\n" +
- "(:domain myDomain)\n" +
- "(:objects \n" +
- "o1 - Object\n" +
- "o2 - Object\n" +
- "l00 - Location\n" +
- "l01 - Location\n" +
- "l02 - Location\n" +
- "l03 - Location\n" +
- "l04 - Location\n" +
- "l05 - Location\n" +
- "l06 - Location\n" +
- "l10 - Location\n" +
- "l11 - Location\n" +
- "l12 - Location\n" +
- "l13 - Location\n" +
- "l14 - Location\n" +
- "l15 - Location\n" +
- "l16 - Location\n" +
- "l20 - Location\n" +
- "l21 - Location\n" +
- "l22 - Location\n" +
- "l23 - Location\n" +
- "l24 - Location\n" +
- "l25 - Location\n" +
- "l26 - Location\n" +
- "l30 - Location\n" +
- "l31 - Location\n" +
- "l32 - Location\n" +
- "l33 - Location\n" +
- "l34 - Location\n" +
- "l35 - Location\n" +
- "l36 - Location\n" +
- "true - Boolean\n" +
- "false - Boolean\n" +
- "cooling - Capability\n" +
- "converting - Capability\n" +
- "heating - Capability\n" +
- "processing - Capability\n" +
- "unloading - Capability\n" +
- "loading - Capability\n" +
- "movement - Capability\n" +
- "clr1 - Service\n" +
- "cnv1 - Service\n" +
- "htr1 - Service\n" +
- "prc1 - Service\n" +
- "rb - Service\n" +
- "rb2 - Service\n" +
- ")\n" +
- "(:init\n" +
- "(provides clr1 cooling)\n" +
- "(provides cnv1 converting)\n" +
- "(provides htr1 heating)\n" +
- "(provides prc1 processing)\n" +
- "(provides rb unloading)\n" +
- "(provides rb loading)\n" +
- "(provides rb movement)\n" +
- "(provides rb2 unloading)\n" +
- "(provides rb2 loading)\n" +
- "(provides rb2 movement)\n" +
- "(at o1 l00)\n" +
- "(at o2 l00)\n" +
- "(movable o1 true)\n" +
- "(movable o2 true)\n" +
- "(at clr1 l01)\n" +
- "(at cnv1 l03)\n" +
- "(at htr1 l21)\n" +
- "(at prc1 l23)\n" +
- "(at rb l01)\n" +
- "(at rb2 l36)\n" +
- "(carries rb2 o2)\n" +
- "(= (total-cost) 0)\n" +
- ")\n" +
- "(:goal \n" +
- "(and \n" +
- "(at o1 l36)\n" +
- "(at o2 l36)\n" +
- "(cooled o1 true)\n" +
- "(cooled o2 true)\n" +
- ")\n" +
- ")\n" +
- "(:metric minimize (total-cost))\n" +
- ")"
- $.ajax( {url: "http://solver.planning.domains/solve-and-validate",
- type: "POST",
- contentType: 'application/json',
- data: JSON.stringify({"domain": domText,
- "problem": probText})})
- .done(function (res) {
- if (res['status'] === 'ok') {
- window.alert('Plan found!');
- } else {
- window.alert('Planning failed.');
- }
- console.log(res);
- }
- );
- function readTextFile(file)
- {
- var rawFile = new XMLHttpRequest();
- rawFile.open("GET", file, false);
- rawFile.onreadystatechange = function ()
- {
- if(rawFile.readyState === 4)
- {
- if(rawFile.status === 200 || rawFile.status == 0)
- {
- var allText = rawFile.responseText;
- alert(allText);
- }
- }
- }
- rawFile.send(null);
- }
- </script>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement