Optimal control of autonomous linear systems switched with a pre-assigned finite sequence