We propose to compute approximations to general invariant sets in dynamical systems by minimizing the distance between an appropriately selected finite set of points and its image under the dynamics. We demonstrate, through computational experiments that this approach can successfully converge to approximations of (maximal) invariant sets of arbitrary topology, dimension and stability as, e.g., saddle type invariant sets with complicated dynamics. We further propose to extend this approach by adding a Lennard-Jones type potential term to the objective function which yields more evenly distributed approximating finite point sets and perform corresponding numerical experiments.