简体   繁体   English

在OptaPlanner中处理层次约束的推荐方法是什么?

[英]What is the recommended way to handle a hierarchical constraint in OptaPlanner?

I'm trying to learn OptaPlanner by building a playlist generator. 我正在尝试通过构建播放列表生成器来学习OptaPlanner。 My constraints look roughly like: 我的约束大致如下:

  1. The total time must be ~60 minutes. 总时间必须为〜60分钟。
  2. All songs selected must be unique. 所选的所有歌曲必须唯一。
  3. Each ~15 minute block may contain only songs from a single artist. 每15分钟左右的音乐块只能包含一位歌手的歌曲。
  4. The four 15 minute blocks must be different artists. 四个15分钟的方块必须是不同的艺术家。

So by hierarchical, I mean you could choose the artist and then attempt to fill the block. 因此,通过分层,我的意思是您可以选择艺术家,然后尝试填补空白。

My current implementation expresses these as constraints on song selection. 我当前的实现将这些表示为歌曲选择的约束。 It's able to solve the problem, but I feel like it's spending a lot of time trying to align the artist constraint. 它可以解决问题,但是我觉得花很多时间试图调整艺术家的约束。

Reading through docs, it seems like there are some features which might be helpful: 通读文档,似乎有些功能可能会有所帮助:

  • Partitioned search 分区搜索
  • Chained variables 链接变量
  • Custom move selectors (eg changing all the songs to have consistent artist) 自定义移动选择器(例如,将所有歌曲更改为具有一致的歌手)
  • Different weighting on constraints 约束的权重不同

What's the recommended way to handle this type of relationship? 处理这种类型关系的推荐方法是什么?

Sounds like these are just 4 constraints with 4 different score levels (see docs chapter on score calculation). 听起来这些只是4种约束,具有4种不同的分数级别 (请参阅有关分数计算的文档章节)。 So in that case, you'll need a BendableScore . 因此,在这种情况下,您将需要BendableScore

In practice though, I would be surprised if 3. and 4. are hierarchical: 3 might just have a much heavier score weight than 4. In that case a HardMediumSoftScore suffices. 但是实际上,如果3.和4.是分层的,我会感到惊讶:3的得分权重可能比4 HardMediumSoftScore 。在这种情况下,使用HardMediumSoftScore

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM