sfplanner 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +20 -2
- data/VERSION +1 -0
- data/bin/sfplanner +4 -3
- data/lib/sfplanner/planner.rb +42 -6
- data/sfplanner.gemspec +2 -2
- metadata +5 -4
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
SFP Planner for Ruby
|
2
2
|
====================
|
3
3
|
- Author: Herry (herry13@gmail.com)
|
4
|
-
- Version
|
5
|
-
- License: [BSD
|
4
|
+
- [Version](https://github.com/herry13/sfplanner/blob/master/VERSION)
|
5
|
+
- License: [BSD](https://github.com/herry13/sfp-ruby/blob/master/LICENSE)
|
6
6
|
|
7
7
|
A Ruby gem that provides a Ruby API to SFP planner that solves a planning task written in [SFP language](https://github.com/herry13/nuri/wiki/SFP-language).
|
8
8
|
|
@@ -184,3 +184,21 @@ Example of Planning Task
|
|
184
184
|
This workflow is sequential that has 3 procedures. If you executes
|
185
185
|
the workflow in given order, it will achieves the goal state as well
|
186
186
|
as perserves the global constraints during the execution.
|
187
|
+
|
188
|
+
|
189
|
+
Planner Options
|
190
|
+
---------------
|
191
|
+
You could set particular environment variable to change the planner settings:
|
192
|
+
- to activate debug-mode
|
193
|
+
|
194
|
+
SFPLANNER_DEBUG=1
|
195
|
+
|
196
|
+
- to use multiple heuristic on finding the solution, and then pick the best result
|
197
|
+
|
198
|
+
SFPLANNER_MIXED_CONTINUE=1
|
199
|
+
|
200
|
+
- to set heuristics which are used in searching
|
201
|
+
|
202
|
+
SFPLANNER_MIXED_HEURISTICS=ff2,cea2
|
203
|
+
|
204
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.2
|
data/bin/sfplanner
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
dir = File.expand_path(File.dirname(__FILE__))
|
4
|
+
current_version = File.read(File.join(File.dirname(__FILE__), '../VERSION')).sub(/\n/, '')
|
5
|
+
require "#{dir}/../lib/sfplanner"
|
5
6
|
|
6
7
|
opts = Trollop::options do
|
7
|
-
version "sfplanner
|
8
|
+
version "sfplanner " + current_version + " (c) 2013 Herry"
|
8
9
|
banner <<-EOS
|
9
10
|
Solve a planning task specified in SFP language, and print the plan (if found) in JSON format.
|
10
11
|
|
data/lib/sfplanner/planner.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
1
3
|
module Sfp
|
2
4
|
class Planner
|
3
5
|
Heuristic = 'mixed' # lmcut, cg, cea, ff, mixed ([cg|cea|ff]=>lmcut)
|
4
|
-
Debug = false
|
6
|
+
Debug = (ENV['SFPLANNER_DEBUG'] ? true : false)
|
5
7
|
TranslatorBenchmarkFile = 'sas_translator.benchmarks'
|
6
8
|
|
7
9
|
class Config
|
@@ -452,15 +454,20 @@ module Sfp
|
|
452
454
|
# 2) remove actions which are not selected by previous step
|
453
455
|
# 3) solve the problem with LMCUT using A*-search to obtain a sub-optimal plan
|
454
456
|
class MixedHeuristic
|
455
|
-
|
457
|
+
attr_reader :heuristics_order
|
458
|
+
|
459
|
+
def initialize(dir, sas_file, plan_file, continue=false, optimize=true)
|
456
460
|
@dir = dir
|
457
461
|
@sas_file = sas_file
|
458
462
|
@plan_file = plan_file
|
463
|
+
@heuristics_order = ['autotune12', 'autotune22', 'ff2', 'cea2']
|
464
|
+
@heuristics_order = ENV['SFPLANNER_MIXED_HEURISTICS'].split(',') if ENV['SFPLANNER_MIXED_HEURISTICS']
|
465
|
+
@continue = continue
|
466
|
+
@continue = true if ENV['SFPLANNER_MIXED_CONTINUE']
|
467
|
+
@optimize = optimize
|
459
468
|
end
|
460
469
|
|
461
|
-
def
|
462
|
-
optimize = true
|
463
|
-
|
470
|
+
def solve2
|
464
471
|
if not File.exist?(@plan_file)
|
465
472
|
#autotune12 (see fd-autotune-1)
|
466
473
|
planner = Sfp::Planner.getcommand(@dir, @sas_file, @plan_file, 'autotune12')
|
@@ -490,7 +497,36 @@ module Sfp
|
|
490
497
|
#end
|
491
498
|
|
492
499
|
return false if not File.exist?(@plan_file)
|
493
|
-
optimize_plan if optimize
|
500
|
+
optimize_plan if @optimize
|
501
|
+
|
502
|
+
true
|
503
|
+
end
|
504
|
+
|
505
|
+
def solve
|
506
|
+
total = 0
|
507
|
+
@heuristics_order.each do |heuristic|
|
508
|
+
command = Sfp::Planner.getcommand(@dir, @sas_file, @plan_file, heuristic)
|
509
|
+
Kernel.system(command)
|
510
|
+
if File.exist?(@plan_file)
|
511
|
+
total += 1
|
512
|
+
File.rename(@plan_file, "#{@plan_file}.sol.#{total}")
|
513
|
+
break if not @continue
|
514
|
+
end
|
515
|
+
end
|
516
|
+
|
517
|
+
return false if total <= 0
|
518
|
+
|
519
|
+
best_length = 1000000
|
520
|
+
1.upto(total) do |i|
|
521
|
+
filepath = "#{@plan_file}.sol.#{i}"
|
522
|
+
plan_length = File.read(filepath).split("\n").length
|
523
|
+
if plan_length < best_length
|
524
|
+
File.delete(@plan_file) if File.exist?(@plan_file)
|
525
|
+
FileUtils.copy(filepath, @plan_file)
|
526
|
+
end
|
527
|
+
end
|
528
|
+
|
529
|
+
optimize_plan if @optimize
|
494
530
|
|
495
531
|
true
|
496
532
|
end
|
data/sfplanner.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'sfplanner'
|
3
|
-
s.version =
|
3
|
+
s.version = File.read(File.join(File.dirname(__FILE__), 'VERSION')).sub(/\n/, '')
|
4
4
|
s.date = '2013-08-13'
|
5
5
|
s.summary = 'SFPlanner'
|
6
6
|
s.description = 'A Ruby gem that provides a Ruby API and a script to the SFP planner. This planner can automatically generate a plan that solves a planning problem written in SFP language.'
|
@@ -16,5 +16,5 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.homepage = 'https://github.com/herry13/sfplanner'
|
17
17
|
s.rubyforge_project = 'sfplanner'
|
18
18
|
|
19
|
-
s.add_dependency 'sfp', '~> 0.3.
|
19
|
+
s.add_dependency 'sfp', '~> 0.3.11'
|
20
20
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sfplanner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,15 +13,15 @@ date: 2013-08-13 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sfp
|
16
|
-
requirement: &
|
16
|
+
requirement: &8735620 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.3.
|
21
|
+
version: 0.3.11
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *8735620
|
25
25
|
description: A Ruby gem that provides a Ruby API and a script to the SFP planner.
|
26
26
|
This planner can automatically generate a plan that solves a planning problem written
|
27
27
|
in SFP language.
|
@@ -34,6 +34,7 @@ files:
|
|
34
34
|
- .gitignore
|
35
35
|
- LICENSE
|
36
36
|
- README.md
|
37
|
+
- VERSION
|
37
38
|
- bin/sfplanner
|
38
39
|
- bin/sfw2graph
|
39
40
|
- bin/solver/linux-x86/downward
|