In the present paper, a study is performed focussing on techno-economic analysis and optimisation of both grey (syngas) and green methanol production. The core of this study is centered around a freely available process simulation tool which, after rigorous validation and fidelity establishment, is used to generate training and test sets for surrogate model building, facilitating easy and speedy combination with relevant optimisation algorithms. This is facilitated by a high level of automation via a python wrapper. An economic analysis is built into the wrapper including CAPEX models for all main equipment and corresponding total plant cost as well an OPEX model factoring in both variable and fixed costs. In addition, the importance and implications of various means of heat recovery and heat integration are also addressed in order to make the methanol synthesis process self-supplied with heat.