I am in the process of creating a minimization problem in which I;
- schedule a certain set of N products according to minimum changeovers in raw materials
- allocate raw materials to submachinery (which determines the changeovers or costs). This allocation occurs for each state n, or for each scheduled product.
The schedule is wrapped into a decision variable x_ij, denoting whether product i is followed by j. I flatten this to a sequence O, which is in the shape of N, e.g. [3,1,2,0], i.e. the third product is first, then the first product, etc.
So, my raw material allocation requires the produced schedule, and my schedule requires (intermediate) values of raw allocation to determine the cost of that schedule.
For one of my constraints, i take the n-th element for the o, and use it as input for a constraint, like
for n in range(N):
for r in range(R):
prob += lpSum(y[n][r][d] for d in range(D)) == matrix[idxs[o[n].varValue]][r]
i.e. i take a corresponding index from idxs and equal my allocation in state n of raw material r on submachinery d to a certain value from a matrix.
Problem O is dynamic, and changes depending on the schedule. However, my model takes only a certain instance of the values within O to determine the constraint, which results in a faulty result. I've read elsewhere that .varValue() only is available after solving. That means the model is not getting the correct results.
Is there a possibility to make this more dynami, i.e. updating this constraint each time O is updated?
I have tried looking at callbacks, but I believe the PULP_CBC_CMD solver does not support it.