# How to design a constraint to control flow in a non-network optimization model

I'm working on a production scheduling problem with a MIP model somebody left to me. This is a discrete-time model in which the constraints used to control the production and consumption of product p are such that

(I dont know how to input formula in StackExchange, so I use picture，hope this doesnt make reading difficult)

You can see that the constraints do not actually indicate in detail which process's product goes to which process that consumes it, but only ensure that the production and consumption of good p is balanced at each t.

Now the constraint I want to add is that the product of some specific production process can flow to the consuming process I specify. The flow transfer time t is not required to be fixed, the quantity is given by me. Colud give me some suggestions?

• Is it the only constraint in the model? What does the process index mean? It seems the index $i$ is for counting the produced product in each process. Do you check that? Nov 25, 2023 at 9:25
• Sry, some work is keeping me away these days, and the fact that I solved the problem on my own in the meantime, I'll see if I can reply to my own question with my own solution in a bit.For your question, the i is the process id, which is unique for each process in each work order. Nov 28, 2023 at 7:12

Ok, suppose production process $$i1$$ goes to consumption process $$i2$$. You can create a map of $$i1 -> i2$$ & define parameters $$z_{i1,i2}$$such that if $$i1 -> i2$$, then $$z_{i1,i2} = 1$$, $$0$$ otherwise
Then the above balance constraints become
$$z_{i1,i2}x_{i1,t} + w_{p,t}+u_{o,t} = z_{i1,i2}x_{i2,t}prop_{i2p} + w_{p,t+1}+ u_{o,t+1}$$

Another way is to again create mapping of production/consumption processes and create a set (or tuple in python) of them like
$$S= \{(i1,i2),(i3,i4),...\}$$
$$x_{i1,t} + w_{p,t}+u_{o,t} = x_{i2,t}prop_{i2p} + w_{p,t+1}+ u_{o,t+1} \quad \forall (i1,i2) \in S$$

• Thx for help. Your method seems to be a very good solution, but I have actually come up with a "bad" solution myself these days, and I'll share my method in my reply. Again thx for help Nov 28, 2023 at 7:18
• @CangWangu, you're welcome Nov 28, 2023 at 11:32

I actually solved this problem recently on my own, though my approach was not based entirely on operations research, but relied a bit on the logic of running the whole program. So if you are looking for an academic solution to a similar problem, please prioritize @Sutanu Majumdar's solution.

First of all, this model is part of one of my work projects, which is used to calculate a suitable production schedule for factory production. The project is divided into a discrete modeling part, a distribution modeling part, and a continuous time modeling part， with the focus mainly on the discrete and distribution models.

In operation, the production plan is first calculated in the discrete model for discrete time (the constraints I presented in the question come from the discrete model), and you can see from this flow balance constraints that the results from the discrete model don't actually know where the process products are going to flow, but only how much of each process will be produced at each t， and that's where the allocation model comes in handy. The allocation model connects the inputs of each process in the discrete model results to the outputs of another process, creating a process-to-process supply relationship.

Note that the allocation model determines whether a process i1 that produces p can supply a process i2 that consumes p based on the fact that i1 is produced earlier than i2 and that the product produced by i1 has the same product id as the product demanded by i2. So I was wondering if there could be a way to get i1 production into i2 whenever it is produced.

If i1 produces, its product can only go into the process that consumes it, or into inventory, according to the flow balance constraint. While I can't know exactly which process supplied the amount of inventory at each t at which previous t, conversely, the amount of inventory can be thought of as being produced by any of the production processes that produced before t, as long as it produced!

Thus, when i1 produces, I just have to make sure that the amount of inventory must be greater than i2's current total production, all the way up to the point when i1 starts to consume it, so that in the view of the allocation model, i1 and i2 can establish a supply relationship, and in between, even if some other consuming process tries to take away the inventory, a new production process will be induced to produce it, based on my constraints as well as on the flow balance!

Here are the constraints I added. Constraint (2) guarantees that, for all supply relationships I want to control, the production quantity of a preceding production process will "always" be held in inventory if its successor does not start consuming it when it starts producing; and constraint (3) makes it possible for each pair of successors in the controlled supply relationship to have a sufficient supply of supply "from i1".

By working with the three constraints, the results obtained from the discrete model can then be processed by the preprocessing function of the assignment model into the supply relationship I want