The optimization module of SAM offers constrained single-function multi-parameter optimization. Constraints are dealt with by treating each violation of a constraint as a penalty that is added to the original cost function. The software offers the option to define own results from the standard set of results via an advanced formula parser. This option is also used to define and add penalties. In this example a 4 bar mechanism with unbalance due to gravity will be in better balance after adding an extra mass. The automated optimization in SAM will find the best solution, being the lowest driving torque.