Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem-specific certificates #118

Open
wants to merge 6 commits into
base: devel
Choose a base branch
from

Conversation

ericahan22
Copy link
Collaborator

Suppose we have a matrix $A$ of constraints and a vector $b$ of values such that $A_{eq}x=b_{eq}$ and $A_{ineq}x \geq b_{ineq}$ and a vector of dual variables $y$ corresponding to the constraints. Then the problem-specific certificate is a dictionary in the form {'A_i - b_i': y_i} for the ith constraint, where A_i uses the names of the variables (e.g. p(0|0)).

@ericahan22 ericahan22 added the enhancement New feature or request label Sep 29, 2023
@ericahan22 ericahan22 self-assigned this Sep 29, 2023
@ericahan22 ericahan22 marked this pull request as draft October 8, 2023 21:44
@ericahan22
Copy link
Collaborator Author

After attempting to change all equalities to two inequalities in solveLP_sparse, all the dual values are 0 when I run Example 4 from examples.ipynb, so I'm not sure if I did it right or where it might be wrong. I'm also not sure how to make this change for only supports problems in lp_utils. Furthermore, one supports test is failing (feasible support for Bell scenario is returning infeasible)

@ecboghiu
Copy link
Owner

While the certificates are zero, does the actual problem work ok? For example, for Example 4, with the LP and all sources classical the critical visibility of the PR box is 1/2. If this is reproduced, then probably its a problem with processing the certificates, which should not be too difficult to fix.

@ericahan22
Copy link
Collaborator Author

Changes:

  • Problem-specific certificates are now in the form $c \cdot x_{sym} \geq (s_l^x-s_u^x) \cdot x_{sym}$ where $x_i$ in $x_{sym}$ is the variable as a string for problem-specific variables and its numeric value otherwise
  • Known values are now encoded as fixed variable bounds instead of equality constraints
  • solve_dual, relaxations (feasibility as optimization) are removed for now

@ericahan22
Copy link
Collaborator Author

ericahan22 commented Oct 13, 2023

Failing tests:

SubTest failure: Traceback (most recent call last):
  File "..\case.py", line 59, in testPartExecutor
    yield
  File "..\case.py", line 498, in subTest
    yield
  File "..\test\test_pipeline.py", line 882, in _GHZ
    lp.solve()
  File "..\inflation\lp\InflationLP.py", line 562, in solve
    self.solution_object = solveLP(**args)
  File "..\inflation\lp\lp_utils.py", line 122, in solveLP
    return solveLP_sparse(**solver_args)
  File "..\inflation\lp\lp_utils.py", line 258, in solveLP_sparse
    assert lb <= kv, \
AssertionError: The known value for pABC(010|000) is lower than the lower bound set for pABC(010|000).
One or more subtests failed
Failed subtests list: [Testing GHZ, incompatible distribution]

SubTest failure: Traceback (most recent call last):
  File "..\case.py", line 59, in testPartExecutor
    yield
  File "..\case.py", line 498, in subTest
    yield
  File "..\test\test_pipeline.py", line 882, in _GHZ
    lp.solve()
  File "..\inflation\lp\InflationLP.py", line 562, in solve
    self.solution_object = solveLP(**args)
  File "..\inflation\lp\lp_utils.py", line 122, in solveLP
    return solveLP_sparse(**solver_args)
  File "..\inflation\lp\lp_utils.py", line 258, in solveLP_sparse
    assert lb <= kv, \
AssertionError: The known value for pABC(010|000) is lower than the lower bound set for pABC(010|000).
One or more subtests failed
Failed subtests list: [Testing GHZ, incompatible distribution]

SubTest failure: Traceback (most recent call last):
  File "..\case.py", line 59, in testPartExecutor
    yield
  File "..\case.py", line 498, in subTest
    yield
  File "..\test\test_pipeline.py", line 652, in test_instrumental
    self.assertIn(lp.status, ["prim_infeas_cer", "dual_infeas_cer",
AssertionError: 'optimal' not found in ['prim_infeas_cer', 'dual_infeas_cer', 'unknown'] : Failed to detect the infeasibility of the distribution that maximally violates Bonet's inequality.
One or more subtests failed
Failed subtests list: [Infeasible Bonet's inequality]

SubTest failure: Traceback (most recent call last):
  File "..\case.py", line 59, in testPartExecutor
    yield
  File "..\case.py", line 498, in subTest
    yield
  File "..\test\test_pipeline.py", line 683, in test_supports
    self.assertIn(lp.status, ["prim_infeas_cer", "dual_infeas_cer"],
AssertionError: 'optimal' not found in ['prim_infeas_cer', 'dual_infeas_cer'] : Failed to detect the infeasibility of a support known to be incompatible.
One or more subtests failed
Failed subtests list: [Incompatible support]

Ran 86 tests in 45.739s
FAILED (failures=4, skipped=18)

I can look at the failing [Testing GHZ, incompatible distribution] tests but I'm not sure what's going on with the other two

@ericahan22
Copy link
Collaborator Author

While the certificates are zero, does the actual problem work ok? For example, for Example 4, with the LP and all sources classical the critical visibility of the PR box is 1/2. If this is reproduced, then probably its a problem with processing the certificates, which should not be too difficult to fix.

When I try getting the critical visibility using max_within_feasible, I get some error like:

Traceback (most recent call last):
  File "..\trash.py", line 23, in <module>
    v, cert = max_within_feasible(lp,
  File "..\inflation\sdp\optimization_utils.py", line 84, in max_within_feasible
    return _maximize_via_bisect(sdp, symbolic_values, param, **kwargs)
  File "..\inflation\sdp\optimization_utils.py", line 166, in _maximize_via_bisect
    crit_param = bisect(f, bounds[0], bounds[1], **bisect_kwargs, full_output=False)
  File "..\venv\lib\site-packages\scipy\optimize\_zeros_py.py", line 557, in bisect
    r = _zeros._bisect(f, a, b, xtol, rtol, maxiter, args, full_output, disp)
ValueError: f(a) and f(b) must have different signs

@ericahan22
Copy link
Collaborator Author

Feasibility as optimization is back and implemented using the relax inequalities method (now a flag named relaxation), relax_known_vars is removed. Also added solveform.dual parameter for the interior-point optimizer. All tests passing :)

@ericahan22 ericahan22 marked this pull request as ready for review October 27, 2023 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants