In this paper, a scenario based optimal power flow (OPF) is presented considering economic (operation cost minimization) and security objective functions. Security objective functions include both reliability and system transient stability improvement. Energy not supplied (ENS) cost is considered as the criterion for system reliability and critical clearing time (CCT) is considered as the criterion for power system dynamic stability. In order to reduce the computational burden of the proposed method, off-line training of neural network is used to determine CCT based on the system operating point. For this purpose, CCT parameter is calculated in Dig silent Software environment for various operating points of system and a data set is obtained to train neural network. In the proposed method, it is tried to improve dynamic stability of system, as well as decreasing the operation cost in post contingency state through optimal load shedding and generation rescheduling. Genetic algorithm (GA) is used as the optimization tool. The proposed framework is tested on IEEE 39-bus test system and results show efficiency of the proposed method.