cost function network