Exact solution of networks of constraints using perfect relaxation