Skip to content
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

Model builder pattern #22

Closed
wants to merge 8 commits into from

Conversation

lixitrixi
Copy link
Contributor

This is a continuation of work from #16. Rebasing has proven difficult so I have based this branch on the current merged changes and manually copied my work over.

@lixitrixi lixitrixi mentioned this pull request Oct 23, 2023
@ozgurakgun
Copy link
Contributor

Thanks Felix, you may have seen #23. Let's discuss which way is better at this point.

Hopefully the astjson-to-rust work shouldn't be affected by the underlying data structure too much.

@lixitrixi lixitrixi marked this pull request as ready for review October 27, 2023 00:13
src/common/ast/ast.rs Show resolved Hide resolved
#[derive(Clone, Debug, PartialEq)]
pub enum Domain {
BoolDomain,
IntDomain(Vec<Range<i32>>),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine for now, but at some point someone will have to write (or find) a lovely library for ranges of ranges -- at the moment the domains [0..3), [3..6), [0..3], [1..6) and [0..6) would all be different, despite them having the same underlying values. I'm sure at a later date there will be a demand for interesting + unioning such domains as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fully agreed

src/common/ast/ast.rs Outdated Show resolved Hide resolved
src/common/ast/model_builder.rs Show resolved Hide resolved
@ozgurakgun
Copy link
Contributor

can you try merging main onto this pr @lixitrixi ? I tried to fix the rustfmt github action by using a fixed version number, just want to see whether that worked.

@lixitrixi
Copy link
Contributor Author

I have removed the add_var_str method for now since it's just a less verbose in application version of the regular add_var method. Perhaps if this builder will be used for constructing models by hand we could have a "find" method which accepts a string, but it seems like we're skipping that and going straight to parsing from structured input.

@ozgurakgun
Copy link
Contributor

are we abandoninig this one or do you want to update it @lixitrixi ?

@lixitrixi
Copy link
Contributor Author

@ozgurakgun Was the code structure PR passing rustfmt before you merged it?

@lixitrixi lixitrixi marked this pull request as draft October 30, 2023 16:17
@lixitrixi
Copy link
Contributor Author

lixitrixi commented Oct 30, 2023

Was actually thinking... would it be better to add the methods like add_constraint to the model instead of a builder? The model already includes methods like update_domain, it could make sense to allow more changes for the purpose of rewriting a model. After this change we wouldn't need a builder anymore but would instead start with an empty model and populate it.

@ozgurakgun
Copy link
Contributor

sure!

if it was me I would write the astjson parser and see what kind of builder makes sense for that.

@lixitrixi
Copy link
Contributor Author

sure!

if it was me I would write the astjson parser and see what kind of builder makes sense for that.

That makes the most sense... I will close this and implement necessary model methods over on #32 as I work.

@lixitrixi lixitrixi closed this Oct 30, 2023
@lixitrixi lixitrixi deleted the model-builder-pattern branch October 31, 2023 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants