To properly model highly entropic inhomogeneous materials in the canonical ensemble by molecular dynamics simulations, it is necessary to choose algorithms which rigorously implement the ensemble. Approximate methods may have either very low efficiency or completely fail in the very soft regime. The calculation of the shear modulus of the diluted central force network is used to illustrate this point. Four algorithms to realize the canonical ensemble have been tested on two methods of evaluation of the shear modulus.