Once you set the parameters and the geometry build-up correctly, it should work. Suppose the frst layer begins at z0, and their thickness is d1,d2,d3:
setnamed("layer1","z min",z0);
setnamed("layer1","z max",z+d1);
setnamed("layer2","z min",z+d1);
setnamed("layer2","z max",z+d1+d2);
setnamed("layer3","z min",z+d1+d2);
setnamed("layer3","z max",z+d1+d2+d3);
then you can optimize d1,d2 and d3.