MoMPy: Moment matrix generation and managing package for SDP hierarchies.
This is a package to generate moment matrices for SDP hierarchies. The package contains the following relevant functions:
- MomentMatrix: generates the moment matrix with operational equivalences already taken into account (except normalisation).
- normalisation_contraints: takes into account normalisation constraints. This is to be called inside the SDP and added as a constraint!
More information in the code files. The package is still in development phase.
How does it work?
It's simple. Suppose you have an optimisation problem involving traces of operators A_{a}, B_{y,b} and C_{k} as for example:
maximise Tr[A_{a} * B_{y,b}]
s.t. Tr[C_{k} * B_{y,b}] >= c_{k,y,b}
1) Define a set of lists of scalar numbers. Each different scalar represents a different operator. to keep track of each operator easily, we suggest to use the following notations:
- List of operators:
A = [] # Operator A
B = [] # Operator B
C = [] # Operator C
- List where we will store the operators:
S = [] # List of first order elements
- Store the operators:
# A has indices A[a]
cc = 1
for a in range(nA):
S += [cc]
R += [cc]
cc += 1
# B has indices B[y][b]
for y in range(nY):
B += [[]]
for b in range(nB):
S += [cc]
B[y] += [cc]
cc += 1
# C has indices [k]
for k in range(nK):
S += [cc]
C += [cc]
cc += 1
2) Declare operational relations. These consists in the following:
- Operators are rank-1: rank_1_projectors
- Operators are orthogonal for different specific indices: orthogonal_projectors
- Operators commute with every other element: commuting_variables
- Operators may not commute with some other operators (which we call states): list_states
For example, suppose all operators are rank-1,
rank_1_projectors = []#w_R
rank_1_projectors += [w_B[y][b] for y in range(nY) for b in range(nB)]
rank_1_projectors += [w_P[k] for k in range(nK)]
operators B are orthogonal for indices [b] for every [y], and same for P but for incides [k]
orthogonal_projectors = []
orthogonal_projectors += [ w_B[y] for y in range(nY)]
orthogonal_projectors += [ w_P ]
and nothing else for now (for simplicity),
list_states = []
commuting_variables = []
3) If we include 1st order elements, we write S as the first entry of the function.
If additionally we want to automatically include all 2nd order elements, we write S as the second entry as well.
If we need additional specific elements of higher order elements, we can include them in the list S_high as for example,
S_high = []
for a in range(nA):
for aa in range(nA):
S_high += [[A[a],A[aa]]]
for a in range(nA):
for b in range(nB):
for y in range(nY):
S_high += [[A[a],B[y][b]]]
for k in range(nK):
for b in range(nB):
for y in range(nY):
S_high += [[C[k],B[y][b]]]
for a in range(nA):
for k in range(nK):
S_high += [[C[k],A[a]]]
Here we included the specific seconnd order elements [[A,A],[A,B],[C,B],[C,A]], but we can include any other higher order elemetns if required.
4) Call MomentMatrix inbuilt function as follows:
[MoMatrix,map_table,S,list_of_eq_indices,Mexp] = MomentMatrix(S,S,S_high,rank_1_projectors,orthogonal_projectors,commuting_variables,list_states)
This function returns:
- MoMatrix: matrix of scalar indices that represent different quantities within the moment matrix. To be used as indices to label SDP variables.
- map_table: table to map from explicit operators to indices in MoMatrix. This shall be used with the inbuilt matrix: fmap(map_table,i) as
fmap(map_table,[A[a],B[y][b]]) returns the index corresponding to the variable that represents Tr[A[a] * B[y][b]].
- S: list of first order elements that we wrote as input
- list_of_eq_indices: complete list of unique indices that appear in MoMatrix. These are ordered from lowest to highest.
- Mexp: Moment matrix with explicit operators as we defined them in the beginning.
Raw data
{
"_id": null,
"home_page": null,
"name": "MoMPy",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "SDP hierarchy, moment matrix, quantum correlations, semidefinite programming",
"author": null,
"author_email": "Carles Roch i Carceller <chalswater@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/ef/17/981e9e90c7820e55f82132ab212031bb22abaed91d74ac3c924421ff7c0f/mompy-0.1.0.tar.gz",
"platform": null,
"description": "MoMPy: Moment matrix generation and managing package for SDP hierarchies.\n\nThis is a package to generate moment matrices for SDP hierarchies. The package contains the following relevant functions:\n\n - MomentMatrix: generates the moment matrix with operational equivalences already taken into account (except normalisation).\n\n - normalisation_contraints: takes into account normalisation constraints. This is to be called inside the SDP and added as a constraint!\n\nMore information in the code files. The package is still in development phase.\n\nHow does it work?\n\nIt's simple. Suppose you have an optimisation problem involving traces of operators A_{a}, B_{y,b} and C_{k} as for example:\n\nmaximise Tr[A_{a} * B_{y,b}] \ns.t. Tr[C_{k} * B_{y,b}] >= c_{k,y,b}\n\n\n\n1) Define a set of lists of scalar numbers. Each different scalar represents a different operator. to keep track of each operator easily, we suggest to use the following notations:\n\n - List of operators:\n \n A = [] # Operator A\n B = [] # Operator B\n C = [] # Operator C\n \n - List where we will store the operators:\n \n S = [] # List of first order elements\n \n - Store the operators:\n \n # A has indices A[a]\n cc = 1 \n for a in range(nA):\n S += [cc]\n R += [cc]\n cc += 1\n \n # B has indices B[y][b]\n for y in range(nY):\n B += [[]]\n for b in range(nB): \n S += [cc]\n B[y] += [cc]\n cc += 1\n \n # C has indices [k]\n for k in range(nK):\n S += [cc]\n C += [cc]\n cc += 1\n\n2) Declare operational relations. These consists in the following:\n\n - Operators are rank-1: rank_1_projectors\n - Operators are orthogonal for different specific indices: orthogonal_projectors\n - Operators commute with every other element: commuting_variables\n - Operators may not commute with some other operators (which we call states): list_states\n \n For example, suppose all operators are rank-1, \n\n rank_1_projectors = []#w_R\n rank_1_projectors += [w_B[y][b] for y in range(nY) for b in range(nB)]\n rank_1_projectors += [w_P[k] for k in range(nK)]\n\n operators B are orthogonal for indices [b] for every [y], and same for P but for incides [k]\n\n \n orthogonal_projectors = []\n orthogonal_projectors += [ w_B[y] for y in range(nY)]\n orthogonal_projectors += [ w_P ] \n\n and nothing else for now (for simplicity),\n\n list_states = [] \n commuting_variables = [] \n \n \n3) If we include 1st order elements, we write S as the first entry of the function. \nIf additionally we want to automatically include all 2nd order elements, we write S as the second entry as well. \nIf we need additional specific elements of higher order elements, we can include them in the list S_high as for example,\n\n S_high = []\n for a in range(nA):\n for aa in range(nA):\n S_high += [[A[a],A[aa]]]\n \n for a in range(nA):\n for b in range(nB):\n for y in range(nY):\n S_high += [[A[a],B[y][b]]]\n \n for k in range(nK):\n for b in range(nB):\n for y in range(nY):\n S_high += [[C[k],B[y][b]]]\n \n for a in range(nA):\n for k in range(nK):\n S_high += [[C[k],A[a]]]\n\nHere we included the specific seconnd order elements [[A,A],[A,B],[C,B],[C,A]], but we can include any other higher order elemetns if required.\n\n4) Call MomentMatrix inbuilt function as follows:\n\n[MoMatrix,map_table,S,list_of_eq_indices,Mexp] = MomentMatrix(S,S,S_high,rank_1_projectors,orthogonal_projectors,commuting_variables,list_states)\n \nThis function returns:\n\n - MoMatrix: matrix of scalar indices that represent different quantities within the moment matrix. To be used as indices to label SDP variables.\n - map_table: table to map from explicit operators to indices in MoMatrix. This shall be used with the inbuilt matrix: fmap(map_table,i) as\n \n fmap(map_table,[A[a],B[y][b]]) returns the index corresponding to the variable that represents Tr[A[a] * B[y][b]].\n \n - S: list of first order elements that we wrote as input\n - list_of_eq_indices: complete list of unique indices that appear in MoMatrix. These are ordered from lowest to highest.\n - Mexp: Moment matrix with explicit operators as we defined them in the beginning.\n \n \n \n \n \n \n \n \n \n \n \n \n ",
"bugtrack_url": null,
"license": null,
"summary": "Moment matrix generation package for SDP hierarchies",
"version": "0.1.0",
"project_urls": {
"Homepage": "https://github.com/chalswater/MoMPy"
},
"split_keywords": [
"sdp hierarchy",
" moment matrix",
" quantum correlations",
" semidefinite programming"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "13599298619fd69dea6a1b43c888f85df55f66ee0a69adf95370505b37de7292",
"md5": "af71ba61bc11e9909d533d10c89a037a",
"sha256": "6df69e1b1a5f2dc921fc029ce2314f164fe3a742a880a79e6ea244aa5f9922f4"
},
"downloads": -1,
"filename": "mompy-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "af71ba61bc11e9909d533d10c89a037a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 12138,
"upload_time": "2024-10-21T10:58:55",
"upload_time_iso_8601": "2024-10-21T10:58:55.166023Z",
"url": "https://files.pythonhosted.org/packages/13/59/9298619fd69dea6a1b43c888f85df55f66ee0a69adf95370505b37de7292/mompy-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ef17981e9e90c7820e55f82132ab212031bb22abaed91d74ac3c924421ff7c0f",
"md5": "39d96921f682a67994eb400d82506599",
"sha256": "07ace575e25ee3408b5ac0cede6771d22d21a52b536bcdd669031cdb5b328915"
},
"downloads": -1,
"filename": "mompy-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "39d96921f682a67994eb400d82506599",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 8198,
"upload_time": "2024-10-21T10:58:56",
"upload_time_iso_8601": "2024-10-21T10:58:56.800050Z",
"url": "https://files.pythonhosted.org/packages/ef/17/981e9e90c7820e55f82132ab212031bb22abaed91d74ac3c924421ff7c0f/mompy-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-21 10:58:56",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "chalswater",
"github_project": "MoMPy",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "mompy"
}