A knowledge-based approach for on line contingency ranking