gams:fast_calculation_of_mappings

$ontext The goal of the program is to calculate distances between companies for each individual sector. Based on these inter-firm distances, I want to construct count variables to obtain the number of "industry-peers" located within, say, 25 km circle of each individual company. We are using mapping for an efficient implementation. The data file is below. $offtext sets i companies / 1 * 6773 /, k zip code / 1 * 589 /, c sector / 15 * 36 / ; alias(i,j) ; alias(k,h) ; parameter dist(k,h) "distance between companies", x(i,*) "matches companies, sector, and zip code"; $gdxin data.gdx $loaddc dist x sets ic(i,c) company sector mapping, ik(i,k) company municipality mapping; ic(i,c) = c.val=x(i,'1'); ik(i,k) = k.val=x(i,'2'); parameters loc010_count(i), loc1025_count(i), locplus25_count(i), rep(i,c,*) summary counts; loop(ic(i,c), loc010_count(i) = sum(j$ic(j,c), sum((k,h)$(ik(i,k)*ik(j,h)), dist(k,h) <= 10 )); loc1025_count(i) = sum(j$ic(j,c), sum((k,h)$(ik(i,k)*ik(j,h)), (dist(k,h) > 10) and (dist(k,h) <= 25) )); locplus25_count(i) = sum(j$ic(j,c), sum((k,h)$(ik(i,k)*ik(j,h)), dist(k,h) > 25 )); ); rep(ic(i,c),'<=10') = loc010_count(i); rep(ic(i,c),'>10 * <=25') = loc1025_count(i); rep(ic(i,c),'>25') = locplus25_count(i); rep(ic(i,c),'all') = loc010_count(i) + loc1025_count(i) + locplus25_count(i); rep(ic(i,c),'same') = sum(j$ic(j,c), 1); Execute_Unload 'results.gdx',loc010_count, loc1025_count, locplus25_count, rep;

gams/fast_calculation_of_mappings.txt · Last modified: 2010/05/21 19:23 by support