ai-planning-val
Version:
Javascript/typescript wrapper for VAL (AI Planning plan validation and evaluation tools from KCL Planning department and the planning community around the ICAPS conference).
52 lines • 2.71 kB
JavaScript
;
/* --------------------------------------------------------------------------------------------
* Copyright (c) Jan Dolejsi. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PlanEvaluator = void 0;
const pddl_workspace_1 = require("pddl-workspace");
const ValStep_1 = require("./ValStep");
/**
* Evaluates plan in the context of domain and problem and returns the final state.
*/
class PlanEvaluator {
evaluateHappenings(domainInfo, problemInfo, happenings, options) {
return __awaiter(this, void 0, void 0, function* () {
return yield new ValStep_1.ValStep(domainInfo, problemInfo)
.executeBatch(happenings, options);
// todo: should correct the predicate/function/object names to the original capitalization
});
}
evaluate(domainInfo, problemInfo, planInfo, options) {
return __awaiter(this, void 0, void 0, function* () {
// todo: run semantic validation for the plan first
const happenings = planInfo.getHappenings();
return this.evaluateHappenings(domainInfo, problemInfo, happenings, options);
});
}
evaluatePlan(plan, options) {
return __awaiter(this, void 0, void 0, function* () {
// todo: run semantic validation for the plan first
const happenings = pddl_workspace_1.PlanInfo.getHappenings(plan.steps);
if (!plan.domain) {
throw new Error('Domain not specified');
}
if (!plan.problem) {
throw new Error('Problem not specified');
}
return this.evaluateHappenings(plan.domain, plan.problem, happenings, options);
});
}
}
exports.PlanEvaluator = PlanEvaluator;
//# sourceMappingURL=PlanEvaluator.js.map