A controller for an optical switch, the optical switch comprising a switching fabric controllable to route optical signals from input ports to output ports, and one or more optical amplifiers for amplifying one or more of said optical signals, the controller comprising processing electronics and a control output, and configured to: determine present amplifier gains; determine, based at least in part on the present amplifier gains, a switching state of the switching fabric the switching state indicating a selected set of optical paths between the input ports and the output ports, wherein optical path losses through the switching fabric vary based on the switching state; determine whether it is possible to implement a new switching state of the switching fabric, the new switching state meeting port-to-port connectivity requirements and signal level or link budget requirements, given the present amplifier gains; provide, at the control output, a switching fabric control signal for implementing the new switching state of the switching fabric; and generate and provide, at the control output, an amplifier control signal for controlling gains of the one or more optical amplifiers, wherein the new switching state of the switching fabric is generated based at least in part on the gains of the one or more optical amplifiers; wherein the switching fabric control signal is for implementing the new switching state with amplifier gains unchanged when it is determined that an implementation of the new switching state of the switching fabric meeting port-to-port connectivity requirements and signal level or link budget requirements, given the present amplifier gains, is possible, and otherwise, the new switching state and a new set of amplifier gains are determined and implemented together, wherein the amplifier control signal is generated based on the new switching state of the switching fabric, characterized in that generating the amplifier control signal comprises: maintaining a prior amplifier control signal as the amplifier control signal when applying the prior amplifier control signal along with the configuration for the switching fabric results in a path loss for the optical switch being below a predetermined threshold, and updating the amplifier control signal otherwise, wherein the prior amplifier control signal controls gains of the one or more optical amplifiers during implementation of a prior configuration for the switching fabric, the prior configuration being immediately prior to the configuration for the switching fabric. determine present amplifier gains; determine, based at least in part on the present amplifier gains, a switching state of the switching fabric the switching state indicating a selected set of optical paths between the input ports and the output ports, wherein optical path losses through the switching fabric vary based on the switching state; determine whether it is possible to implement a new switching state of the switching fabric, the new switching state meeting port-to-port connectivity requirements and signal level or link budget requirements, given the present amplifier gains; provide, at the control output, a switching fabric control signal for implementing the new switching state of the switching fabric; and generate and provide, at the control output, an amplifier control signal for controlling gains of the one or more optical amplifiers, wherein the new switching state of the switching fabric is generated based at least in part on the gains of the one or more optical amplifiers; wherein the switching fabric control signal is for implementing the new switching state with amplifier gains unchanged when it is determined that an implementation of the new switching state of the switching fabric meeting port-to-port connectivity requirements and signal level or link budget requirements, given the present amplifier gains, is possible, and otherwise, the new switching state and a new set of amplifier gains are determined and implemented together, wherein the amplifier control signal is generated based on the new switching state of the switching fabric, characterized in that generating the amplifier control signal comprises: maintaining a prior amplifier control signal as the amplifier control signal when applying the prior amplifier control signal along with the configuration for the switching fabric results in a path loss for the optical switch being below a predetermined threshold, and updating the amplifier control signal otherwise, wherein the prior amplifier control signal controls gains of the one or more optical amplifiers during implementation of a prior configuration for the switching fabric, the prior configuration being immediately prior to the configuration for the switching fabric.