implemented hyperplane distance cost function, not fully tested yet