# gams error in code-linear programing

 0 issue is maximizing benefit from 3 items:clock,radio,phone each has it's cost of supply,workforce,demand,price this is my first program in first day in gamps please help me with errors I have errors in part of equation SETS I items / clock, radio,phone/ ; PARAMETERS A(I) cost per item /clock 7 radio 10 phone 5 / B(I) workforce pre item / clock 2 radio 3 phone 2 / C(I) demand per item /clock 200 radio 300 phone 150/ D(I) sell price / clock 15 radio 20 phone 12 / ; VARIABLES X(I) quantities in cases Z total benefit; POSITIVE VARIABLE X ; EQUATIONS BENEFIT define objective function SUPPLY(I) quantity supply I Worker(I) quantity worker I DEMAND(I) quantity demand I ; BENEFIT .. Z=E= SUM(I,(D(I)*X(I)-A(I)*X(I))); SUPPLY(I) .. SUM(I,(A(I)*X(I)))=L=2000; Worker(I) .. SUM(I,(B(I)*X(I)))=L=660; DEMAND(I).. X(I)=L=C(I); MODEL commodity /ALL/ ; SOLVE commodity USING LP Maximizing Z ;  Update:This outputs me now hope it is correct  BENEFIT .. Z=E=sum(I,(D(I)-A(I))*X(I)); SUPPLY .. sum(i,A(I)*X(I))=L=2000; Worker .. sum(i,B(I)*X(I))=L=660; DEMAND(i).. X(I)=L=C(I);  asked 15 Jan '12, 07:57 nik 5●1●4 accept rate: 0%

 6 This looks a little bit like a homework problem, but I will at least give you a hint. You can't both "sum" over an index (I) and have the constraint hold 'for each' (I). GAMS will say: 125 Set is under control already I guess you don't want the SUPPLY and Worker constraints to be indexed over (I). Hope this helps. answered 15 Jan '12, 09:13 Jeff Linderoth 441●2 accept rate: 40% Thanks Jeff,I couldn't understand your mean exactly, in the line of SUPPLY I wanted to compute cost of supply for items so I should have this:A(1)*X(1)+A(2)*X(2)+A(3)*X(3) then I should go round i=1,2,3 and I should sum over I then what is wrong here? no it is not my homework it is my first experience I just solved an example from my book if you have any reference which I can go and study OR functions in Gams I would be so Thankful. (16 Jan '12, 00:18) nik @nik: What @Jeff told you is correct. You could not simultaneously use an index in both "for each" and "summation" sections of a constraint. The "for each" section iteratively fixes the index to specific values, say 2. The "summation" section tries to sum over all possible index values from 1 to n (in your case, 3). This is a contradiction from a mathematical point of view (your index could not simultaneously be both 1 and 2, just one of them). Therefore, you should use your indices in just one place, either "for each" section or "summation" section. (16 Jan '12, 02:28) Ehsan ♦ good to see you Ehsan from the same country nice 2 meet u n Thanks hope it is correct now.I updated no errors Now. (17 Jan '12, 08:00) nik
 4 GAMS has great online documentation. In particular for gaining "first experience", the tutorial is what you need. answered 16 Jan '12, 01:14 Marco Luebbecke ♦ 3.4k●1●6●15 accept rate: 16% Thank you Marco I used this one too (17 Jan '12, 08:02) nik
 toggle preview community wiki

### Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "Title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported

Tags:

×127
×51

Asked: 15 Jan '12, 07:57

Seen: 6,325 times

Last updated: 18 Jan '12, 11:08

### Related questions

OR-Exchange! Your site for questions, answers, and announcements about operations research.