Hello
@Renaud Dumeur,
Thank you for your prompt reply. I had look into the all examples out there for CP model. But here in my scheduling problem, what's the difference than the
house_building.py example is I have list of Tasks unlike same task list for all houses. It's different tasks for different house. Like Tasks = {T1H1, T2H1, T3H2, T4H3, ... }. So aim (Objective) is to maximize the count of Houses that can be fully completed (100% completed houses from solution).
I tried below code for this, which gives me the error "
CpoException: CPO expression can not be used as Boolean."
mdl0.add(cp.maximize(sum ( 1
for H in Houses
if
sum((cp.presence_of(dictIntrvalVarsTasks[T]) * 1)
for T in Tasks) ==
dfAllTasks.loc[dfAllTasks['House'] == H, 'TaskName'].count()
)))
Here, in the code first I'm trying to get sum of houses which can be completed 100% using the condition (
if
sum((cp.presence_of(dictIntrvalVarsTasks[T]) * 1)
for T in Tasks) == dfAllTasks.loc[dfAllTasks['House'] == H, 'TaskName'].count()
), and check that if sum of present tasks in solution are equal to the total tasks for the house? If so that means all tasks for that house is completed and so the house. And maximize that sum.
Hope I explained it enough, but please let me know if there is any question. Thanks a lot in advance. Hope you or somebody could help me with this! :)
------------------------------
Patel
------------------------------
Original Message:
Sent: Thu September 22, 2022 05:10 PM
From: Renaud Dumeur
Subject: How to maintain the presence of group of Interval variables in scheduling problem using Cplex Python?
Dear Patel,
Could you please provide a short model that shows the error you describe?
Thank you in advance,
Edit: I suggest that you have a look at the house_building example that seems to match what you want to do:
docplex-examples/house_building.py at master · IBMDecisionOptimization/docplex-examples
GitHub |
remove preview |
|
docplex-examples/house_building.py at master · IBMDecisionOptimization/docplex-examples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters You can't perform that action at this time. You signed in with another tab or window. |
View this on GitHub > |
|
|
------------------------------
Renaud Dumeur
Original Message:
Sent: Thu September 22, 2022 04:33 PM
From: Patel
Subject: How to maintain the presence of group of Interval variables in scheduling problem using Cplex Python?
Hello,
So basically I have a scheduling problem where all tasks (interval variables) are optional and it belongs to different groups. Like as an house building problem, but here I have different tasks (not same at all) for different houses and I want to model that it fully completes as many houses as possible by finishing all tasks for those houses. I am also checking for the resource capacity that it won't exceed the given capacity. (So main goal is to fully complete the houses as much as possible and if capacity permits also select some tasks to use the remaining capacity, even if last house can't be complete )
So here I'm trying to count the presence_of() tasks (Model picks in solution) from perticular house and then check if those are all tasks for a house to be finish completely, and then try to maximize the number of completed houses. But it's not working and giving me an error that "CPO expression can not be used as boolean". I would really appreciate any help to make it work! Thank you!
------------------------------
Patel
------------------------------
#DecisionOptimization