$title	Applying an Import Quota in a Small Open Economy

scalar	Quota	Import quota (0=no quota) /0/;


Small Open Economy:

Base year SAM:

	x,y	Production
	t	Net Trade
	fd	Final demand

	px,py	Prices of x and y
	w	Wage rate
	r	Return to capital

	x	y	t	fd
px	100		-20	-80
py		60	+20	-80
w	-60	-20		80
r	-40	-40		80

Assume Ricardo-Viner structure with fixed sectoral capital stocks.  


	x	!	X production
	y	!	Y production
	t	!	Trade

	px	!	Price of X
	py	!	Price of Y
	w	!	Wage rate
	rx	!	Rental rate in X
	ry	!	Rental rate in Y
	pq$quota	!	Quota rent

	ra	!	Representative agent

$prod:x  s:1
	o:px	q:100
	i:w	q:60
	i:rx	q:40

$prod:y s:1
	o:py	q:60
	i:w	q:20
	i:ry	q:40

	o:py	q:20
	i:px	q:20
	i:pq$quota	q:20

$demand:ra s:1
	d:px	q:80
	d:py	q:80
	e:pq	q:quota
	e:w	q:80
	e:rx	q:40
	e:ry	q:40

	v:welfare	w:ra

$sysinclude mpsgeset soequota

soequota.iterlim = 0;

$include soequota.gen
solve soequota using mcp;

soequota.iterlim = 8000;

parameter	results		Summary of results;

set	qlvl		/0*10/,
	ql(qlvl)	/0 0.0,  5 0.5, 10 1.0/;

$setglobal domain qlvl
$setglobal labels ql

results(qlvl,"ev") = na;
results(qlvl,"qrent") = na;

loop(qlvl$(ord(qlvl) gt 1),

	quota = 20 * (ord(qlvl)-1)/(card(qlvl)-1);

$include soequota.gen
	solve soequota using mcp;

	results(qlvl,"ev") = 100 * (welfare.l-1);
	results(qlvl,"qrent") = pq.l/w.l;

*	Terminate if GNUPLOT is not installed:

$if not exist %gams.sdir%wgnupl32.exe $exit

*	Plot results to the terminal:

$libinclude plot results

*	Plot results to a file:

$setglobal batch yes
$setglobal gp_opt1 'set term gif'
$setglobal gp_opt2 "set output 'quota.gif'"
$setglobal gp_opt3 "set size 0.8,0.8"
$libinclude plot results