Skip to content

Commit

Permalink
Merge pull request #605 from bobmyhill/rm_ECOS_cvxpy
Browse files Browse the repository at this point in the history
remove ECOS as default linear solver for cvxpy
  • Loading branch information
bobmyhill authored Nov 12, 2024
2 parents cca76d0 + 0fad7db commit b65e918
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 2 additions & 0 deletions burnman/classes/solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ def site_formula(self, precision=2):
for i, site_occs in enumerate(self.site_occupancies):
formula += "["
for species, occ in site_occs.items():
if np.abs(occ) < 1.0e-12:
occ = np.abs(occ)
formula += f"{species}{occ:0.{precision}f}"
formula += split_empty[i + 1]
return formula
Expand Down
5 changes: 2 additions & 3 deletions burnman/optimize/linear_fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,13 @@ def weighted_constrained_least_squares(

try:
with warnings.catch_warnings(record=True) as w:
res = prob.solve(solver=cp.ECOS)
res = prob.solve()
popt = np.array([x.value[i] for i in range(len(A.T))])
warns.extend(w)
except Exception:
print("ECOS Solver failed. Trying default solver.")
try:
with warnings.catch_warnings(record=True) as w:
res = prob.solve()
res = prob.solve(solver=cp.ECOS)
popt = np.array([x.value[i] for i in range(len(A.T))])
warns.extend(w)
except Exception as e:
Expand Down
2 changes: 1 addition & 1 deletion examples/example_fit_composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
gt.set_composition(popt)

print("\nSite formula:")
print(gt.site_formula(2))
print(gt.site_formula(precision=2))

print(f"\nWeighted residual: {res:.3f}")
"""
Expand Down

0 comments on commit b65e918

Please sign in to comment.