Application of Pontryagin's principle to bimodal buckling optimization of micro and nano rods