Skip to content

Conversation

@SundermannC
Copy link
Member

No description provided.

st-vi and others added 30 commits September 13, 2024 14:18
…ontain doubles by encoding them in integer values
st-vi and others added 17 commits November 28, 2024 08:28
…ure cardinality subtree roots, expression contains feature from feature cardinality, unsatisfiable expression should return false and not throw error, several issues with opb division encoding, removed unnecessary overwrites of left and right in expression constraints, force order of featurecardinality and aggregate function conversion, several to string methods for better debugging, issues with whole number encoding because numbers get larger than long value, uniform substitution, simpler substitution code,
…vs tseitin style cross-tree constraint encoding)
Fixes for problems that occured during my master thesis
@SundermannC SundermannC changed the title Refactoring metamodel Refactor constraints, conversion strategies, and print Sep 1, 2025
@SundermannC
Copy link
Member Author

This PR comes with several changes to simplify the usage of constraints, conversion strategies, and printing.
In particular, the following is added:

Constraints

  • MultiOrConstraints and MultiAndConstraints that allow more than two children
  • Many convenience functions and bug fixes for using the constraints

Conversion strategies:

  • Many bug fixes that may occur when converting constraints
  • Conversion of feature cardinality that matches the description in the latest paper
  • Reorders conversions to prevent potential issues

Printing:

  • Enforces required brackets to maintain semantics of the models
  • Enforces required parentheses to prevent illegal names when printing
  • Adds test for correct bracket behavior

Copy link
Contributor

@coemgen1992 coemgen1992 left a comment

Choose a reason for hiding this comment

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

I only have some comments regarding comments and guarantees, which should be resolved. Besides that, the code looks good.

}
}
/*
additional constraint with all cloned versions ored
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a particular reason to leave the comments in?
Please remove these comments, otherwise.

Expression left = ((ExpressionConstraint) constraint).getLeft();
Expression right = ((ExpressionConstraint) constraint).getRight();
return expressionContains(left, subTreeFeatures) || expressionContains(right, subTreeFeatures);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This if-else statement is very specific.
Can we guarantee that there only will be these cases? If not, we may want to add some sort of log, error statement in an else branch of the cascade.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this makes sense. It should only be those three cases in this abstraction level:

  1. Found the atom to collect it
  2. Constraint is an expression, so we switch to "expression mode" for the traversal
  3. Traverse all subparts of the constraint

orConstraint.add_sub_part(constraint);
}
/*
Constraint orConstraint;
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as before. Please remove code in comments.

orConstraint.add_sub_part(constraint);
}
/*
Constraint orConstraint;
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove comments.

static {
constraintprecedenceLookup = new HashMap<>();

// n-ary
Copy link
Contributor

Choose a reason for hiding this comment

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

I am always a bit nervous on magic numbers in code.
Consider making the ordering clear with constants?

StringBuilder result = new StringBuilder();
for (Constraint part : sub_parts) {
result.append(AutomaticBrackets.enforceConstraintBracketsIfNecessary(this, part, withSubmodels, currentAlias));
result.append(" | ");
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to introduce a Symbol lookup at some point?

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense. I created an issue #20

@SundermannC
Copy link
Member Author

All comments should be addressed now. Pipeline sadly still fails due to the publishing issues. Locally all tests ran through.

@gravemalte
Copy link
Member

@SundermannC I will try to run it by myself next week.

@gravemalte
Copy link
Member

LGTM, nothing broke and code looks clean.

@SundermannC SundermannC merged commit 7a02ec0 into main Sep 22, 2025
1 check failed
@SundermannC SundermannC deleted the refactoring_metamodel branch September 22, 2025 07:38
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.

5 participants