This paper presents two modified versions of the Tasmanian Devil Optimization (TDO) for dealing with the optimal power flow (OPF) problem in both conventional and advanced power systems. The original TDO is enhanced with two distinct constraint handling techniques: weighted factors (WF) in addition to the superiority of feasible solutions (SF).The two developed algorithms (TDO-WF and TDO-SF) are applied to tackle both single and multi-objective functions of the OPF problem. Two test systems are used for verifying the two developed algorithms in different case studies. The first test system is the IEEE-30 bus system in its conventional form, while the second system is an advanced version of the IEEE-30 bus system that contains three distinct sorts of renewable energy plants and a variable load. The MATLAB software is used for simulation purposes. The two developed algorithms overcame the problem of violating the system’s constraints in the original TDO and achieved better results than alternative approaches in the related research. A statistical analysis and a Wilcoxon signed rank test are carried out to define the best one of the two developed techniques. The results of the two suggested techniques are quite similar, and we verified the validity of both of them to tackle the OPF problem in both conventional and advanced power systems.