Bug 304374

Summary: Dynamic mode adds tracks which don't match the constraints
Product: [Applications] amarok Reporter: robert marshall <robert>
Component: Playlists/Dynamic PlaylistsAssignee: Amarok Developers <amarok-bugs-dist>
Severity: normal CC: karl, lrm.regs-15.07, Mathias.Homann, ralf-engels
Priority: NOR    
Version: 2.6.0   
Target Milestone: 2.7   
Platform: Ubuntu   
OS: Linux   
Latest Commit: Version Fixed In: 2.8

Description robert marshall 2012-08-01 11:12:11 UTC
I have the following dynamic playlist setup:
        <title>Not recent</title>
So abbreviating:
playcount:=0 OR lastplay:>180d OR (length:<540 and lastplay:>90d and playcount:<2)

However I'm frequently seeing tracks added to the playlist which were last played in the last 3 days.
If I filter the local music
playcount:=0 gives me 79 tracks
lastplay:>180d  - 550 tracks
length:<540 and lastplay:>90d and playcount:<2 - 30 tracks

So there should be > 600 tracks to choose from which satisfy the constraints (and none of them should be played more recently than 90 days). The length of the upcoming list is 40 tracks

Reproducible: Always

Steps to Reproduce:
1. set up a dynamic playlist as above
2.turn dynamic on
3.observe that tracks which don't satisfy constrains are added to the playlist
Actual Results:  
I'm seeing tracks played in the last few days being added (I've not noticed tracks played more than a week and < 90days in the list but that may be me forgetting that I've heard them!) Probably around 1 in 10 of the tracks added to the playlist are recently played tracks. I'm seeing tracks of any length appearing wrongly so it's not the final  condition with 'and's that's being ignored

Expected Results:  
I'd expect only tracks played more than 90 days ago (or never played) are added
Comment 1 Mathias Homann 2012-08-14 12:39:34 UTC
I can confirm this for amarok 2.5.0, dynamic contraint adds songs that have the wrong genre.
Comment 2 Myriam Schweingruber 2012-08-14 12:45:47 UTC
Confirmed with 2.6 final as well
Comment 3 Mathias Homann 2012-08-29 13:04:21 UTC
having metallica in the middle of bach fugues is really annoying... please fix this.
Comment 4 Leonardo M 2012-10-02 21:02:39 UTC
I can also confirm this bug for Amarok 2.5.0. At least, Genre and Lastplay constraints fail.
Comment 5 Karl Ove Hufthammer 2012-12-14 11:37:01 UTC
I can confirm this with the latest Amarok 2.6.0. I’m getting non-Christmas songs in the middle of a Christmas dynamic playlist.
Comment 6 Ralf Engels 2012-12-15 13:16:35 UTC
Hi all,
i am still be confused.

Admitted, the playlist will add tracks that don't fullfill the conditions if it runs out of valid candidates.

Also the playlist has an internal buffer of 50 tracks. Since tracks are also disregarded if they are in the recent history (let's assume a backlock of 10) you will need to have at least 60 valid tracks.

The last-played and playcount bias has a slight issue. Amarok is trying to buffer previous database queries until the collection was changed. However updating the playcount or the last played does only update one song and not the collection as such.
So you might actually run into this problem.

Still, genres are working. I have my own dynamic playlist here excluding audiobooks and I only ever incorrectly tagged audiobooks.

Could everybody please:
1. allow duplicate tracks in the playlist and check if that solves the problem
2. also post the dynamic playlist so that I can see if there are similarities.

Here is mine:
not genre:"Audiobook" and partition( 25%: not rating>2, 50%: rating>2, 25%: rating>3.5)
Comment 7 Karl Ove Hufthammer 2012-12-15 16:05:20 UTC
I can confirm that it happens even when allowing duplicate tracks. I observe the behaviour with this dynamic playlist (and previously others, but this is the one I tested now):

genre:Christmas and Rating:<1

(Ratings < 1 are tracks with no ratings, and I have a bunch (i.e., over 60) of them.)

One thing I have noticed is that when I click the ‘repopulate’ button, often all tracks fulfil the criteria. But when one track is finished playing and a new one is added at the end of the playlist that does not fulfil the critera, ~all tracks automatically added thereafter do not fulfil the criteria. So it seems like the search criteria gets lost, somehow.

This may be related: When I activate the ‘allow duplicates’ option, I often get an *enormous* amount of duplicates (in the same 5+10 track dynamic playlist), much more than would be expected. So perhaps the dynamic playlist doesn’t ‘find’ all eligible tracks, for some reason?
Comment 8 Karl Ove Hufthammer 2012-12-15 16:15:24 UTC
As an example of the amount of duplicates: I just repopulated the playlist (adding 10 tracks), and got 4 duplicates of one track (i.e. 1 track duplicated 4 times), 2 duplicates of a different track and 2 duplicates of a third track. Also, when repopulating, even several times, I get many of the same tracks again.

And it does look like I get tracks that don’t fulfil the search criteria much less often when I allow duplicate tracks, but it does still happen.
Comment 9 Ralf Engels 2012-12-15 23:41:51 UTC
do your really have over 60 unrated Christmas songs?
Everything that you are writing seems to indicate to me that you just don't have enough valid tracks.

I would guess that allowing duplicates solves the problem with the "unwanted" tracks (and causes another problem with duplicates).
Comment 10 Karl Ove Hufthammer 2012-12-16 08:24:08 UTC
Yes, I have 328 unrated Christmas songs.
Comment 11 Ralf Engels 2013-02-07 15:25:55 UTC
Git commit 093177d4d8f86098b75d4a2ff28e23d4d0ceba6d by Ralf Engels.
Committed on 06/02/2013 at 18:38.
Pushed by rengels into branch 'master'.

Update Dynamic playlist. Get rid of energy optimizing code

The dynamic playlist always used to optimize the generated tracks
by different ways.
However the new biases all have hard conditions. The user also
used to see it like this and was confused if a "pretty good" result
was generated.

The new algorithm will generate an empty list if the conditions
cannot be fullfilled
Related: bug 286642, bug 292648, bug 301716

M  +4    -0    ChangeLog
M  +10   -37   src/dynamic/Bias.cpp
M  +17   -31   src/dynamic/Bias.h
M  +46   -411  src/dynamic/BiasSolver.cpp
M  +21   -69   src/dynamic/BiasSolver.h
M  +6    -7    src/dynamic/BiasedPlaylist.cpp
M  +2    -1    src/dynamic/BiasedPlaylist.h
M  +7    -2    src/dynamic/TrackSet.cpp
M  +9    -7    src/dynamic/biases/AlbumPlayBias.cpp
M  +2    -2    src/dynamic/biases/AlbumPlayBias.h
M  +14   -15   src/dynamic/biases/EchoNestBias.cpp
M  +2    -3    src/dynamic/biases/EchoNestBias.h
M  +7    -11   src/dynamic/biases/IfElseBias.cpp
M  +3    -4    src/dynamic/biases/IfElseBias.h
M  +51   -39   src/dynamic/biases/PartBias.cpp
M  +3    -5    src/dynamic/biases/PartBias.h
M  +5    -4    src/dynamic/biases/QuizPlayBias.cpp
M  +2    -2    src/dynamic/biases/QuizPlayBias.h
M  +4    -5    src/dynamic/biases/TagMatchBias.cpp
M  +2    -2    src/dynamic/biases/TagMatchBias.h
M  +6    -6    src/services/lastfm/biases/LastFmBias.cpp
M  +2    -3    src/services/lastfm/biases/LastFmBias.h