0

I don't know a lot about Java Streams, I'm learning about it right now but I'm trying to solve this problem if anyone has advice:

Say I'm doing job scheduling, and each job has a width X. When we do a new job with a different width, the machine has to be reconfigured, so we prefer to do all jobs of width X in a row. I'm trying to set up a soft score penalty if the next job in the queue has a different width.

 private Constraint customConstraint(ConstraintFactory constraintFactory) {
    return constraintFactory.forEach(Job.class)
        //filter down to jobs whose next job has a different width
        .penalize(HardSoftScore.ONE_SOFT)
        .asConstraint("Width change");
}

Or, if we use the hello world quickstart as an example, a penalty for when a teacher has to change rooms. Does anyone have advice? Thank you.

MattWolc24
  • 106
  • 1
  • 9
  • This question is impossible to answer without knowing what your domain model looks like. Unless you are asking for a domain model design as well, of course. – Lukáš Petrovický Jul 01 '23 at 07:12
  • @LukášPetrovický It is the same as the hello world quickstart. I've just renamed the Lesson class to Job. – MattWolc24 Jul 02 '23 at 19:20

1 Answers1

0

I would say you should adjust your domain model to use PlanningListVariable to assign jobs to machine. This will provide you with previous/next element reference and allow to write filter in you constraint comparing widths of your job.