## 3 System Modeling with Petri Nets
### Device Modeling  
The devices involved in crude oil operations include tanks (storage and charging tanks) and a pipeline. While scheduling a refinery without sufficient charging tanks, the crude oil must stay in storage tanks for ORT, but charging tanks may adopt the SCF mode during the execution of a schedule. Hence, the models for charging and storage tanks are different. The PN model in Figure 2 describes the behavior of a storage tank and is the same as that in [21; 22]. A storage tank is modeled by two continuous places \(p_{s}\) and \(p_{c}\) to describe its state. In the PN model, a token in a discrete place is treated as a discrete one and acts just as that in a general PN. For example, a token in \(p_{4}\) is just a discrete one. A token in a continuous place can be treated as both discrete and continuous one. When it is treated as a discrete one, it indicates that there is oil in a tank. For example, one token in \(p_{s}\) or \(p_{c}\) or both denotes that there is oil in it. Also, when \(t_{2}\) fires, the token in \(p_{s}\) is removed just like a discrete one. When the token in a continuous place is treated as a continuous one, it represents the crude oil in the device with a real number volume, which is called the token volume. If there is a token in an enforcing place, it enforces the output transitions to fire until it is empty. Figure 1: Icons in the model. Figure 2: PN model for storage tanks. A discrete transition behaves the same as in a general PN. When a timed transition fires, it moves a token from an input place to an output place with a constant time delay, which is used to model the oil residency time constraint. When a continuous transition fires, oil is delivered from one place to another with a flow rate for a time duration, which is determined by an \(OD\). Hence, crude oil unloading, transportation or feeding to distillers can be modeled by continuous transitions. One token in \(p_{s}\) indicates that the oil stays in the tank for less than ORT and is not ready for discharging. Only if there is a token in \(p_{c}\), and \(p_{s}\) is empty, can the oil in the tank be discharged. Continuous place \(p_{3}\) models the capacity of the tank available at the current marking. Continuous transitions \(t_{1}\) and \(t_{3}\) model the processing of charging to and discharging from a tank. Timed transition \(t_{2}\) models the ORT constraint. When \(t_{2}\) completes its firing with a given time delay, the token in \(p_{s}\) moves to \(p_{c}\), indicating that the oil in the tank is ready for discharging. Notice that a non-emptied tank can be charged when the type of oil to be charged to the tank is same as that in the tank. In this case, when the firing of \(t_{1}\) ends, both \(p_{s}\) and \(p_{c}\) hold a token such that both \(t_{2}\) and \(t_{3}\) are enabled. However, in this case, the firing of \(t_{3}\) results in the violation of oil residency time constraint. Hence, inhibitor arc (\(p_{s}\), \(t_{3}\)) guarantees that \(t_{3}\) can fire only when \(p_{s}\) is emptied, which implies that the oil stays in the tank for ORT. If transition \(t_{1}\) (\(t_{2}\), \(t_{3}\)) fires, one token in place \(p_{4}\) is consumed at the beginning, and one token is put into place \(p_{4}\) when its firing ends. Since there is only one token in \(p_{4}\), during the firing of one of transitions \(t_{1}\), \(t_{2}\), and \(t_{3}\), the others are disabled, which ensures that a storage tank cannot be filled and discharged simultaneously. Thus, a storage tank can only be operated under the normal mode and its behavior is well described. A charging tank should operate under the normal mode if possible. However, when the charging tanks in the system are not enough, the SCF mode has to be adopted to keep the distillers in operation.