Analytical solutions to some optimization problems on ranks and inertias of matrix-valued functions subject to linear matrix inequalities