anchor.diff:  
       %% Generate a series of unique identifiers.
       RovioAdIds = lists:map(fun(_) -> druuid:v4() end, lists:seq(1, 10)),
  -    lager:info("Rovio Ad Identifiers are: ~p", [RovioAdIds]),
  -
       TriforkAdIds = lists:map(fun(_) -> druuid:v4() end, lists:seq(1, 10)),
  -    lager:info("Trifork Ad Identifiers are: ~p", [TriforkAdIds]),
  -
       Ids = RovioAdIds ++ TriforkAdIds,
  -    lager:info("Ad Identifiers are: ~p", [Ids]),
   
       %% Generate Rovio's advertisements.
       {ok, RovioAds} = lasp:declare(?SET),
  
positive.code: 
  -define(COUNTER, riak_dt_gcounter).
  
  -record(ad, {id, image, counter}).
  
  -record(contract, {id}).
  
negative.code: 
                      %% Increment it.
                      {ok, _} = lasp:update(Ad, increment, Id),
  
                      client(Id, AdsWithContracts, AdList0)
              end
      end.
  
  %% @doc Simulate clients viewing advertisements.
  simulate(ClientList) ->
      %% Start the simulation.
      Viewer = fun(_) ->
              Random = random:uniform(length(ClientList)),
              Pid = lists:nth(Random, ClientList),
              Pid ! view_ad
      end,
      lists:foreach(Viewer, lists:seq(1, ?NUM_EVENTS)).
  
  %% @doc Launch a server process for each advertisement, which will block
  %% until the advertisement should be disabled.
  servers(Ads, AdsWithContracts) ->
      %% Create a OR-set for the server list.
      {ok, Servers} = lasp:declare(?SET),
  
      %% Get the current advertisement list.
      {ok, {_, _, AdList0}} = lasp:read(AdsWithContracts, {strict, undefined}),
      AdList = ?SET:value(AdList0),
  
      %% For each advertisement, launch one server for tracking it's
      %% impressions and wait to disable.
      lists:map(fun(Ad) ->
                  ServerPid = spawn_link(?MODULE, server, [Ad, Ads]),
                  {ok, _} = lasp:update(Servers, {add, ServerPid}, undefined),
                  ServerPid
                  end, AdList).
  
  %% @doc Launch a series of client processes, each of which is responsible
  %% for displaying a particular advertisement.
  clients(AdsWithContracts) ->
      %% Generate a OR-set for tracking clients.
      {ok, Clients} = lasp:declare(?SET),
  
      %% Each client takes the full list of ads when it starts, and reads
      %% from the variable store.
      lists:map(fun(Id) ->
                  ClientPid = spawn_link(?MODULE, client, [Id, AdsWithContracts, undefined]),
                  {ok, _} = lasp:update(Clients, {add, ClientPid}, undefined),
                  ClientPid
                  end, lists:seq(1, ?NUM_CLIENTS)).
  
  %% @doc Summarize results.
  summarize(AdsWithContracts) ->
      %% Wait until all advertisements have been exhausted before stopping
      %% execution of the test.
      {ok, {_, _, AdsWithContracts0}} = lasp:read(AdsWithContracts, {strict, undefined}),
      Overcounts = lists:map(fun({#ad{counter=CounterId}, _}) ->
                  lager:info("Waiting for advertisement ~p to reach ~p impressions...",
                             [CounterId, ?MAX_IMPRESSIONS]),
                  {ok, {_, _, V0}} = lasp:read(CounterId, ?MAX_IMPRESSIONS),
                  V = ?COUNTER:value(V0),
                  lager:info("Advertisement ~p reached max impressions: ~p with ~p....",
                             [CounterId, ?MAX_IMPRESSIONS, V]),
                  V - ?MAX_IMPRESSIONS
          end, ?SET:value(AdsWithContracts0)),
  
      Sum = fun(X, Acc) ->
              X + Acc
      end,
      TotalOvercount = lists:foldl(Sum, 0, Overcounts),
      io:format("----------------------------------------"),
      io:format("Total overcount: ~p~n", [TotalOvercount]),
      io:format("Mean overcount per client: ~p~n", [TotalOvercount / ?NUM_CLIENTS]),
      io:format("----------------------------------------"),
  
      ok.
  