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

Serial filter(...) expr: all filters but the first are missing in the generated code #90

Open
maxkratz opened this issue Dec 15, 2022 · 1 comment
Labels
bug Something isn't working still broken Issue/Bug is not resolved when adding this label

Comments

@maxkratz
Copy link
Member

In some cases, serial filter(...) expressions break the filter semantics.
Example: Echtzeitsysteme/gips-tests#31

constraint -> global {
	mappings.n2n
	->filter(m | m.nodes().vnode.resourceDemand == 0)
	->filter(m | m.nodes().snode.resourceAmountTotal == 0)
	->count() == 0
}

Problem (if I understand it correctly):
If the first filter expression (in this case ->filter(m | m.nodes().vnode.resourceDemand == 0)) filters nothing out, i.e., the result should not be an empty set, the second filter(...) operation could not be triggered and, therefore, the count() does not evaluate to 0?

@maxkratz
Copy link
Member Author

Update: If I understand it correctly, the second filter expression is simply missing in the generated Java code. The expression above compiles to:

[...]
	protected void builder_0(final List<ILPTerm> terms) {
		for(N2nMapping itr_0 : engine.getMapper("n2n").getMappings().values().parallelStream()
			.map(mapping -> (N2nMapping) mapping)
			.filter(itr_0 -> itr_0.getVnode().getResourceDemand() == 0).collect(Collectors.toList())) {
			terms.add(new ILPTerm(itr_0, (double)1.0));
				}
	}
[...]

@maxkratz maxkratz changed the title Serial filter(...) expr: In some cases this breaks semantics Serial filter(...) expr: all filters but the first are missing in the generated code Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working still broken Issue/Bug is not resolved when adding this label
Projects
None yet
Development

No branches or pull requests

1 participant