Skip to content

Commit

Permalink
fix: empty or([]) being parsed as nothing
Browse files Browse the repository at this point in the history
Constant matrices inside operations were not recognised by our parser,
so were ignored. This includes expressions like or([]) and
min([1,2,3]).

- Add parsing support for constant matrices inside operations.

- Add support for top level "false" and "true" with Minion. Ideally,
  these models would never get passed to the solver; however, this would
  require solution evaluation and a refactor of our tester, so I have
  left this for future work.

Fixes #366.
  • Loading branch information
niklasdewally committed Oct 15, 2024
1 parent abcd9bc commit 0cb4f3b
Show file tree
Hide file tree
Showing 16 changed files with 497 additions and 31 deletions.
6 changes: 3 additions & 3 deletions conjure_oxide/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ pub fn main() -> AnyhowResult<()> {
.append(true)
.open("conjure_oxide.log")?;

//Builder::with_level("Trace")
Builder::new()
Builder::with_level("TRACE")
//Builder::new()
.with_target_writer("info", new_writer(stdout()))
.with_target_writer("file", new_writer(log_file))
.with_target_writer("file,jsonparser", new_writer(log_file))
.init();

if target_family != SolverFamily::Minion {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

$ "By mathematical tradition (and Essence semantics), an 'empty or' is false, however, this model has 5 answers (one for each value of a)"
$ -- https://github.com/conjure-cp/conjure-oxide/issues/366

find a : int(1..5)
such that
or([])
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"constraints": {
"Or": [
{
"clean": false,
"etype": null
},
[]
]
},
"next_var": 0,
"variables": [
[
{
"UserName": "a"
},
{
"domain": {
"IntDomain": [
{
"Bounded": [
1,
5
]
}
]
}
}
]
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"constraints": {
"Constant": [
{
"clean": false,
"etype": null
},
{
"Bool": false
}
]
},
"next_var": 0,
"variables": [
[
{
"UserName": "a"
},
{
"domain": {
"IntDomain": [
{
"Bounded": [
1,
5
]
}
]
}
}
]
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$ the parser would read the min as Nothing...
$ related: issue-366

find c : int(1..7)
such that min([5,7]) + c <= 10
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[
{
"UserName(c)": 1
},
{
"UserName(c)": 2
},
{
"UserName(c)": 3
},
{
"UserName(c)": 4
},
{
"UserName(c)": 5
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{
"constraints": {
"Leq": [
{
"clean": false,
"etype": null
},
{
"Sum": [
{
"clean": false,
"etype": null
},
[
{
"Min": [
{
"clean": false,
"etype": null
},
[
{
"Constant": [
{
"clean": false,
"etype": null
},
{
"Int": 5
}
]
},
{
"Constant": [
{
"clean": false,
"etype": null
},
{
"Int": 7
}
]
}
]
]
},
{
"Reference": [
{
"clean": false,
"etype": null
},
{
"UserName": "c"
}
]
}
]
]
},
{
"Constant": [
{
"clean": false,
"etype": null
},
{
"Int": 10
}
]
}
]
},
"next_var": 0,
"variables": [
[
{
"UserName": "c"
},
{
"domain": {
"IntDomain": [
{
"Bounded": [
1,
7
]
}
]
}
}
]
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"constraints": {
"SumLeq": [
{
"clean": false,
"etype": null
},
[
{
"Reference": [
{
"clean": false,
"etype": null
},
{
"UserName": "c"
}
]
}
],
{
"Constant": [
{
"clean": false,
"etype": null
},
{
"Int": 5
}
]
}
]
},
"next_var": 1,
"variables": [
[
{
"UserName": "c"
},
{
"domain": {
"IntDomain": [
{
"Bounded": [
1,
7
]
}
]
}
}
]
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,70 @@
]
]
},
{
"Or": [
{
"clean": false,
"etype": null
},
[
{
"AllDiff": [
{
"clean": false,
"etype": null
},
[
{
"Constant": [
{
"clean": false,
"etype": null
},
{
"Int": 1
}
]
},
{
"Constant": [
{
"clean": false,
"etype": null
},
{
"Int": 2
}
]
},
{
"Constant": [
{
"clean": false,
"etype": null
},
{
"Int": 3
}
]
}
]
]
},
{
"Constant": [
{
"clean": false,
"etype": null
},
{
"Bool": true
}
]
}
]
]
},
{
"And": [
{
Expand Down
Loading

0 comments on commit 0cb4f3b

Please sign in to comment.