This paper proposes the deployment of the Hopfield's artificial neural network (H-NN) approach to optimally assign power in optical code division multiple access (OCDMA) systems. Figures of merit such as feasibility of solutions and complexity are compared with the classical power allocation methods found in the literature, such as Sequential Quadratic Programming (SQP) and Augmented Lagrangian Method (ALM). The analyzed methods are used to solve constrained nonlinear optimization problems in the context of resource allocation for optical networks, specially to deal with the energy efficiency (EE) in OCDMA networks. The promising performance-complexity tradeoff of the modified H-NN is demonstrated through numerical results performed in comparison with classic methods for general problems in nonlinear programming. The evaluation is carried out considering challenging OCDMA networks in which different levels of QoS were considered for large numbers of optical users.