ecboghiu / inflation

Implementations of the Inflation Technique for Causal Inference.
GNU General Public License v3.0
22 stars 3 forks source link

For all classical sources, difference seen when nonfanout=True vs. nonfanout=False #120

Closed ecboghiu closed 6 months ago

ecboghiu commented 11 months ago

Describe the bug I am running a modification of inflation where I optimise some upper bounds on some variables. I get an inconsistent result when I turn the nonfanout flag from True to False.

To Reproduce

from inflation import InflationProblem, InflationLP
from inflation.lp.lp_utils import solveLP
prob = InflationProblem(dag={"rhoAB": ["A", "B"]},
                        outcomes_per_party=(2, 2),
                        settings_per_party=(2, 2),
                        classical_sources='all')
lp = InflationLP(prob, supports_problem=True, nonfanout=True)
lp.set_distribution(P_PR())
args = lp._prepare_solver_arguments()
new_ineqs = []
for k, v in args['known_vars'].items(): 
    new_ineqs += [{k: 1}]
    new_ineqs += [{k: -1, 'var_epsilon': 1}] 
args['known_vars'] = {'0': 0, 'constant_term': 1} 
args['inequalities'] += new_ineqs
args['objective'] = {'var_epsilon': -1}
solution = solveLP(**args)
print(solution['x']['var_epsilon']/solution['x']['1'])

>>> 0.24999999999622097

from inflation import InflationProblem, InflationLP
from inflation.lp.lp_utils import solveLP
prob = InflationProblem(dag={"rhoAB": ["A", "B"]},
                        outcomes_per_party=(2, 2),
                        settings_per_party=(2, 2),
                        classical_sources='all')
lp = InflationLP(prob, supports_problem=True, nonfanout=False)
lp.set_distribution(P_PR())
args = lp._prepare_solver_arguments()
new_ineqs = []
for k, v in args['known_vars'].items(): 
    new_ineqs += [{k: 1}]
    new_ineqs += [{k: -1, 'var_epsilon': 1}] 
args['known_vars'] = {'0': 0, 'constant_term': 1} 
args['inequalities'] += new_ineqs
args['objective'] = {'var_epsilon': -1}
solution = solveLP(**args)
print(solution['x']['var_epsilon']/solution['x']['1'])

>>> 0.19999999999850399

Expected behavior Since classical_sources='all', it should not matter whether nonfanout=Falseor nonfanout=True.

OS Information: Inflation: Implementations of the Inflation Technique for Causal Inference

Authored by: Emanuel-Cristian Boghiu, Elie Wolfe and Alejandro Pozas-Kerstjens

Inflation Version: 1.1.0

Core Dependencies

NumPy Version: 1.26.0 SciPy Version: 1.11.3 SymPy Version: 1.12 Numba Version: Not installed Mosek Version: 10.1.12

Python Version: 3.11.5 Platform Info: Darwin (arm64)

eliewolfe commented 6 months ago

Problem has been fixed in devel since d77f2350b666a0de81030a0b395f40bb581e2eea