Skip to content

Commit

Permalink
Made the basis-finding algorithm a little more robust. Bumped to vers…
Browse files Browse the repository at this point in the history
…ion 0.3.5
  • Loading branch information
ariostas committed Feb 22, 2022
1 parent 07c25c1 commit 40103ac
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 19 deletions.
2 changes: 1 addition & 1 deletion cytools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from cytools.utils import read_polytopes, fetch_polytopes

# Latest version
version = "0.3.4"
version = "0.3.5"
versions_with_serious_bugs = []

# Check for more recent versions of CYTools
Expand Down
34 changes: 20 additions & 14 deletions cytools/polytope.py
Original file line number Diff line number Diff line change
Expand Up @@ -1799,10 +1799,18 @@ def glsm_charge_matrix(self, include_origin=True,
basis_exc = []
indices = np.argsort(norms)
indices[:linrel.shape[0]] = np.sort(indices[:linrel.shape[0]])
for n_try in range(4):
for n_try in range(14):
if n_try == 1:
indices[:] = np.array(range(linrel.shape[1]))
elif n_try > 1:
elif n_try == 2:
pts_lll = np.array(fmpz_mat(linrel[1:,:].tolist()).lll().tolist(), dtype=int)
norms = [np.linalg.norm(p,1) for p in pts_lll.T]
indices = np.argsort(norms)
indices[:linrel.shape[0]] = np.sort(indices[:linrel.shape[0]])
elif n_try == 3:
indices[:] = np.array([0] + list(range(1,linrel.shape[1]))[::-1])
indices[:linrel.shape[0]] = np.sort(indices[:linrel.shape[0]])
elif n_try > 3:
np.random.shuffle(indices[1:])
indices[:linrel.shape[0]] = np.sort(indices[:linrel.shape[0]])
for ctr in range(np.prod(linrel.shape)+1):
Expand Down Expand Up @@ -1840,18 +1848,16 @@ def glsm_charge_matrix(self, include_origin=True,
if found_good_basis:
break
if not found_good_basis:
raise Exception("failed")
if ctr == np.prod(linrel.shape):
print("Warning: An integral basis could not be found. "
"A non-integral one will be computed. However, this "
"will not be usable as a basis of divisors for the "
"ToricVariety or CalabiYau classes. Please let the "
"developers know about the polytope that caused this "
"issue. Here are the vertices of the polytope: "
f"{self.vertices().tolist()}")
return self.glsm_charge_matrix(include_origin=include_origin,
include_points_interior_to_facets=include_points_interior_to_facets,
points=points, integral=False)
print("Warning: An integral basis could not be found. "
"A non-integral one will be computed. However, this "
"will not be usable as a basis of divisors for the "
"ToricVariety or CalabiYau classes. Please let the "
"developers know about the polytope that caused this "
"issue. Here are the vertices of the polytope: "
f"{self.vertices().tolist()}")
return self.glsm_charge_matrix(include_origin=include_origin,
include_points_interior_to_facets=include_points_interior_to_facets,
points=points, integral=False)
linrel_dict = {ii:i for i,ii in enumerate(indices)}
linrel = np.array(linrel_rand[:,[linrel_dict[i] for i in range(linrel_rand.shape[1])]])
basis_ind = np.array([i for i in range(linrel.shape[1]) if linrel_dict[i] not in basis_exc], dtype=int)
Expand Down
2 changes: 1 addition & 1 deletion scripts/linux/cytools
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ cat << EOF
░░█████████ █████ █████ ░░██████ ░░██████ █████ ██████
░░░░░░░░░ ░░░░░ ░░░░░ ░░░░░░ ░░░░░░ ░░░░░ ░░░░░░
Developed by Liam McAllister's Group | Version 0.3.4
Developed by Liam McAllister's Group | Version 0.3.5
https://cytools.liammcallistergroup.com
EOF
Expand Down
2 changes: 1 addition & 1 deletion scripts/macos/cytools
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ cat << EOF
░░█████████ █████ █████ ░░██████ ░░██████ █████ ██████
░░░░░░░░░ ░░░░░ ░░░░░ ░░░░░░ ░░░░░░ ░░░░░ ░░░░░░
Developed by Liam McAllister's Group | Version 0.3.4
Developed by Liam McAllister's Group | Version 0.3.5
https://cytools.liammcallistergroup.com
EOF
Expand Down
2 changes: 1 addition & 1 deletion scripts/windows/launcher.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ $banner=@"
░░█████████ █████ █████ ░░██████ ░░██████ █████ ██████
░░░░░░░░░ ░░░░░ ░░░░░ ░░░░░░ ░░░░░░ ░░░░░ ░░░░░░
Developed by Liam McAllister's Group | Version 0.3.4
Developed by Liam McAllister's Group | Version 0.3.5
https://cytools.liammcallistergroup.com
"@
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="cytools",
version="0.3.4",
version="0.3.5",
author="Liam McAllister Group",
author_email="",
description="A software package for analyzing Calabi-Yau hypersurfaces in toric varieties.",
Expand Down

0 comments on commit 40103ac

Please sign in to comment.