Joint search of optimal topology and trajectory for planar linkages