We present a model-based optimization approach to determine the configuration of a petroleum refinery for grassroots (new) or existing site that considers a large number of commercial technologies particularly for heavy oil processing of crude oil residue from an atmospheric distillation unit. First, we develop a superstructure representation for the refinery configuration to encompass all possible topology alternatives comprising 96 technologies and their interconnectivities. The superstructure is postulated by decomposing it to incorporate representative heavy oil processing scheme alternatives that center on the technologies for atmospheric residual hydrodesulfurization (ARDS), vacuum residual hydrodesulfurization (VRDS), and residual fluid catalytic cracking (RFCC). We formulate a mixed-integer linear program (MILP) based on the superstructure by devising logic propositions on design and structural specifications that represent these processing options to aid convergence to an optimal refinery configu...