added function \'optiS1\' to determine optimal value for S1 given some S2