shen...@gmail.com
unread,Apr 22, 2017, 4:25:32 PM4/22/17Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to AMPL Modeling Language
This is the problem statement:-
You are in charge of an advertising campaign for a new product, with a budget of $1 million.
You can advertise on TV or in magazines. One minute of TV time costs $20,000 and reaches 1.8
million potential customers; a magazine page costs $10,000 and reaches 1 million. You must sign
up for at least 10 minutes of TV time. How should you spend your budget to maximize your audience?
Formulate the problem in AMPL and solve it. Check the solution by hand using at least one
of the approaches described in Section 1.1.
---------------------------------------------
i am getting this errors :-
Section1.dat, line 9 (offset 146):
cost['price'] already defined
context: mag >>> 10000 <<< 0 ;
Section1.dat, line 9 (offset 156):
cost['time'] already defined
context: mag 10000 >>> 0 <<< ;
Section1.dat, line 12 (offset 188):
1 item(s) missing in last line of table, which starts with "10"
context: 10 >>> ; <<<
ampl:
------------------------------------------------------------
this is my Code:-
set method;
param Budget >=0;
param time {method}>=0;
param Time {method}>=0;
param cost {method} >=0;
param audiance{method}>=0;
var X {method} >=0;
maximize viewers : sum {i in method} (X[i]*audiance[i]);
s.t. TimeConst : sum {i in method} (X[i]* time[i])>= 10;
s.t. BudgConst: sum {i in method} (X[i] *cost[i])<=Budget;
#Data
data;
set method := tv mag;
param Budget:= 1000000;
param cost : price time :=
tv 20000 1
mag 10000 0 ;
param Time :=
10;
param audiance:=
tv 1800000
mag 1000000;
-------------------------------------------------
i would like to know what is wrong and how to fix it, i am still getting used to formulating using algebraic notation and still getting errors but i want to know if my code model/data is correct and how it can be improved;