The weights in SOSs are used to select branching variables. They define an order of the variables in the special ordered set. You can find more details in the respective chapter of the user manual here. The weights should not affect correctness. So if you get invalid results then something else is wrong.
You cannot specify the weights as a matrix (see the documentation of addSOSs here). You can only give a cell array of columns.
As far as I can tell, your code looks correct. Could you add this statement before cplex.solve():
cplex.writeModel('model.lp');
Then look at the created file model.lp (maybe post it here). This file should contain a section called SOS with this content:
SOS
s1: S1 :: x1 : 1 x2 : 2 x3 : 3
s2: S1 :: x4 : 1 x5 : 2 x6 : 3
s3: S1 :: x7 : 1 x8 : 2 x9 : 3
Do you see this in the file? If yes then the SOSs are correctly defined and the issue must be somewhere else.
If you observe that two of x1, x2, x3 are 1, are they really 1 or are they just not equal to 0? What are the exact floating point values of those variables in an incorrect solution?
#CPLEXOptimizers#DecisionOptimization