rceOptimalStateSignal ::
  (Vec.Walker vec, Arith.Sum a,Vec.Zipper vec, Show a,RealFloat a,
   Ord a, Vec.Storage vec a, Vec.Singleton vec) =>
  Balance.StateForcing ->
  Sig.UTSignal vec a ->
  Sig.UTSignal vec a ->
  Sig.UTSignal vec a
forceOptimalStateSignal stateForcing overallOptimalSignal optimalSignalOfState =
  case stateForcing of
       Balance.StateForcingOn -> Sig.offset minimalDifference optimalSignalOfState
       Balance.StateForcingOff -> optimalSignalOfState
  where differenceSignal = overallOptimalSignal Sig..- optimalSignalOfState
        minimalDifference = Sig.fromScalar $ Sig.minimumWithNaN differenceSignal


forceOptimalStateSignal ::
  (Vec.Walker vec, Arith.Sum a,Vec.Zipper vec, Show a,RealFloat a,
   Ord a, Vec.Storage vec a, Vec.Singleton vec) =>
  Balance.StateForcing ->
  Sig.UTSignal vec a ->
  Sig.UTSignal vec a ->
  Sig.UTSignal vec a
forceOptimalStateSignal stateForcing overallOptimalSignal optimalSignalOfState =
  case stateForcing of
       Balance.StateForcingOn -> Sig.offset minimalDifference optimalSignalOfState
       Balance.StateForcingOff -> optimalSignalOfState
  where differenceSignal = overallOptimalSignal Sig..- optimalSignalOfState
        minimalDifference = Sig.fromScalar $ Sig.minimumWithNaN differenceSignal
forceOptimalStateSignal stateForcing overallOptimalSignal optimalSignalOfState =
  case stateForcing of
       Balance.StateForcingOn -> Sig.offset minimalDifference optimalSignalOfState
       Balance.StateForcingOff -> optimalSignalOfState
  where differenceSignal = overallOptimalSignal Sig..- optimalSignalOfState
        minimalDifference = Sig.fromScalar $ Sig.minimumWithNaN differenceSignal