Gauge Theory and Variational Principles