Modeling

Problems with modeling
Post Reply
Omi
User
User
Posts: 7
Joined: 4 years ago

Modeling

Post by Omi »

Can you tell how can I split the value of decision variable x into x1 and x0?
I have wrote a code and ran it. But only x1 is showing values, which is equal to x. I want to split larger demand into two x1 and x0. Addition of both will be x.
I have attached my model and constraints.
Thank you in advance.

Code: Select all

sets

j number of products /J1*J4/
t number of perids /T1*T4/
a(j) /J1, J2, J3/

*a is used instead of S for subset of t

;

Alias (j,jj);
Alias (t,tt,k)
*s in equation 15 is used as tt

parameters

cap     available production capacity on the a machine in period t   /27000/
c       setup cost for item j in period t                            /1500/
p(j)    capacity needed time to produce one unit of i in period t    /J1 6, J2 6.7, J3 6.8, J4 5/
d(j)    deterministic demand for item j in period t                  /J1 790, J2 200, J3 300, J4 400/
h(j)  Holding cost per unit and per period dollars                 /J1 5, J2 4, J3 4, J4 5/
M /6000/
mi /50/
;
Table s(j,jj) Time needed for setup
      J1  J2  J3  J4    
   J1 800 900 700 800   
   J2 890 790 600 700 
   J3 700 700 800 800
   J4 700 700 780 700
   
   ;
   
positive variables

I(j,t) inventory level of j at the end of peiord t
x(j,t) production quantity for item j in period t
z(j,t)

x0(j,t)
x1(j,t)
;
variable
Total_Cost;

Binary variables

U(j,jj,t) 1 if setup for item j in period t otherwise 0
Y(j,t)
R(t)
;

equations

objective
InvBalance inventory balance equation
ProdSetup  Production take place for j if it is setup
Capa        capacity constaint

*************************************************************************************************
ct1
ct2 subtour constraint
ct3 x1 addition x0
ct4 x1 upper bound
ct5 x0
ct6 

;

objective..Total_Cost=e=sum((j,t),h(j)*I(j,t))+sum((j,jj,t),c*U(j,jj,t));

InvBalance(j,t)..I(j,t)+d(j)=e=I(j,t-1)+x(j,t);

ProdSetup(j,jj,t)..p(j)*x(j,t)+s(j,jj)*U(j,jj,t)=l=cap*U(j,jj,t);

Capa(t)..sum((j),p(j)*x(j,t))+sum((j,jj),s(j,jj)*U(j,jj,t))=l=cap;

**************************************************************************************************

ct1(j,t)..z(j,t)+sum((jj),U(j,jj,t))=e=z(j,t-1)+sum((jj),U(j,jj,t));

ct2(t)$(card(a)>=2)..sum((jj,a)$(ord(jj)<>ord(a)),U(jj,a,t))+sum((a),z(a,t))=g=1-M*sum((a),(1-Y(a,t)));

ct3(j,t)..x(j,t)=e=x1(j,t)+x0(j,t);

ct4(j,t)..x1(j,t)=l=M*z(j,t);

ct5(j,t)..x0(j,t)=g=mi*(sum((jj),U(jj,j,t)-z(j,t+1)));

ct6(j,t,tt)..x0(j,t)+sum(k$(ord(k)=ord(t)+1),x1(j,k))=g=mi*sum(jj,U(jj,j,t))-M*(sum(k$(ord(k)=ord(t)+1),R(k))+1-R(tt));





Model Basic /all/
solve Basic using minlp minimizing Total_Cost;
Attachments
Capture.PNG
Post Reply