Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
inox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LARA
inox
Commits
99a20e07
Commit
99a20e07
authored
12 years ago
by
Etienne Kneuss
Browse files
Options
Downloads
Patches
Plain Diff
Decouple Synthesizer from Search
parent
5ccb8ebe
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/scala/leon/synthesis/SimpleSearch.scala
+62
-0
62 additions, 0 deletions
src/main/scala/leon/synthesis/SimpleSearch.scala
src/main/scala/leon/synthesis/Synthesizer.scala
+1
-56
1 addition, 56 deletions
src/main/scala/leon/synthesis/Synthesizer.scala
with
63 additions
and
56 deletions
src/main/scala/leon/synthesis/SimpleSearch.scala
0 → 100644
+
62
−
0
View file @
99a20e07
package
leon
package
synthesis
import
synthesis.search._
case
class
TaskRunRule
(
problem
:
Problem
,
rule
:
Rule
,
app
:
RuleApplication
)
extends
AOAndTask
[
Solution
]
{
val
cost
=
RuleApplicationCost
(
rule
,
app
)
def
composeSolution
(
sols
:
List
[
Solution
])
:
Solution
=
{
app
.
onSuccess
(
sols
)
}
override
def
toString
=
rule
.
name
}
case
class
TaskTryRules
(
p
:
Problem
)
extends
AOOrTask
[
Solution
]
{
val
cost
=
ProblemCost
(
p
)
override
def
toString
=
p
.
toString
}
class
SimpleSearch
(
synth
:
Synthesizer
,
problem
:
Problem
,
rules
:
Set
[
Rule
])
extends
AndOrGraphSearch
[
TaskRunRule
,
TaskTryRules
,
Solution
](
new
AndOrGraph
(
TaskTryRules
(
problem
)))
{
import
synth.reporter._
val
sctx
=
SynthesisContext
.
fromSynthesizer
(
synth
)
def
processAndLeaf
(
t
:
TaskRunRule
)
=
{
val
prefix
=
"[%-20s] "
.
format
(
Option
(
t
.
rule
).
getOrElse
(
"?"
))
t
.
app
.
apply
()
match
{
case
RuleSuccess
(
sol
)
=>
info
(
prefix
+
"Got: "
+
t
.
problem
)
info
(
prefix
+
"Solved with: "
+
sol
)
ExpandSuccess
(
sol
)
case
RuleDecomposed
(
sub
,
onSuccess
)
=>
info
(
prefix
+
"Got: "
+
t
.
problem
)
info
(
prefix
+
"Decomposed into:"
)
for
(
p
<-
sub
)
{
info
(
prefix
+
" - "
+
p
)
}
Expanded
(
sub
.
map
(
TaskTryRules
(
_
)))
case
RuleApplicationImpossible
=>
ExpandFailure
()
}
}
def
processOrLeaf
(
t
:
TaskTryRules
)
=
{
val
sub
=
rules
.
flatMap
(
r
=>
r
.
attemptToApplyOn
(
sctx
,
t
.
p
).
alternatives
.
map
(
TaskRunRule
(
t
.
p
,
r
,
_
))
)
if
(!
sub
.
isEmpty
)
{
Expanded
(
sub
.
toList
)
}
else
{
ExpandFailure
()
}
}
}
This diff is collapsed.
Click to expand it.
src/main/scala/leon/synthesis/Synthesizer.scala
+
1
−
56
View file @
99a20e07
...
...
@@ -29,7 +29,7 @@ class Synthesizer(val reporter: Reporter,
def
synthesize
()
:
Solution
=
{
val
search
=
new
AO
Search
(
this
,
problem
,
rules
)
val
search
=
new
Simple
Search
(
this
,
problem
,
rules
)
val
sigINT
=
new
Signal
(
"INT"
)
var
oldHandler
:
SignalHandler
=
null
...
...
@@ -59,61 +59,6 @@ class Synthesizer(val reporter: Reporter,
res
.
getOrElse
(
Solution
.
choose
(
problem
))
}
case
class
TaskRunRule
(
problem
:
Problem
,
rule
:
Rule
,
app
:
RuleApplication
)
extends
AOAndTask
[
Solution
]
{
val
cost
=
RuleApplicationCost
(
rule
,
app
)
def
composeSolution
(
sols
:
List
[
Solution
])
:
Solution
=
{
app
.
onSuccess
(
sols
)
}
override
def
toString
=
rule
.
name
}
case
class
TaskTryRules
(
p
:
Problem
)
extends
AOOrTask
[
Solution
]
{
val
cost
=
ProblemCost
(
p
)
override
def
toString
=
p
.
toString
}
class
AOSearch
(
synth
:
Synthesizer
,
problem
:
Problem
,
rules
:
Set
[
Rule
])
extends
AndOrGraphSearch
[
TaskRunRule
,
TaskTryRules
,
Solution
](
new
AndOrGraph
(
TaskTryRules
(
problem
)))
{
val
sctx
=
SynthesisContext
.
fromSynthesizer
(
synth
)
def
processAndLeaf
(
t
:
TaskRunRule
)
=
{
val
prefix
=
"[%-20s] "
.
format
(
Option
(
t
.
rule
).
getOrElse
(
"?"
))
t
.
app
.
apply
()
match
{
case
RuleSuccess
(
sol
)
=>
info
(
prefix
+
"Got: "
+
t
.
problem
)
info
(
prefix
+
"Solved with: "
+
sol
)
ExpandSuccess
(
sol
)
case
RuleDecomposed
(
sub
,
onSuccess
)
=>
info
(
prefix
+
"Got: "
+
t
.
problem
)
info
(
prefix
+
"Decomposed into:"
)
for
(
p
<-
sub
)
{
info
(
prefix
+
" - "
+
p
)
}
Expanded
(
sub
.
map
(
TaskTryRules
(
_
)))
case
RuleApplicationImpossible
=>
ExpandFailure
()
}
}
def
processOrLeaf
(
t
:
TaskTryRules
)
=
{
val
sub
=
rules
.
flatMap
(
r
=>
r
.
attemptToApplyOn
(
sctx
,
t
.
p
).
alternatives
.
map
(
TaskRunRule
(
t
.
p
,
r
,
_
))
)
if
(!
sub
.
isEmpty
)
{
Expanded
(
sub
.
toList
)
}
else
{
ExpandFailure
()
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment