Context : As the number of complex organic molecules ( COMs ) detected in the interstellar medium increases , it becomes ever more important to place meaningful constraints on the origins and formation pathways of such chemical species . The molecular cloud Sagittarius B2 ( N ) is host to several hot molecular cores in the early stage of star formation , where a great variety of COMs are detected in the gas phase . Because of its exposure to the extreme conditions of the the Galactic center ( GC ) region , Sgr B2 ( N ) is one of the best targets to study the impact of environmental conditions on the production of COMs . Aims : Our main goal is to characterize the physico-chemical evolution of Sgr B2 ( N ) ’ s sources in order to explain their chemical differences and constrain their environmental conditions . Methods : The chemical composition of Sgr B2 ( N ) ’ s hot cores , N2 , N3 , N4 , and N5 is derived by modeling their 3 mm emission spectra extracted from the EMoCA imaging spectral line survey performed with the Atacama Large Millimeter/submillimeter Array ( ALMA ) . We derive the density distribution in the envelope of the sources based on the masses computed from the ALMA dust continuum emission maps . We use the radiative transfer code RADMC-3D to compute temperature profiles and infer the current luminosity of the sources based on the COM rotational temperatures derived from population diagrams . We use published results of 3D radiation-magnetohydrodynamical ( RMHD ) simulations of high-mass star formation to estimate the time evolution of the sources properties . We employ the astrochemical code MAGICKAL to compute time-dependent chemical abundances in the sources and investigate how physical properties and environmental conditions influence the production of COMs . Results : The analysis of the abundances of 11 COMs detected toward Sgr B2 ( N2-N5 ) reveals that N3 and N5 share a similar chemical composition while N2 differs significantly from the other sources . We estimate the current luminosities of N2 , N3 , N4 , and N5 to be 2.6 \times 10 ^ { 5 } L _ { \odot } , 4.5 \times 10 ^ { 4 } L _ { \odot } , 3.9 \times 10 ^ { 5 } L _ { \odot } , and 2.8 \times 10 ^ { 5 } L _ { \odot } , respectively . We find that astrochemical models with a cosmic-ray ionization rate of 7 \times 10 ^ { -16 } s ^ { -1 } best reproduce the abundances with respect to methanol of ten COMs observed toward Sgr B2 ( N2-N5 ) . We also show that COMs still form efficiently on dust grains with minimum dust temperatures in the prestellar phase as high as 15 K , but that minimum temperatures higher than 25 K are excluded . Conclusions : The chemical evolution of Sgr B2 ( N2-N5 ) strongly depends on their physical history . A more realistic description of the hot cores ’ physical evolution requires a more rigorous treatment with RMHD simulations tailored to each hot core .