Advanced Modeling and Optimization Techniques for Smart Grids: From Prosumer Behavior to Three-Phase Distribution Systems Analyses