Semirings for soft constraint solving and programming