Abstract The paper introduces a method for solving the failure probability-safety factor problem for designing engineering works proposed by Castillo et al. that optimizes an objective function subject to the standard geometric and code constraints, and two more sets of constraints that simultaneously guarantee given safety factors and failure probability bounds associated with a given set of failure modes. The method uses the dual variables and is especially convenient to perform a sensitivity analysis, because sensitivities of the objective function and the reliability indices can be obtained with respect to all data values. To this end, the optimization problems are transformed into other equivalent ones, in which the data parameters are converted into artificial variables, and locked to their actual values. In this way, some variables of the associated dual problems become the desired sensitivities. In addition, using the proposed methodology, calibration of codes based on partial safety factors can be done. The method is illustrated by its application to the design of a simple rubble mound breakwater and a bridge crane.