The rapid rise of Large Language Model (LLM) agents is driving a fundamental paradigm shift in Multi-Agent Systems (MAS) research, moving from manually orchestrated static architectures toward automated configuration and optimization. Despite its significant potential, this frontier lacks a systematic and rigorous survey with clearly defined operational boundaries. To address this gap, this paper provides a comprehensive review of Automated MAS Optimization, formally anchoring it as the P4 paradigm within a six-stage evolutionary framework spanning from Foundation LLMs (P0) to Agentic Swarms (P5). We introduce precise mathematical definitions for core concepts, establishing a unified MAS configuration space that encompasses agent-level, system-level, and underlying components, and formulate the optimization objective as a holistic system-utility maximization problem. Furthermore, we partition P4 into three operationally distinct sub-paradigms based on the orthogonal dimensions of optimization timing and effect persistence: Design-Time Adaptive MAS, Test-Time Adaptive MAS, and Self-Evolving MAS. Guided by this taxonomy, we systematically review over 200 state-of-the-art works, covering both general methodologies and domain-specific applications. Beyond algorithmic perspectives, we critically examine key supporting issues including benchmarking, evaluation, and safety, while analyzing the evolutionary trajectory toward decentralized, emergent P5 Agentic Swarms. Finally, we identify core open challenges and propose future research directions centered on holistic configuration co-optimization, life-cycle evaluation, endogenous safety mechanisms, and the controllable transition from P4 to P5. This survey aims to provide a rigorous theoretical foundation and strategic navigation for researchers and practitioners in this rapidly evolving field.