net: now calculating cost
net: added helper function to generate matrix with ones