Elastic-energy relaxation in heterostructures with strained nanoinclusions