Analysis and optimization of systems