Combinatorial optimisation is applied to maximise oil production in some intelligent completion systems. The motivation is to use an optimisation approach to increase oil production from smart wells. Model-based optimal control requires a suitable computational engine for use in the optimisation codes; Fastflo 3.0, a programmable finite element-based PDE solver, is used because it is an accurate simulator which is suitable in the role of an internal routine. Optimal control algorithms which maximise production of oil in horizontal and dual completion production systems are developed for various control strategies. Oil production in the dual completion system is maximised by application of a search routine where the control variables, the oil and water flows, are assumed to be discrete functions of time. The evolution of the safe operating envelope for a dual completion well is studied as an optimal control problem-it is shown how to develop a stochastic search method to calculate optimal trajectory of oil and water flow rates. The width of the calculated safety envelope shows that in practice, unless some optimisation is initially done, the oil production rate will be far below the maximum possible rate.