0

I am working on the scheduling problem where I want to add an objective according to such condition. So is there any way to count the present interval variables (like presence_of()) to apply some condition for an objective? Thanks in advance!

Gops
  • 1
  • 1

1 Answers1

0

In the example CPLEX_Studio221\python\examples\cp\basic you could have a look at the example house_building.py

You will see

# Maximization objective of the model
obj2 = mdl.sum([s.level * mdl.presence_of(wtasks[(h, s)]) for s in SKILLS for h in HOUSES])
mdl.add(mdl.maximize(obj2))
Alex Fleischer
  • 9,276
  • 2
  • 12
  • 15
  • Thank you! So here is possible to have like presence_of(tasks) == 10, just for example? Because I want to check if specific number of tasks are present in the solution? – Gops Sep 27 '22 at 16:25
  • If you use a sum as in the example I mentioned, yes – Alex Fleischer Sep 27 '22 at 16:43