Python code for dual decompositon for different model pairs