Constraint-Based Design by Cost Function