Simulation schemes for liquids or strongly fluctuating systems that allow to change the molecular representation in a subvolume of the simulation box while preserving the equilibrium with the surroundings introduce conceptual problems of thermodynamic consistency. In this work we present a general scheme based on thermodynamic arguments which ensures a thermodynamic equilibrium among molecules of different representations. The robustness of the algorithm is tested for two examples, namely, an adaptive resolution simulation, atomistic/coarse grained, for a liquid of tetrahedral molecules, and an adaptive resolution simulation of a binary mixture of tetrahedral molecules and spherical solutes.