Skip to content

Instantly share code, notes, and snippets.

@ge0ffrey
Last active October 3, 2018 13:11
Show Gist options
  • Save ge0ffrey/b63acfbc5baad6d1548d4863405dc27a to your computer and use it in GitHub Desktop.
Save ge0ffrey/b63acfbc5baad6d1548d4863405dc27a to your computer and use it in GitHub Desktop.
Option A
========
@PlanningSolution
class MeetingSchedule {
@ConstraintWeight("Room conflict")
HardSoftScore roomConflictWeight = HardSoftScore.ofHard(-100);
@ConstraintWeight("Speaker conflict")
HardSoftScore speakerConflictWeight = HardSoftScore.ofHard(-1);
...
@PlanningScore
HardSoftScore score;
}
Option B
========
@PlanningSolution
class MeetingSchedule {
@ConstraintWeightSourceProperty
GenericConstraintWeightSource foo = new GenericConstraintWeightSourceBuilder()
.add("Room conflict", HardSoftScore.ofHard(-100)
.add("Speaker conflict", HardSoftScore.ofHard(-1)
.build();
...
@PlanningScore
Score score;
}
Option C
========
@PlanningSolution
class MeetingSchedule {
@ConstraintWeightSourceProperty
MeetingConstraintWeightSource foo;
...
@PlanningScore
Score score;
}
@ConstraintWeightSource
class MeetingConstraintWeightSource {
@ConstraintWeight("Room conflict")
HardSoftScore roomConflict = HardSoftScore.ofHard(-100);
@ConstraintWeight("Speaker conflict")
HardSoftScore speakerConflict = HardSoftScore.ofHard(-1);
}
@ge0ffrey
Copy link
Author

ge0ffrey commented Oct 3, 2018

B and C variants with Provider:

Option B2

@PlanningSolution
class MeetingSchedule {

    @ConstraintWeightProvider
    GenericConstraintWeightProvider foo = new GenericConstraintWeightProviderBuilder()
            .add("Room conflict", HardSoftScore.ofHard(-100)
            .add("Speaker conflict", HardSoftScore.ofHard(-1)
            .build();


    ...
    @PlanningScore
    Score score;

}

Option C2

@PlanningSolution
class MeetingSchedule {

    @ConstraintWeightProvider
    MeetingWeightProvider foo;

    ...
    @PlanningScore
    Score score;

}

@ConstraintWeightProvider
class MeetingWeightProvider {

    @ConstraintWeight("Room conflict")
    HardSoftScore roomConflict = HardSoftScore.ofHard(-100);
    @ConstraintWeight("Speaker conflict")
    HardSoftScore speakerConflict = HardSoftScore.ofHard(-1);

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment