Skip to content

Commit 3f3ea29

Browse files
committed
introduce type for objects representing number
one aspect mentioned in #7
1 parent b37b597 commit 3f3ea29

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

examples/suave/suave_problem_created.pddl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
(:domain suave)
33

44
(:objects
5-
f_generate_search_path f_follow_pipeline f_maintain_motion fd_spiral_low fd_spiral_medium fd_spiral_high fd_all_thrusters fd_recover_thrusters fd_follow_pipeline 0.25_decimal 0.5_decimal 0.75_decimal 1.0_decimal 1.25_decimal 2.25_decimal 3.25_decimal <_string battery_level c_thruster_1 c_thruster_2 c_thruster_3 c_thruster_4 c_thruster_5 c_thruster_6 energy obs_water_visibility performance qa_inspect_efficiency_high qa_motion_efficiency_degraded qa_motion_efficiency_normal qa_search_efficiency_high qa_search_efficiency_low qa_search_efficiency_medium qa_water_visibility_high qa_water_visibility_low qa_water_visibility_medium safety - object
5+
f_generate_search_path f_follow_pipeline f_maintain_motion fd_spiral_low fd_spiral_medium fd_spiral_high fd_all_thrusters fd_recover_thrusters fd_follow_pipeline <_string battery_level c_thruster_1 c_thruster_2 c_thruster_3 c_thruster_4 c_thruster_5 c_thruster_6 energy obs_water_visibility performance qa_inspect_efficiency_high qa_motion_efficiency_degraded qa_motion_efficiency_normal qa_search_efficiency_high qa_search_efficiency_low qa_search_efficiency_medium qa_water_visibility_high qa_water_visibility_low qa_water_visibility_medium safety - object
66
a_search_pipeline a_inspect_pipeline - action
77
pipeline - pipeline
88
bluerov - robot
9+
0.25_decimal 0.5_decimal 0.75_decimal 1.0_decimal 1.25_decimal 2.25_decimal 3.25_decimal - number
910
)
1011

1112
(:init

src/main/kotlin/no/uio/tobiajoh/owl/OwlNumber.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
package no.uio.tobiajoh.owl
22

33
// owl constant, representing a number
4-
class OwlNumber(val number: Double, name: String) : OwlAssertionConstant(name) {
4+
class OwlNumber(private val number: Double, name: String) : OwlAssertionConstant(name) {
5+
6+
companion object {
7+
// the type that is used for numbers in pddl files
8+
const val PDDLTYPE = "number"
9+
}
510

611
// operator to compare two numbers
712
// note: only indicates, which number is larger, not by how much

src/main/kotlin/no/uio/tobiajoh/pddl/PDDLInjector.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ class PDDLInjector(val addNumComparisons: Boolean = false) {
7474

7575
sP.addInitialAssertions(assertions)
7676

77-
sP.addObjects(objects)
77+
sP.addObjects(objects.minus(numbers))
78+
sP.addNumbers(numbers)
7879

7980
sP.outputToFile(newProblem)
8081

src/main/kotlin/no/uio/tobiajoh/pddl/SplitProgram.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package no.uio.tobiajoh.pddl
22

33
import no.uio.tobiajoh.owl.OwlAssertion
44
import no.uio.tobiajoh.owl.OwlAssertionConstant
5+
import no.uio.tobiajoh.owl.OwlNumber
56
import java.io.File
67

78

@@ -93,6 +94,14 @@ class SplitProgram(val problem : File) {
9394
}
9495
}
9596

97+
fun addNumbers(newNumbers: Set<OwlNumber>) {
98+
val sortedNumbers = newNumbers.map { it.toString() }.sorted()
99+
sortedNumbers.forEach { n ->
100+
if (!objects.containsKey(n))
101+
objects[n] = OwlNumber.PDDLTYPE
102+
}
103+
}
104+
96105
fun outputToFile(outFile: File) {
97106
outFile.printWriter().use { out ->
98107
out.println("(define (problem ${problemName})")

0 commit comments

Comments
 (0)