I am working on a memory allocation optimization problem, i.e., allocation of a number of sized buffers in an amount of memory that is not enough to accommodate all buffers concurrently. The swapping in and out of buffers has an associated cost, so obviously, swapping needs to be minimized.
To model the cost function as an objective function, I need to establish whether two buffers are overlapping. If they do, the cost value returned may be something like a fixed value, let's say 28. If they don't the cost is 0.
I thought to model this in Python as follows:
cost = solver.ConditionalValue(x1 >= x0 + size0 or x0 >= x1 + size1, 0, 28)
objective = solver.Minimize(cost, 1)
Of course this doesn't work as the ConditionalValue member function does not exist.
What is good practice to address a problem like this?