improved PSO solver, modified matlab example slightly