hello,i have to write this minimize model in gams but i got confused and i need help.
labor time for this month is 480, machine time for machine 1 is 200,and machine 2 is 200
demands for product 1 is 200 and product 2 is 250.Also at least half of product 1 must be produced on machine 1 and least half of product 2 must be produced on machine 2.
Confusing model
Re: Confusing model
What's confusing? Share what you have done so far and where you got stuck. Do you expect someone from the forum doing your homework?
-Michael
-Michael
-
- User
- Posts: 2
- Joined: 1 year ago
Re: Confusing model
Sets
i/1*2/;
alias (i,j);
Variable z;
positive variable
x(i,j);
parameters
machine_time_co(j)/1 200,2 200/
demand_co(i)/1 200,2 250/
machine_using(i)/1 0,2 0/
labor_co / 480/;
table objective(i,j)
1 2
1 1.5 2.5
2 0.5 4 ;
table demand(i,j)
1 2
1 1 1
2 1 1;
table machine_t(i,j)
1 2
1 0.7 0.75
2 0.8 0.85;
table machine_us(i,j)
1 2
1 0.5 -0.5
2 -0.5 0.5;
table labor_us(i,j)
1 2
1 0.75 1.2
2 0.7 1.5;
Equations
obj,dem,machtime,machusing,labor;
obj..z=e=sum((i,j),objective(i,j)*x(i,j));
labor..sum((i,j),labor_us(i,j)*x(i,j))=l=labor_co;
dem(i)..sum(j,x(i,j)*demand(i,j))=g=demand_co(i);
machtime(j)..sum(i,x(i,j)*machine_t(i,j))=l=machine_time_co(j);
machusing(i)..sum(j,x(i,j)* machine_us(i,j))=g=machine_using(i);
model UmutHendem /all/;
solve UmutHendem using LP minimizing z;
I got confused about tables, i used it many times in this but i wonder if i can use it once or lesser than 5
i/1*2/;
alias (i,j);
Variable z;
positive variable
x(i,j);
parameters
machine_time_co(j)/1 200,2 200/
demand_co(i)/1 200,2 250/
machine_using(i)/1 0,2 0/
labor_co / 480/;
table objective(i,j)
1 2
1 1.5 2.5
2 0.5 4 ;
table demand(i,j)
1 2
1 1 1
2 1 1;
table machine_t(i,j)
1 2
1 0.7 0.75
2 0.8 0.85;
table machine_us(i,j)
1 2
1 0.5 -0.5
2 -0.5 0.5;
table labor_us(i,j)
1 2
1 0.75 1.2
2 0.7 1.5;
Equations
obj,dem,machtime,machusing,labor;
obj..z=e=sum((i,j),objective(i,j)*x(i,j));
labor..sum((i,j),labor_us(i,j)*x(i,j))=l=labor_co;
dem(i)..sum(j,x(i,j)*demand(i,j))=g=demand_co(i);
machtime(j)..sum(i,x(i,j)*machine_t(i,j))=l=machine_time_co(j);
machusing(i)..sum(j,x(i,j)* machine_us(i,j))=g=machine_using(i);
model UmutHendem /all/;
solve UmutHendem using LP minimizing z;
I got confused about tables, i used it many times in this but i wonder if i can use it once or lesser than 5
Re: Confusing model
Please use the code block when you paste formatted model code.
You can combine the data for i,j in a single table as I did and either produce named parameters from that data (example objective and demand) or use the combined table with a new header index directly in the equations, that's a matter of taste.
-Michael
PS Take pride in the code you write. Use consistent spacing/alignment, capitalization and provide symbol text (see text for ijHeaders) even when you do small projects. It pays off in the end.
You can combine the data for i,j in a single table as I did and either produce named parameters from that data (example objective and demand) or use the combined table with a new header index directly in the equations, that's a matter of taste.
Code: Select all
Set i/1*2/; Alias (i,j);
Variable z;
Positive variable x(i,j);
Parameters
machine_time_co(j) /1 200,2 200/
demand_co(i) /1 200,2 250/
machine_using(i) /1 0,2 0/
labor_co /480/;
Set ijHeaders "data elements for machine pairs" / objective,demand, machine_t, machine_us, labor_us /;
Table data(ijHeaders,i,j)
1.1 1.2 2.1 2.2
objective 1.5 2.5 0.5 4
demand 1 1 1 1
machine_t 0.7 0.75 0.8 0.85
machine_us 0.5 -0.5 -0.5 0.5
labor_us 0.75 1.2 0.7 1.5
;
Parameter
objective(i,j)
demand(i,j);
objective(i,j) = data('objective',i,j);
demand(i,j) = data('demand' ,i,j);
Equations
obj,dem,machtime,machusing,labor;
obj.. z =e= sum((i,j), objective(i,j)*x(i,j));
labor.. sum((i,j), data('labor_us',i,j)*x(i,j)) =l= labor_co;
dem(i).. sum(j, x(i,j)*demand(i,j)) =g= demand_co(i);
machtime(j).. sum(i, x(i,j)*data('machine_t',i,j)) =l= machine_time_co(j);
machusing(i).. sum(j, x(i,j)*data('machine_us',i,j)) =g= machine_using(i);
Model UmutHendem /all/;
solve UmutHendem using LP minimizing z;
PS Take pride in the code you write. Use consistent spacing/alignment, capitalization and provide symbol text (see text for ijHeaders) even when you do small projects. It pays off in the end.