Transition to epileptic seizures: Optimization