Page 1 of 1

nonlinear problem

Posted: Mon Apr 26, 2021 6:08 pm
by giovannixasssn
Hello friends, i have to make this problem, i have errors while doing the equations. can you halp me out?
An airline operates the San Francisco-Los Angeles route. The demand for each flight clearly has two distinct components. There is a demand for business, with a price that responds to the curve p = 600-4q and a demand for leisure: p = 450-q. The costs of the company are 5 + 3q, where q represents the total number of seats sold.
1) Analyze the model to be solved. Define (by hand) the parameters, variables and equations of the model. What kind of model is it, linear or non-linear? Non-linear
2) Program the model in GAMS. How many sets do we have? Solve it. How many seats will the company sell in each class and at what price? Calculate the elasticity of each of the demands at this point and export them to an excel file.
3) How will the solution change if the plane has a maximum capacity of 260 seats?
4) Program a routine that allows you to solve the model for business demands p = a * (600-4q), where a takes the values from 1 to 1.5 in increments of 0.05. Export the results of the quantities, prices and benefits in each case. 11 times res optimization /01*11/
$title AIRLINE COMPANY PROBLEM

SET
i 'flight' / business, leisure /

Parameter
a(i)
/ business 600
leisure 450 /

b(i)
/ business -4
leisure -1 /;

VARIABLE
cost
price(i) "p1,p2"
quantity(i) "q1,q2"
profit
income(i)

Scalar f "numbers of seats" / 260 /;

Positive Variable price,quantity;

Equation
eqcost
eqprofit
eqprice(i)
eqincome(i)
eqquantity(i)

eqcost.. =e= sum(i, quantity(i),*3+5));
eqprice(i).. a(i)-b(i)*quantity(i) =e=price(i);
eqquantity(i).. sum (5/3 ,cost(i)/3)), =e=;
eqincome(i).. price(i)*q(i), =e=income(i);
eqprofit sum (i,income(i)), -cost, =e=profit;

Model airline / all /;

solve airline using lp minimizing cost;

Re: nonlinear problem

Posted: Mon Apr 26, 2021 6:25 pm
by abhosekar
Several issues.
1. the equation eqcost should be cost =e=..
2. There should be a ; at the end of equation block.
3. sum(5/3,..) is meaningless. Not sure what you try to achieve
4. Many unmatched parantheses and simple syntax errors in equations

Please follow some tutorials in the GAMS documentation before you start.
https://www.gams.com/latest/docs/UG_MAI ... l_Examples

- Atharv

Re: nonlinear problem

Posted: Mon Apr 26, 2021 7:10 pm
by giovannixasssn
when I divide by 3, I want to get the quantities

eqcost.. cost =e= sum(i, quantity(i),*3+5)); in this line i still have the error 8

Re: nonlinear problem

Posted: Mon Apr 26, 2021 7:29 pm
by giovannixasssn
i have problems in eqquantity(i)
An airline operates the San Francisco-Los Angeles route. The demand for each flight clearly has two distinct components. There is a demand for business, with a price that responds to the curve p = 600-4q and a demand for leisure: p = 450-q. The costs of the company are 5 + 3q, where q represents the total number of seats sold.
1) Analyze the model to be solved. Define (by hand) the parameters, variables and equations of the model. What kind of model is it, linear or non-linear? Non-linear
2) Program the model in GAMS. How many sets do we have? Solve it. How many seats will the company sell in each class and at what price? Calculate the elasticity of each of the demands at this point and export them to an excel file.
3) How will the solution change if the plane has a maximum capacity of 260 seats?
4) Program a routine that allows you to solve the model for business demands p = a * (600-4q), where a takes the values from 1 to 1.5 in increments of 0.05. Export the results of the quantities, prices and benefits in each case. 11 times res optimization /01*11/

$title AIRLINE COMPANY PROBLEM

SET
i 'flight' / business, leisure /

Parameter
a(i)
/ business 600
leisure 450 /

b(i)
/ business -4
leisure -1 /;

VARIABLE
cost
price(i) "p1,p2"
quantity(i) "q1,q2"
profit
income(i)

Scalar f "numbers of seats" / 260 /;

Positive Variable price,quantity;

Equation
eqcost
eqprofit
eqprice(i)
eqincome(i)
eqquantity(i);

eqcost.. cost =e= sum(i, quantity(i)*3+5);
eqprice(i).. a(i)-b(i)*quantity(i) =e=price(i);
eqquantity(i).. sum (5/3, cost(i)/3)), =e=;
eqincome(i).. price(i)*q(i), =e=income(i);
eqprofit sum (i,income(i)), -cost, =e=profit;

Model airline / all /;

solve airline using nlp minimizing cost;

Re: nonlinear problem

Posted: Mon Apr 26, 2021 7:49 pm
by giovannixasssn
error in eqproft line
$title AIRLINE COMPANY PROBLEM

SET
i 'flight' / business, leisure /

Parameter
a(i)
/ business 600
leisure 450 /

b(i)
/ business -4
leisure -1 /;

VARIABLE
cost
price(i) "p1,p2"
profit
income(i)

Scalar f "numbers of seats" / 260 /;

Positive Variable price,quantity;

Equation
eqcost
eqprofit
eqprice(i)
eqincome(i);

eqcost.. cost =e= sum(i, quantity(i)*3+5);
eqprice(i).. a(i)-b(i)*quantity(i) =e=price(i);
eqincome(i).. (price(i)*a(i)) =e=income(i);
eqprofit sum (i,income(i), -cost) =e=profit;
Model airline / all /;

solve airline using nlp minimizing cost;

Re: nonlinear problem

Posted: Tue Apr 27, 2021 1:42 pm
by abhosekar
Please use code block while posting a code.

sum (i,income(i), -cost) what is the purpose of this comma after income(i), please do not make up your own syntax. Try to read the error and check the syntax in GAMS documentation.

Good luck.
- Atharv