Kent Zhang
Kent Zhang

Reputation: 89

What if I set the constraint weight to zero in OptaPlanner?

If I set the weight of a constraint to zero, does that mean that this constraint does not take effect? look like below:

@ConstraintWeight("Speaker conflict")
private HardMediumSoftScore speakerConflict = HardMediumSoftScore.ofHard(0);

Upvotes: 1

Views: 141

Answers (1)

Geoffrey De Smet
Geoffrey De Smet

Reputation: 27312

Functionally: yes, the constraint has no score impact so is effectively ignored.

Implementation wise:

  • In DRL score calculation in 7.20.0.Final that constraint rule still eats CPU power because Drools doesn't support disabling rules after building the KieBase at the moment.
  • In the ConstraintStreams prototype (long-term work in progress, not yet released) that constraint already automatically takes no CPU power because it isn't be added to the KieBase.

Upvotes: 1

Related Questions