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

Changing Model.constraints, and Reduction.new_top to be a Vec<Expression> #435

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

YehorBoiar
Copy link
Contributor

This PR is created to address the issue #421.

@YehorBoiar YehorBoiar marked this pull request as draft November 11, 2024 12:01
@YehorBoiar
Copy link
Contributor Author

YehorBoiar commented Nov 11, 2024

@niklasdewally @ozgurakgun Since we are changing Model.constraints to a Vec<Expression>, should we assume it will always contain only one expression, or is it acceptable to have multiple expressions in constraints?

I'm asking this because in rewrite_iteration expression is not a Vec<>, and I'm not sure how to handle that.

fn rewrite_iteration<'a>(
    expression: &'a Vec<Expression>, 
    model: &'a Model,
    rules: &'a Vec<&'a Rule<'a>>,
    apply_optimizations: bool,
    stats: &mut RewriterStats,
) -> Option<Reduction> {
    if apply_optimizations && expression.is_clean()  { // should we use expression.first in here???
        // Skip processing this expression if it's clean
        return None;
    }

    // Mark the expression as clean - will be marked dirty if any rule is applied
    let mut expression = expression.clone(); 

    let rule_results = apply_all_rules(&expression, model, rules, stats); // should we try to iterate through the Vector, or expression.first would be just fine?
    if let Some(new) = choose_rewrite(&rule_results, &expression) {
        // If a rule is applied, mark the expression as dirty
        return Some(new);
    }

    let mut sub = expression.children();
    for i in 0..sub.len() {
        if let Some(red) = rewrite_iteration(&sub[i], model, rules, apply_optimizations, stats) {
            sub[i] = red.new_expression;
            let res = expression.with_children(sub.clone());
            return Some(Reduction::new(res, red.new_top, red.symbols));
        }
    }
    // If all children are clean, mark this expression as clean
    if apply_optimizations {
        assert!(expression.children().iter().all(|c| c.is_clean()));
        expression.set_clean(true);
        return Some(Reduction::pure(expression));
    }
    None
}

@niklasdewally
Copy link
Collaborator

@niklasdewally @ozgurakgun Since we are changing Model.constraints to a Vec<Expression>, should we assume it will always contain only one expression, or is it acceptable to have multiple expressions in constraints?

We currently have a top level And containing many expressions, the top level vector would just replace this.

@ozgurakgun
Copy link
Contributor

Agreed. So the vector can, and often will, contain multiple expressions in it.

@ozgurakgun
Copy link
Contributor

to me it looks like rewrite_iteration should operate on expressions, not vectors. we aren't rewriting vectors of expressions at a time after all?

@YehorBoiar
Copy link
Contributor Author

Good point.

@YehorBoiar
Copy link
Contributor Author

I run into the same problem I had last time. For some reason on some models it's getting in an infinite loop, but I don't know exactly where and why. I'm planning to run it in a debug mode, but I don't know how. @niklasdewally Can you tell me how to do that?I want to run conjure_oxide/tests/integration/basic/div/01/input.essence

