During the last decade, distribution networks have experienced essential changes driven by the integration of renewable-energy sources, batteries, electric-vehicle charging stations, etc. This results in not only opportunities, but also operational problems. For example, the renewable power generation and the charging-station power consumption can be very large, leading to line congestion and over-/under-voltage issues. To solve the operational problems, we can develop methods that consist in directly manipulating the power; this is feasible by means of power-electronic devices and local controllers. For example, to address the line congestion and over-/under-voltage issues, we can either perform power curtailment at the energy sources and charging stations, or use batteries and demand response to avoid excessive power. So far, there is a growing number of works on managing distribution networks via direct power manipulation. These works include both the typical ones, such as regulating voltage/frequency by active/reactive power, and the pioneering ones, such as the Commelec that controls distribution networks by multi-agent systems and explicit power setpoints. With the integrated loads/sources and the direct power manipulation, the essence of distribution networks has changed. This gives us the concept of active distribution networks (ADNs). In this thesis, we focus on how to ensure network security and achieve optimality in ADNs. First, we study the AC power-flow problem in generically modelled multi-phase ADNs, which is an inverse problem. It determines whether a target system power injection has a corresponding system electrical state that fulfills the security constraints and might need to be repeatedly solved in real time. For this problem, we apply the fixed-point theory and establish explicit conditions for the existence and uniqueness of the power-flow solution. When the conditions are satisfied, we guarantee the existence of a power-flow solution and analytically specify a domain in which this solution is unique. For this guaranteed solution, we further provide an efficient iterative method to numerically compute it. Second, we take into account that the actual system power injection might be different from the target one, due to improperly modelled system dynamics, reaction delays, and renewable-energy disturbances. As a consequence, it is important to see whether we can ensure that the actual system electrical state always satisfies the security constraints, given that the actual system power injection resides in some known uncertainty set. We refer to this as the admissibility problem, which is another inverse problem. For it, a major difficulty is that each system power injection might correspond to zero or multiple system electrical states. We layout the theoretical foundations for solving this problem. In addition, we develop two concrete solution methods that can be implemented in practical ADNs. Third, to decide the optimal system power injection, we study an AC optimal power flow problem in generically modelled multi-phase ADNs. In this problem, we consider wye/delta load/source connections and incorporate the non-singularity constraint. We solve this problem by developing a successive local exploration method. All proposed theories and methods have been numerically evaluated via IEEE/CIGRE test feeders.