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

Fix faulty behaviour of #1114 #1117

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open

Conversation

ArthurGodet
Copy link
Collaborator

Replace the TaskMonitor by arithm constraints
Update code of Cumulative implementations to update start + duration = end relation as soon as possible

The only problem of this implementation is that it might slow down a bit the solving process, as arithm constraints and cumulative constraints might do a ping-pong (however, it should not happen if the relation is well propagated inside cumulative filter implementations, but I could not find where it was not done fine). I have spotted such a slow down in CumulativeTest.test6() which is now taking 1.5s, instead of 0.5s (but no slow down on other testing methods).

That said, I tested on the new implementations of cumulative and disjunctive constraints I am working on, and no slow down has been spotted in these. So it is up to you to wait for this bigger Pull Request, or to accept this quick fix.

@ArthurGodet
Copy link
Collaborator Author

Failing tests seem to come from performance issues of the Cumulative constraint (for xcsp failing test, it seems to come from a greater number of nodes, which is a bit odd, as new implementation should not induce a weaker filtering).

To investigate

h[i].updateLowerBound(0, aCause);
s[i].updateBounds(e[i].getLB() - d[i].getUB(), e[i].getUB() - d[i].getLB(), aCause);
e[i].updateBounds(s[i].getLB() + d[i].getLB(), s[i].getUB() + d[i].getUB(), aCause);
d[i].updateBounds(e[i].getLB() - s[i].getUB(), e[i].getUB() - s[i].getLB(), aCause);
Copy link
Contributor

Choose a reason for hiding this comment

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

if domains are enumerated, you might need to loop

@@ -56,4 +56,15 @@ public CumulFilter(int nbMaxTasks){
* @throws ContradictionException
*/
public abstract void filter(IntVar[] s, IntVar[] d, IntVar[] e, IntVar[] h, IntVar capa, ISet tasks, Propagator<IntVar> aCause) throws ContradictionException;

protected void propStartDurationEndRelation(IntVar[] s, IntVar[] d, IntVar[] e, IntVar[] h, Propagator<IntVar> aCause) throws ContradictionException {
Copy link
Contributor

Choose a reason for hiding this comment

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

what if we don't do that at all and leave it to arithm ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As I said, the idea is to avoid a ping-pong between arithm constraints and the cumulative one, as the latter could be long to initiate. But maybe it is OK to allow it

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok I found a new reason : some filtering algorithms rely on the hypothesis of the task relation, especially the one in NRJCumulFilter

But I still can't really explain why we have the performance issues

Copy link
Member

Choose a reason for hiding this comment

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

I think the slow donw mainly comes from the fact that, with views, only the modified tasks are updated and with the proposal all of them are updated.

Copy link
Member

Choose a reason for hiding this comment

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

One possible way to avoid iterating over all tasks is to use IVariableMonitor to store modified tasks and only iterate over them. This is, for example, what is done in ActivityBased search.

…cy() + loop in CumulFilter.propStartDurationEndRelation() for enumerated domains
@cprudhom cprudhom changed the base branch from master to develop January 8, 2025 16:22
@@ -29,7 +28,7 @@
* @author Jean-Guillaume Fages
* @since 04/02/2013
*/
public class Task {
public class Task implements ICause {
Copy link
Member

Choose a reason for hiding this comment

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

I'm confused: the Task object was initially designed to maintain the relationship between start, duration and end during propagation. Now, if the relation is maintained explicitly by propagators, what is the purpose of Task ?

@@ -147,7 +151,15 @@ private void declareMonitor() {
* @throws ContradictionException thrown if a inconsistency has been detected between start, end and duration
*/
public void ensureBoundConsistency() throws ContradictionException {
Copy link
Member

Choose a reason for hiding this comment

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

Here again, is this method still relevant?

@@ -106,6 +106,8 @@ public void test5(){

@Test(groups="10s", timeOut=60000)
public void test6(){
long time = System.currentTimeMillis();
Copy link
Member

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 removed

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