## Production Batch Constraint Topic is solved

Problems with modeling
vigoleo
User
Posts: 6
Joined: 1 year ago

### Production Batch Constraint

Hi all,

my name is Leonardo from Italy. I'm a gams beginner. Reading the online doucmentation I have came up with this model I would like to employ to optimize the production planning process of my company. I'm attaching here a sample of the model (data has been taken randomly):

Code: Select all

``````Sets
art   "Continuative production"   / a1, a2, a3 /
pp    "New production" / p1, p2, p3 /
forn  "Suppliers" / f1, f2, f3 / ;

Parameters
t1(art)  "Cycle times of continuative products" /a1 35,a2 18,a3 63/
q1(art)  "Demand of continuative products" /a1 12,a2 17,a3 25/
cap(forn)  "Production capacity in hours" /f1 3000, f2 4000,f3 3000/
t2(pp)  "Cycle times of new producs " /p1 35,p2 18,p3 63/
q2(pp)  "Demand of new products" /p1 28,p2 14,p3 32/
numeropp(forn) "Max new products" /f1 2, f2 3, f3 1/;

Table  percorsi(art,forn)  "Who can produce continuative products"
f1           f2           f3
a1        1            1            1
a2        1            0            1
a3        1            1            0       ;

Table  dati(art,forn)  "Already assigned production in pieces"
f1       f2        f3
a1         35        0         0
a2          0        0         0
a3          0       18         0       ;

Scalar M /50000000/;

Variables
x(art,forn) "Quantity of continuative products assigned"
y(pp,forn)    "Quantity of new products"
k(pp, forn)  "Dummy variable"
z  "Output";

Integer Variables x,y;
Binary Variable k;

Equations
macroplan        'Maximize the production batch (expressed in hours) assigned to each supplier'
venduto1(art)    'Assign always all the pieces sold for a continuative product'
venduto2(pp)      'Assign always all the pieces sold for a new product'
capprod(forn)     'Do not exceed production capacity'
attivazione(pp,forn)  'If statement'
vincolo(forn)       'Assign a maximum number of new products';

macroplan ..     sum((art,forn), t1(art)*percorsi(art,forn)*x(art,forn)) + sum((pp,forn), t2(pp)*y(pp,forn)) =e= z ;
venduto1(art) .. sum(forn, x(art,forn)) =e= q1(art);
venduto2(pp) ..   sum(forn ,y(pp,forn)) =e= q2(pp);
capprod(forn) .. sum(art, t1(art)*[x(art,forn)+dati(art,forn)]) + sum(pp, t2(pp)*y(pp,forn)) =l= cap(forn);
attivazione(pp,forn).. M*k(pp,forn) =g= y(pp,forn);
vincolo(forn) .. sum(pp, k(pp,forn)) =l= numeropp(forn);

Model transport /all/ ;
Solve transport using MIP maximizing z;
display x.l, y.l;

``````
Here are my questions:
1) Sometimes the program reports "Integer Infeasible". Is that because the model is wrongly written or just because a solution really doesn't exist?
2)Is there any way to add a constraint for the minum dimension of batch assigned to each supplier? For example, in the case of new products I would like to set k(pp,forn)*y(pp,forn) =g= 5, but I guess the program doesn't accept that because I can't maximize a variable in function of another dependent variable.

I hope you guys could really help me.
Thank you so much in advance.

All the best

Freddy
User
Posts: 11
Joined: 1 year ago

### Re: Production Batch Constraint

Hello Leonardo,

if the solver reports "integer infeasible" then there is no feasible solution for the data you have provided. However, the model being infeasible does not mean the problem you want to solve is infeasible. You might have just modelled the reality too restrictive.
One way to avoid having the solver report "integer infeasible" is by adding non-negative slack variables to your equations and punishing them from taking nonzero values by subtracting them with some reasonably large factor from your objective function. This way you get a better understanding why your problem is infeasible and there might be compromises in the real world that are not reflected in your model but you could apply to make the problem you want to solve feasible.

Regarding your second question: Your model is of type MIP, which forces it to be a linear model. Thus, you can not multiply endogenous variables. However, you can use your binary variables and write the equations like this: y(pp,forn) =g= k(pp,forn) *5

Hope this helps,
Freddy

vigoleo
User
Posts: 6
Joined: 1 year ago

### Re: Production Batch Constraint

Freddy wrote:
1 year ago
Hello Leonardo,

if the solver reports "integer infeasible" then there is no feasible solution for the data you have provided. However, the model being infeasible does not mean the problem you want to solve is infeasible. You might have just modelled the reality too restrictive.
One way to avoid having the solver report "integer infeasible" is by adding non-negative slack variables to your equations and punishing them from taking nonzero values by subtracting them with some reasonably large factor from your objective function. This way you get a better understanding why your problem is infeasible and there might be compromises in the real world that are not reflected in your model but you could apply to make the problem you want to solve feasible.

Regarding your second question: Your model is of type MIP, which forces it to be a linear model. Thus, you can not multiply endogenous variables. However, you can use your binary variables and write the equations like this: y(pp,forn) =g= k(pp,forn) *5

Hope this helps,
Freddy
Hello Freddy,

thank you very much for your answer. You definitely solved my second question, I would have never thought about using the dummy variable in such that clever way!

About the first question: I think I didn't get exactly your point. I understood it is kind of debugging process, but I didn't get how it would work. How would I practically add that "non-negative slack variables"? Could you please provide me with a short example?

Thanks a lot again.

Leonardo

Freddy
User
Posts: 11
Joined: 1 year ago

### Re: Production Batch Constraint

Sure, let's take the following equation:

Code: Select all

``vincolo(forn) .. sum(pp, k(pp,forn)) =l= numeropp(forn);``
and add a non-negative slack variable slack(forn) to this equation as follows:

Code: Select all

``vincolo(forn) .. sum(pp, k(pp,forn)) =l= numeropp(forn) + slack(forn);``
Subtract the slack variables (potentially multiplied by a reasonably large factor) from your objective function:

Code: Select all

``macroplan ..  sum((art,forn), t1(art)*percorsi(art,forn)*x(art,forn)) + sum((pp,forn), t2(pp)*y(pp,forn)) - slackFactor*sum(forn, slack(forn)) =e= z ;``
. This way, your model becomes less restrictive (i.e. the original equation can now be violated by the slack variable taking on non-negative values). However, this violation is punished in your objective function. Of course you need to be careful with this technique as it adds extra variables to your problem and thus makes it more complex.
The point I wanted to make is that you are always modelling a subset of the reality. Thus, even though your model is infeasible, there might be a solution in reality that is not reflected in your model.

Best,
Freddy