conjure_oxide/tests/generated_tests.rs Show resolved Hide resolved
&mut stats,
) {
step.apply(&mut new_model); // Apply side-effects (e.g. symbol table updates)
let constraints = new_model.constraints.clone();
Copy link
Contributor

Choose a reason for hiding this comment

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

fine for now, but just to note that in gen_reduce (or whatever it's called) this for loop shouldn't be necessary. it's a container containing expressions, the top level container can be a vector of expressions or just an expression, it shouldn't matter via uniplate/biplate. fyi @lixitrixi @niklasdewally @YehorBoiar

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, we can just use model.constraints.transform instead?

Copy link
Collaborator

@niklasdewally niklasdewally Nov 17, 2024

Choose a reason for hiding this comment

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

It would be a <_ as Biplate<Expr>>::descend_bi(constraints,fn) i think.

If you only want to operate on your immediate children, use descend not transform.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I have a mutable iterator in the roadmap which also work nicely here, but for now descend_bi is the better option.

@ozgurakgun
Copy link
Contributor

is the debugging section here useful: https://code.visualstudio.com/docs/languages/rust

assuming you are using vs code.

@niklasdewally
Copy link
Collaborator

niklasdewally commented Nov 12, 2024

RUST_LOG= cargo run -- --verbose

INFO is the default log level, if thats all you need, no need to set rustlog, just use --verbose.

INFO logs will give you "rule was applied", which might be enough, otherwise use TRACE.

I would try info first as trace is very chatty...

@niklasdewally
Copy link
Collaborator

is the debugging section here useful: https://code.visualstudio.com/docs/languages/rust

assuming you are using vs code.

If not, the default binaries created by cargo build, stored in target/debug, have debug symbols for rust-gdb.

@ozgurakgun
Copy link
Contributor

I cancelled the CI runs manually and added time limits to CI jobs in #437

@YehorBoiar YehorBoiar force-pushed the exp_to_vector branch 2 times, most recently from ef509c5 to e897aff Compare November 15, 2024 14:52
Copy link
Contributor

Code and Documentation Coverage Report

Documentation Coverage

Click to view documentation coverage for this PR
+-------------------------------------+------------+------------+------------+------------+
| File                                | Documented | Percentage |   Examples | Percentage |
+-------------------------------------+------------+------------+------------+------------+
| crates/conjure_macros/src/lib.rs    |          2 |      66.7% |          1 |      33.3% |
+-------------------------------------+------------+------------+------------+------------+
| Total                               |          2 |      66.7% |          1 |      33.3% |
+-------------------------------------+------------+------------+------------+------------+
+-------------------------------------+------------+------------+------------+------------+
| File                                | Documented | Percentage |   Examples | Percentage |
+-------------------------------------+------------+------------+------------+------------+
| ...m_compatability_macro/src/lib.rs |          2 |     100.0% |          1 |      50.0% |
+-------------------------------------+------------+------------+------------+------------+
| Total                               |          2 |     100.0% |          1 |      50.0% |
+-------------------------------------+------------+------------+------------+------------+
+-------------------------------------+------------+------------+------------+------------+
| File                                | Documented | Percentage |   Examples | Percentage |
+-------------------------------------+------------+------------+------------+------------+
| crates/tree_morph/src/commands.rs   |          1 |     100.0% |          0 |       0.0% |
| crates/tree_morph/src/helpers.rs    |          0 |       0.0% |          0 |       0.0% |
| crates/tree_morph/src/lib.rs        |          1 |     100.0% |          1 |     100.0% |
| crates/tree_morph/src/reduce.rs     |          2 |     100.0% |          0 |       0.0% |
| crates/tree_morph/src/reduction.rs  |          0 |       0.0% |          0 |       0.0% |
| crates/tree_morph/src/rule.rs       |          0 |       0.0% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+
| Total                               |          4 |      40.0% |          1 |      33.3% |
+-------------------------------------+------------+------------+------------+------------+
+-------------------------------------+------------+------------+------------+------------+
| File                                | Documented | Percentage |   Examples | Percentage |
+-------------------------------------+------------+------------+------------+------------+
| solvers/kissat/src/lib.rs           |          0 |       0.0% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+
| Total                               |          0 |       0.0% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+
+-------------------------------------+------------+------------+------------+------------+
| File                                | Documented | Percentage |   Examples | Percentage |
+-------------------------------------+------------+------------+------------+------------+
| solvers/minion/src/ast.rs           |         11 |      11.0% |          0 |       0.0% |
| solvers/minion/src/error.rs         |          8 |     100.0% |          0 |       0.0% |
| solvers/minion/src/lib.rs           |          1 |     100.0% |          1 |     100.0% |
| solvers/minion/src/run.rs           |          2 |     100.0% |          1 |     100.0% |
| solvers/minion/src/wrappers.rs      |          1 |     100.0% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+
| Total                               |         23 |      20.5% |          2 |      11.8% |
+-------------------------------------+------------+------------+------------+------------+
+-------------------------------------+------------+------------+------------+------------+
| File                                | Documented | Percentage |   Examples | Percentage |
+-------------------------------------+------------+------------+------------+------------+
| .../conjure_core/src/ast/domains.rs |          0 |       0.0% |          0 |       0.0% |
| ...jure_core/src/ast/expressions.rs |         24 |      92.3% |          0 |       0.0% |
| ...s/conjure_core/src/ast/factor.rs |          1 |      33.3% |          0 |       0.0% |
| ...conjure_core/src/ast/literals.rs |          1 |      33.3% |          0 |       0.0% |
| crates/conjure_core/src/ast/mod.rs  |          0 |       0.0% |          0 |       0.0% |
| ...ure_core/src/ast/symbol_table.rs |          0 |       0.0% |          0 |       0.0% |
| ...es/conjure_core/src/ast/types.rs |          0 |       0.0% |          0 |       0.0% |
| ...onjure_core/src/ast/variables.rs |          1 |      50.0% |          0 |       0.0% |
| crates/conjure_core/src/bug.rs      |          1 |      50.0% |          1 |      50.0% |
| crates/conjure_core/src/context.rs  |          0 |       0.0% |          0 |       0.0% |
| crates/conjure_core/src/error.rs    |          1 |      14.3% |          0 |       0.0% |
| crates/conjure_core/src/lib.rs      |          0 |       0.0% |          0 |       0.0% |
| crates/conjure_core/src/metadata.rs |          0 |       0.0% |          0 |       0.0% |
| crates/conjure_core/src/model.rs    |          2 |      12.5% |          0 |       0.0% |
| ...core/src/parse/example_models.rs |          2 |     100.0% |          0 |       0.0% |
| ...es/conjure_core/src/parse/mod.rs |          0 |       0.0% |          0 |       0.0% |
| ...re_core/src/parse/parse_model.rs |          0 |       0.0% |          0 |       0.0% |
| ...jure_core/src/rule_engine/mod.rs |          5 |      71.4% |          5 |      71.4% |
| ...src/rule_engine/resolve_rules.rs |          3 |     100.0% |          0 |       0.0% |
| ..._core/src/rule_engine/rewrite.rs |          2 |      66.7% |          0 |       0.0% |
| ...ure_core/src/rule_engine/rule.rs |          3 |      25.0% |          1 |     100.0% |
| ...core/src/rule_engine/rule_set.rs |          4 |     100.0% |          0 |       0.0% |
| ...njure_core/src/rules/constant.rs |          1 |     100.0% |          0 |       0.0% |
| ...es/conjure_core/src/rules/mod.rs |          1 |     100.0% |          0 |       0.0% |
| ...re/src/solver/adaptors/kissat.rs |          1 |     100.0% |          0 |       0.0% |
| ...re/src/solver/adaptors/minion.rs |          1 |     100.0% |          0 |       0.0% |
| ..._core/src/solver/adaptors/mod.rs |          1 |     100.0% |          0 |       0.0% |
| ...s/conjure_core/src/solver/mod.rs |         14 |      33.3% |          1 |       4.2% |
| ...ore/src/solver/model_modifier.rs |          7 |      70.0% |          0 |       0.0% |
| ...onjure_core/src/solver/states.rs |          7 |      63.6% |          0 |       0.0% |
| ...es/conjure_core/src/stats/mod.rs |          0 |       0.0% |          0 |       0.0% |
| ...core/src/stats/rewriter_stats.rs |          1 |      20.0% |          0 |       0.0% |
| ...e_core/src/stats/solver_stats.rs |          3 |      37.5% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+
| Total                               |         87 |      41.0% |          8 |       9.9% |
+-------------------------------------+------------+------------+------------+------------+
+-------------------------------------+------------+------------+------------+------------+
| File                                | Documented | Percentage |   Examples | Percentage |
+-------------------------------------+------------+------------+------------+------------+
| conjure_oxide/src/defaults.rs       |          1 |      50.0% |          0 |       0.0% |
| conjure_oxide/src/find_conjure.rs   |          1 |      50.0% |          0 |       0.0% |
| conjure_oxide/src/lib.rs            |          0 |       0.0% |          0 |       0.0% |
| conjure_oxide/src/utils/conjure.rs  |          0 |       0.0% |          0 |       0.0% |
| conjure_oxide/src/utils/json.rs     |          2 |      66.7% |          0 |       0.0% |
| conjure_oxide/src/utils/misc.rs     |          0 |       0.0% |          0 |       0.0% |
| conjure_oxide/src/utils/mod.rs      |          0 |       0.0% |          0 |       0.0% |
| conjure_oxide/src/utils/testing.rs  |          0 |       0.0% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+
| Total                               |          4 |      12.9% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+
Click to view documentation coverage for main
+-------------------------------------+------------+------------+------------+------------+
| File                                | Documented | Percentage |   Examples | Percentage |
+-------------------------------------+------------+------------+------------+------------+
| crates/conjure_macros/src/lib.rs    |          2 |      66.7% |          1 |      33.3% |
+-------------------------------------+------------+------------+------------+------------+
| Total                               |          2 |      66.7% |          1 |      33.3% |
+-------------------------------------+------------+------------+------------+------------+
+-------------------------------------+------------+------------+------------+------------+
| File                                | Documented | Percentage |   Examples | Percentage |
+-------------------------------------+------------+------------+------------+------------+
| ...m_compatability_macro/src/lib.rs |          2 |     100.0% |          1 |      50.0% |
+-------------------------------------+------------+------------+------------+------------+
| Total                               |          2 |     100.0% |          1 |      50.0% |
+-------------------------------------+------------+------------+------------+------------+
+-------------------------------------+------------+------------+------------+------------+
| File                                | Documented | Percentage |   Examples | Percentage |
+-------------------------------------+------------+------------+------------+------------+
| crates/tree_morph/src/commands.rs   |          1 |     100.0% |          0 |       0.0% |
| crates/tree_morph/src/helpers.rs    |          0 |       0.0% |          0 |       0.0% |
| crates/tree_morph/src/lib.rs        |          1 |     100.0% |          1 |     100.0% |
| crates/tree_morph/src/reduce.rs     |          2 |     100.0% |          0 |       0.0% |
| crates/tree_morph/src/reduction.rs  |          0 |       0.0% |          0 |       0.0% |
| crates/tree_morph/src/rule.rs       |          0 |       0.0% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+
| Total                               |          4 |      40.0% |          1 |      33.3% |
+-------------------------------------+------------+------------+------------+------------+
+-------------------------------------+------------+------------+------------+------------+
| File                                | Documented | Percentage |   Examples | Percentage |
+-------------------------------------+------------+------------+------------+------------+
| solvers/minion/src/ast.rs           |         11 |      11.0% |          0 |       0.0% |
| solvers/minion/src/error.rs         |          8 |     100.0% |          0 |       0.0% |
| solvers/minion/src/lib.rs           |          1 |     100.0% |          1 |     100.0% |
| solvers/minion/src/run.rs           |          2 |     100.0% |          1 |     100.0% |
| solvers/minion/src/wrappers.rs      |          1 |     100.0% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+
| Total                               |         23 |      20.5% |          2 |      11.8% |
+-------------------------------------+------------+------------+------------+------------+
+-------------------------------------+------------+------------+------------+------------+
| File                                | Documented | Percentage |   Examples | Percentage |
+-------------------------------------+------------+------------+------------+------------+
| .../conjure_core/src/ast/domains.rs |          0 |       0.0% |          0 |       0.0% |
| ...jure_core/src/ast/expressions.rs |         24 |      92.3% |          0 |       0.0% |
| ...s/conjure_core/src/ast/factor.rs |          1 |      33.3% |          0 |       0.0% |
| ...conjure_core/src/ast/literals.rs |          1 |      33.3% |          0 |       0.0% |
| crates/conjure_core/src/ast/mod.rs  |          0 |       0.0% |          0 |       0.0% |
| ...ure_core/src/ast/symbol_table.rs |          0 |       0.0% |          0 |       0.0% |
| ...es/conjure_core/src/ast/types.rs |          0 |       0.0% |          0 |       0.0% |
| ...onjure_core/src/ast/variables.rs |          1 |      50.0% |          0 |       0.0% |
| crates/conjure_core/src/bug.rs      |          1 |      50.0% |          1 |      50.0% |
| crates/conjure_core/src/context.rs  |          0 |       0.0% |          0 |       0.0% |
| crates/conjure_core/src/error.rs    |          1 |      14.3% |          0 |       0.0% |
| crates/conjure_core/src/lib.rs      |          0 |       0.0% |          0 |       0.0% |
| crates/conjure_core/src/metadata.rs |          0 |       0.0% |          0 |       0.0% |
| crates/conjure_core/src/model.rs    |          2 |      12.5% |          0 |       0.0% |
| ...core/src/parse/example_models.rs |          2 |     100.0% |          0 |       0.0% |
| ...es/conjure_core/src/parse/mod.rs |          0 |       0.0% |          0 |       0.0% |
| ...re_core/src/parse/parse_model.rs |          0 |       0.0% |          0 |       0.0% |
| ...jure_core/src/rule_engine/mod.rs |          5 |      71.4% |          5 |      71.4% |
| ...src/rule_engine/resolve_rules.rs |          3 |     100.0% |          0 |       0.0% |
| ..._core/src/rule_engine/rewrite.rs |          2 |      66.7% |          0 |       0.0% |
| ...ure_core/src/rule_engine/rule.rs |          3 |      25.0% |          1 |     100.0% |
| ...core/src/rule_engine/rule_set.rs |          4 |     100.0% |          0 |       0.0% |
| ...njure_core/src/rules/constant.rs |          1 |     100.0% |          0 |       0.0% |
| ...es/conjure_core/src/rules/mod.rs |          1 |     100.0% |          0 |       0.0% |
| ...re/src/solver/adaptors/kissat.rs |          1 |     100.0% |          0 |       0.0% |
| ...re/src/solver/adaptors/minion.rs |          1 |     100.0% |          0 |       0.0% |
| ..._core/src/solver/adaptors/mod.rs |          1 |     100.0% |          0 |       0.0% |
| ...s/conjure_core/src/solver/mod.rs |         14 |      33.3% |          1 |       4.2% |
| ...ore/src/solver/model_modifier.rs |          7 |      70.0% |          0 |       0.0% |
| ...onjure_core/src/solver/states.rs |          7 |      63.6% |          0 |       0.0% |
| ...es/conjure_core/src/stats/mod.rs |          0 |       0.0% |          0 |       0.0% |
| ...core/src/stats/rewriter_stats.rs |          1 |      20.0% |          0 |       0.0% |
| ...e_core/src/stats/solver_stats.rs |          3 |      37.5% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+
| Total                               |         87 |      41.0% |          8 |       9.9% |
+-------------------------------------+------------+------------+------------+------------+
+-------------------------------------+------------+------------+------------+------------+
| File                                | Documented | Percentage |   Examples | Percentage |
+-------------------------------------+------------+------------+------------+------------+
| conjure_oxide/src/defaults.rs       |          1 |      50.0% |          0 |       0.0% |
| conjure_oxide/src/find_conjure.rs   |          1 |      50.0% |          0 |       0.0% |
| conjure_oxide/src/lib.rs            |          0 |       0.0% |          0 |       0.0% |
| conjure_oxide/src/utils/conjure.rs  |          0 |       0.0% |          0 |       0.0% |
| conjure_oxide/src/utils/json.rs     |          2 |      66.7% |          0 |       0.0% |
| conjure_oxide/src/utils/misc.rs     |          0 |       0.0% |          0 |       0.0% |
| conjure_oxide/src/utils/mod.rs      |          0 |       0.0% |          0 |       0.0% |
| conjure_oxide/src/utils/testing.rs  |          0 |       0.0% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+
| Total                               |          4 |      12.9% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+
+-------------------------------------+------------+------------+------------+------------+
| File                                | Documented | Percentage |   Examples | Percentage |
+-------------------------------------+------------+------------+------------+------------+
| solvers/kissat/src/lib.rs           |          0 |       0.0% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+
| Total                               |          0 |       0.0% |          0 |       0.0% |
+-------------------------------------+------------+------------+------------+------------+

Code Coverage Summary

This PR: Detailed Report

  lines......: 64.9% (2843 of 4383 lines)
  functions..: 50.7% (275 of 542 functions)
  branches...: no data found

Main: Detailed Report

  lines......: 72.5% (3455 of 4764 lines)
  functions..: 58.8% (359 of 611 functions)
  branches...: no data found

Coverage Main & PR Coverage Change

Lines coverage changed by -7.60% and covered lines changed by -612
Functions coverage changed by -8.10% and covered lines changed by -84
Branches... coverage: No comparison data available

@YehorBoiar
Copy link
Contributor Author

@ozgurakgun I don't understand how apply() function should be written.

Here is what I understand:
Our model is still a conjunction of rules. Previously, we represented this conjunction as a single Expression, and the apply() function rewrote the entire tree into a new_expression plus new_top (if it existed) after applying reductions.

Although we changed the constraint field in our model construct, it’s still a conjunction. However, this change affects how we apply rules to it.

Here is what my approach was:
I iterate through the vector of constraints and try to reduce each constraint separately. I don’t check if new_top is empty; I always add it to the constraint vector. After that, I replace the current model with the reduced model obtained from rewrite_iteration.

My approach doesn't work, and I can't figure out why.

@niklasdewally
Copy link
Collaborator

niklasdewally commented Nov 15, 2024

@YehorBoiar curious that it just seems to be the test tests_integration_eprime_minion_bool_literals_to_wlit_1 that failed...
Run this test through cargo run and stick the logs on pastebin/gist and I'll be happy to take a look

@niklasdewally
Copy link
Collaborator

I've took a quick look, and it seems that we have a stray FactorE in the final model that hasn't been ran through boolean_literal_to_wliteral for whatever reason

@ozgurakgun
Copy link
Contributor

@YehorBoiar - did you see my comment above? you didn't respond to that.

@YehorBoiar
Copy link
Contributor Author

@niklasdewally Do you have any clues why it could happen?

@niklasdewally
Copy link
Collaborator

@niklasdewally Do you have any clues why it could happen?

I'm not too familiar with this PR or the rewriter in general unfortunately.

Copy link
Contributor

@ozgurakgun ozgurakgun left a comment

Choose a reason for hiding this comment

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

left a comment, please take a look Yehor. I can try to build this PR locally if you get stuck.

// Apply side-effects (e.g. symbol table updates
pub fn apply(self, model: &mut Model) {
// Apply side-effects (e.g. symbol table updates)
pub fn apply(self, model: &mut Model, constraint_idx: usize) {
Copy link
Contributor

Choose a reason for hiding this comment

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

passing the constraint id into apply looks suspicious to me. why do you need to do this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We needed this to target reductions to a specific constraint instead of applying them to the whole model like before. But I just realized how this could go wrong. For instance, if we add a constraint to the start of the model, we would not attempt to apply reductions to it, leaving one dirty node that never gets processed.

I’ll try applying reductions to the entire vector of constraints each time we attempt to reduce the model. If my assumption is correct, this should work!

Copy link
Contributor Author

@YehorBoiar YehorBoiar Nov 18, 2024

Choose a reason for hiding this comment

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

I tried naively implement it through the while loop

    let mut changed = true;
    while changed {
        changed = false; // Reset change tracker

        // Iterate over all constraints
        for i in 0..new_model.constraints.len() {
            while let Some(step) = rewrite_iteration(
                &new_model.constraints[i],
                &new_model,
                &rules,
                apply_optimizations,
                &mut stats,
            ) {
                step.apply(&mut new_model, i); // Apply reduction
                changed = true; // Track that a change occurred
            }
        }
    }    

but it didn't work either.

Addressing your suspicion, I could try to pass a direct reference to a constraint in apply() function, but I don't see how it would be different from what I am doing right now.

Copy link
Collaborator

Choose a reason for hiding this comment

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

For instance, if we add a constraint to the start of the model, we would not attempt to apply reductions to it, leaving one dirty node that never gets processed.

Shouldn't it rewrite until the entire model is clean?

Copy link
Contributor

Choose a reason for hiding this comment

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

On further reflection I think this is a stop gap, working constraint by constraint, but we should make it work like this before designing the ultimate version. I'll try this afternoon to see what's breaking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@niklasdewally Yes, it should, and I was thinking that it doesn't so I tried to fix it. Apparently, it wasn't the problem

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ozgurakgun Okay, thank you for help!

Copy link
Contributor

Choose a reason for hiding this comment

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

sorry I am failing to find time to look into this, but it's on the list. feel free to keep trying :)

updating the branch to track main is probably a good idea.

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