This academic course started the third edition of the Master in Industry 4.0 of the UPC School. The main objective of the master's degree in Industry 4.0 is to train professionals to understand the complexities and challenges of Industry 4.0 in a transversal way. I participate in this master giving a course on mathematical optimization for industry 4.0. In the first part of the course, we review the role of mathemnatical optimization, operations research and analytics in Ind. 4.0, analyse some case studies on mathematical optimization models in supply chain and energy industry. In the second part, the theoretical and computational basis of mathematical optimization are presented and applied by the students to solve a complete optimization project in supply and distribution chain using mathematical optimization modeling software.