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

Filters for KOptListMove don't work yet? #572

Open
AlexeyTrefilov opened this issue Jan 16, 2024 · 5 comments
Open

Filters for KOptListMove don't work yet? #572

AlexeyTrefilov opened this issue Jan 16, 2024 · 5 comments
Labels
bug Something isn't working process/needs triage Requires initial assessment of validity, priority etc.

Comments

@AlexeyTrefilov
Copy link

AlexeyTrefilov commented Jan 16, 2024

Hello.
Describe the bug
After you made KOptListMove public, I tried to create trivial filter for it, but it didn't work. https://stackoverflow.com/questions/77619677/timefold-is-it-possible-to-filter-out-all-trivial-2opt-moves-for-planninglistva.

public class KOptFilter implements SelectionFilter<Table, KOptListMove> {
    @Override
    public boolean accept(ScoreDirector<Table> scoreDirector, KOptListMove kOptListMove) {
        System.out.println(kOptListMove.getSimpleMoveTypeDescription() +" "+kOptListMove.getPlanningEntities().size()+" "+kOptListMove.getPlanningValues().size());
        System.out.println(kOptListMove);
        return true;
    }
}

Expected behavior
I expected some information in log, which would help me to understand, how filter out moves with firstEndpointIndex == secondEndpointIndex + 1

Actual behavior
But I haven't got any information in log. Instead I've got warning messages:
2024-01-16 11:26:26,118 WARN [ai.tim.sol.cor.imp.heu.sel.mov.dec.FilteringMoveSelector] (pool-7-thread-1) Bailing out of neverEnding selector (Filtering(ai.timefold.solver.core.impl.heuristic.selector.move.generic.list.kopt.KOptListMoveSelector@4b8a1b5)) after (0) attempts to avoid infinite loop.
And looks like k-opt moves weren't accepted at all. I couldn't find any "firstEndpointIndex" in log.

To Reproduce
Create any filter for KOptListMove

Environment

Timefold Solver Version or Git ref:
1.6.0

Output of java -version:
java version "21" 2023-09-19 LTS
Java(TM) SE Runtime Environment (build 21+35-LTS-2513)
Java HotSpot(TM) 64-Bit Server VM (build 21+35-LTS-2513, mixed mode, sharing)

Output of uname -a or ver:
Microsoft Windows [Version 10.0.22621.3007]

@AlexeyTrefilov AlexeyTrefilov added bug Something isn't working process/needs triage Requires initial assessment of validity, priority etc. labels Jan 16, 2024
@triceo
Copy link
Contributor

triceo commented Jan 16, 2024

Hello @AlexeyTrefilov,

thanks for reporting. There are good reasons why K-Opt moves would be filtered out even before the selection got to your filter. (For example, in cases where we could not find a single valid K-Opt move in your data set.) It could also be a bug in our code.

It is impossible to say which is the case without being able to step through the code. Please provide something that we can run on our end to see the problem.

@triceo
Copy link
Contributor

triceo commented Jan 16, 2024

(Also: we have already pre-filtered trivial K-Opt moves, and the way to filter out K-Opts of any particular K is to configure it using the minimumK and maximumK parameters. Therefore there should be no need for custom K-Opt filtering.)

@AlexeyTrefilov
Copy link
Author

AlexeyTrefilov commented Jan 16, 2024

Hello @AlexeyTrefilov,

thanks for reporting. There are good reasons why K-Opt moves would be filtered out even before the selection got to your filter. (For example, in cases where we could not find a single valid K-Opt move in your data set.) It could also be a bug in our code.

It is impossible to say which is the case without being able to step through the code. Please provide something that we can run on our end to see the problem.

If I remove filter from config, warnings will disappear and k-opt moves will return. Could you just add any trivial KOptListMove filter to any your model with KOptListMoves to reproduce the problem?

@AlexeyTrefilov
Copy link
Author

AlexeyTrefilov commented Jan 16, 2024

(Also: we have already pre-filtered trivial K-Opt moves, and the way to filter out K-Opts of any particular K is to configure it using the minimumK and maximumK parameters. Therefore there should be no need for custom K-Opt filtering.)

As I've mentioned, I want to filter out moves with firstEndpointIndex == secondEndpointIndex + 1, which reverse full route. I don't need them.

@triceo
Copy link
Contributor

triceo commented Jan 16, 2024

@AlexeyTrefilov Thanks for the information.
We'll look into this if/when time permits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working process/needs triage Requires initial assessment of validity, priority etc.
Projects
None yet
Development

No branches or pull requests

2 participants