High intensity focused ultrasound (HIFU) enables highly localized, non-invasive tissue ablation and its efficacy has been demonstrated in the treatment of a range of cancers, including those of the kidney, prostate and breast. HIFU offers the ability to treat deep-seated tumours locally, and potentially bears fewer side effects than more invasive treatment modalities such as resection, chemotherapy and ionizing radiation. There remains however a number of significant challenges which currently hinder its widespread clinical application. One of these challenges is the need to transmit sufficient energy through the ribcage to ablate tissue at the required foci whilst minimizing the formation of side lobes and sparing healthy tissue. Ribs both absorb and reflect ultrasound strongly. This sometimes results in overheating of bone and overlying tissue during treatment, leading to skin burns. Successful treatment of a patient with tumours in the upper abdomen therefore requires a thorough understanding of the way acoustic and thermal energy is deposited. Previously, a boundary element approach based on a Generalized Minimal Residual (GMRES) implementation of the Burton-Miller formulation was developed to predict the field of a multi-element HIFU array scattered by human ribs, the topology of which was obtained from CT scan data (Gélat et al 2011 Phys. Med. Biol. 56 5553-81). The present paper describes the reformulation of the boundary element equations as a least-squares minimization problem with nonlinear constraints. The methodology has subsequently been tested at an excitation frequency of 1 MHz on a spherical multi-element array in the presence of ribs. A single array-rib geometry was investigated on which a 50% reduction in the maximum acoustic pressure magnitude on the surface of the ribs was achieved with only a 4% reduction in the peak focal pressure compared to the spherical focusing case. This method was then compared with a binarized apodization approach based on ray tracing and against the decomposition of the time-reversal operator (DORT). In both cases, the constrained optimization provided a superior ratio of focal peak pressure to maximum pressure magnitude on the surface of the ribs.