Fixed cost issue. Needed to use reference in agentbased.cpp