Model-based diagnosis and manufacturing control