Forum Discussion

FICO's avatar
FICO
Community Manager
5 years ago

Combining sum and overall statement

Hi,

I am trying to build a perishable supply chain model. To include perishability, I want to include a constraint in which for every period in time (T is the set of periods, indexed by t) the model sums over certain periods of time.

Let's say that x(t, i) is the production in period t, in location i. The variable d(t, i) denotes demand. The variable w(t,i) represents the products perished. Theta is a constant which represents the life time of a product.

To include perishability in the model, the following constraint is included:

forall(t in Theta..NT, i in I)  w1(t, i) >= sum(tau in 0..t-Theta) x(t,i) - sum(tau in 0..t, i in I) d(t, i) - sum(tau in 0..t) w(t-1, i)

The idea is to take the total amount of products produced that should be perished in this period and subtract the fulfilled demand up to this period and the products that perished previous periods. The remaining part should than be the part of production that perishes this period.

On the right-hand side of the constraint, I replaced t by tau since I still want to sum over t, but Xpress does not allow me to do that. Is this the right way to implement this? The model I have so far does work, but the results are not correct and I think it has to do with this constraint.

2 Replies

  • FICO's avatar
    FICO
    Community Manager

    Hi Stijn,

    if you define your constraint for all t in Theta..NT, then "t" is already defined and can't be reused as a summation index. Naming those other summation indices tau should be fine, but then you should also sum over x(tau,i) [and similarly for the other two], if you want to compute the sum of all productions in previous periods, currently you would just add the production of the current period once for each previous period.

  • FICO's avatar
    FICO
    Community Manager

    Thank you! This helps a lot!