I have a job-shop model programmed using CPO (docplex.cp) and it is working fine! I have model all my scheduling variables as interval variables like ops(j,o) and mops(j, o, m) (job, operation, machine) like in the cp doc examples.
However, I have inserted some machines as buffers, which are optional and no-fixed sized. The objective of the optimization is set to minimize Makespan, but I would like to add a KPI monitoring the number of buffers used in parallel at each moment to get the maximum and the average.
I have delved into the docplex examples and documentation but I have no idea on how to this. My vague attempts have revolved around creating a step _at(0,) variable and accumulating pulse(mops), but I don't know how to extract the "max" of it. Any idea or suggestion?
I can provide the code, but it is very similar to the one in the documentation.
Ok, it's clearer now. You could:
let MAX be the max capacity of f, the number of jobs can be used for that.
Let HORIZON be an interval variable starting at 0 and ending at the max possible time in your problem.
Let us introduce
g = pulse(HORIZON,0,MAX)
Add the constaint
f+g<=MAX
Define
f_max = MAX - heightAtStart(g,HORIZON)
Now if we maximize f_max, it will be the max level of f on HORIZON
You need to put f_max in your objective.