Hydrocode calculations require knowledge of the variation of pressure of a material with density and temperature, which is given by the equation of state. An accurate model needs to account for discontinuities in energy, density and properties of a material across a phase boundary. When generating a multiphase equation of state the modeller attempts to balance the agreement between the available data for compression, expansion and phase boundary location. However, this can prove difficult because minor adjustments in the equation of state for a single phase can have a large impact on the overall phase diagram. This paper describes how combining statistical-mechanics-based condensed matter physics models with a stochastic analysis technique called particle swarm optimisation, yields multiphase equations of state which give good agreement with experiment over a wide range of pressure-temperature space. Aluminium and tin are used as test cases in the proof of principle described in this paper.