-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Define behaviour for empty expressions #370
Conversation
2fe3b93
to
4d77c6f
Compare
we should also actually remove Nothing, shouldn't we? |
Will do. The reason why we are not deleting it yet is that we want to ensure that all empty rules work before deleting Nothing. |
4d77c6f
to
b57db0e
Compare
@YehorBoiar I've just merged some code that checks solutions against Conjure when running ACCEPT=true cargo test. |
Okay, thanks. |
fd50fcc
to
7e74b8a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in addition to removing nothing you introduce an if let
here, why is that?
crates/conjure_core/src/model.rs
Outdated
@@ -46,7 +46,7 @@ use crate::metadata::Metadata; | |||
pub struct Model { | |||
#[serde_as(as = "Vec<(_, _)>")] | |||
pub variables: SymbolTable, | |||
pub constraints: Expression, | |||
pub constraints: Option<Expression>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be a vector actually, instead of a top level and. then it can be empty if needed.
in fact we should probably have a top level vec of statements, including declarations etc, but we can discuss that later. for this pr, let's make constraints a vector.
@@ -130,10 +132,13 @@ pub fn rewrite_model<'a>( | |||
let apply_optimizations = optimizations_enabled(); | |||
|
|||
let start = std::time::Instant::now(); | |||
|
|||
let default_constraint = Expression::Constant(Metadata::new(), Constant::Int(1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when the top level is a vector we won't need magic values like this one...
|
||
Ok(Reduction::pure(new_expr)) | ||
} | ||
// #[register_rule(("Base", 8800))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't comment out code please, just remove it!
@@ -1,5 +1,5 @@ | |||
{ | |||
"constraints": "Nothing", | |||
"constraints": null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should always either have true
or false
instead of null here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: Given that this passes, it seems that null passes through to Minion without erroring: ideally, the Minion solver adaptor shouldn't support null
at all. You didn't introduce this functionality, so I don't think fixing it is necessary for this PR.
bd44406
to
bd5c7db
Compare
@ozgurakgun @niklasdewally I'm getting this error on rules now, but I don't understand why. Could you help?
|
@@ -63,7 +63,11 @@ pub struct Reduction { | |||
pub type ApplicationResult = Result<Reduction, ApplicationError>; | |||
|
|||
impl Reduction { | |||
pub fn new(new_expression: Expression, new_top: Expression, symbols: SymbolTable) -> Self { | |||
pub fn new( | |||
new_expression: Vec<Expression>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@YehorBoiar this shouldn't be a vec. it's the replacement expression, so you want to replace expression with expression. this is probably the reason for the error you are getting.
symbols: SymbolTable::new(), | ||
} | ||
} | ||
|
||
/// Represents a reduction that also modifies the symbol table. | ||
pub fn with_symbols(new_expression: Expression, symbols: SymbolTable) -> Self { | ||
pub fn with_symbols(new_expression: Vec<Expression>, symbols: SymbolTable) -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
propagate that change here too. we just want to change the constraints in the model (and new_top as well) to be a vec, not everything else.
just to make sure this is not blocked on me @YehorBoiar ? |
@ozgurakgun No, it's not. I was working on it, but got stuck at some point. I decided to take one day off this task and focus on gen_reduce for a little bit. I will start working on it either today's evening or tomorrow morning. I will write more details about the issue in case if I wouldn't resolve it. Thanks for double checking on me! |
bd5c7db
to
0863fe0
Compare
When I'm running
I'm not sure what caused it, and I don't know how to navigate this error message. @ozgurakgun @niklasdewally Do you have any idea how I can fix it? |
Seems like a rust bug, nothing to do with you or us.... Maybe try cargo clean and updating rust? Failing that, sending Rust a bug report (with the link above) would be the best move... |
Thanks! |
Hey! I forgot how to generate a parse, rewrite models when testing essence. Can somebody remind me how to do that? @niklasdewally @Soph1514 |
ACCEPT=true cargo test |
435dc50
to
a94ea05
Compare
What do the logs say? |
a94ea05
to
7e1b4f4
Compare
I'm getting failures on
I suspect that the reason for that is the fact that I deleted the rule that removes nothings. However, I tried to rewrite it to this, and it only made things worse (even less tests were passing and the results were chaotic)
@niklasdewally Do you think that it is the reason why we currently fail, or it could be something else in my implementation that went wrong? |
This is an error to do with reading the solutions against json output from Conjure, which happens after we run the model through oxide. Try to |
If you still suspect a rule issue, it might help to update your branch against main, as I have recently improved our logging output:
|
7e1b4f4
to
d021b9f
Compare
Sorry, for bother, I run the same script on my own machine, and it worked just fine. All tests are being passed. Please review @ozgurakgun |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a few comments for you
c85e827
to
e9423aa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@YehorBoiar you should update this branch to main; there are some merge conflicts due to f931a3d
e9423aa
to
4c2f093
Compare
For now, we would treat top as Expression::And(Metadata::new, Vec::new())
4c2f093
to
bc4cec6
Compare
Code and Documentation Coverage ReportDocumentation CoverageClick to view documentation coverage for this PR
Click to view documentation coverage for main
Code Coverage SummaryThis PR: Detailed Report
Main: Detailed Report
Coverage Main & PR Coverage ChangeLines coverage changed by 0.60% and covered lines changed by -6
Functions coverage changed by -0.10% and covered lines changed by -4
Branches... coverage: No comparison data available |
This PR is based on the Chris's and Oz's comment on Teams:
"
Chris:
I'd get existing PRs merged in first, but then it might be worth making a pass over empty constraints, I think (please check essence semantics , and I'm not sure which are implemented yet):
and([]) = true
or([]) = false
sum([]) = 0
product([]) = 1
it's worth getting these right because (from experience), while no-one is likely to write these, they often end up getting created as parts of more interesting expressions.
Oz:
min([]) and max([]) are a bit different, as min([])=x is always false, but this falseness will arise naturally from the fact they will end up turning into an 'and([])' and an 'or([])', and the or will be false, so there is no need to special-case empty min([]) and max([]) (hopefully!)
we can define an abstraction which has a zero vale and an append operator for these.
and is true, /
or is false, /
sum is 0, +
product is 1, *
regarding min and max, we already did a bunch of definedness work with Felix last semester (Soph and Yehor taking over this now)
"