pymdkit 1.7.7__tar.gz → 1.7.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pymdkit-1.7.7 → pymdkit-1.7.8}/CHANGELOG.md +6 -0
- {pymdkit-1.7.7/src/pymdkit.egg-info → pymdkit-1.7.8}/PKG-INFO +64 -9
- {pymdkit-1.7.7 → pymdkit-1.7.8}/README.md +63 -8
- {pymdkit-1.7.7 → pymdkit-1.7.8}/pyproject.toml +1 -1
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/__init__.py +1 -1
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/_dope_certify.py +5 -1
- pymdkit-1.7.8/src/pymdkit/commands/_dope_exact.py +209 -0
- pymdkit-1.7.8/src/pymdkit/commands/_dope_graph.py +132 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/_dope_optimize.py +9 -5
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/_msd_coordinates.py +25 -6
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/_msd_io.py +17 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/_msd_reuse.py +19 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/_vasp_nep.py +66 -2
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/msd.py +4 -1
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/vasp_out.py +52 -1
- {pymdkit-1.7.7 → pymdkit-1.7.8/src/pymdkit.egg-info}/PKG-INFO +64 -9
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit.egg-info/SOURCES.txt +5 -0
- pymdkit-1.7.8/tests/test_dope_graph.py +78 -0
- pymdkit-1.7.8/tests/test_msd_wrapped.py +124 -0
- pymdkit-1.7.8/tests/test_vasp_nep_bec.py +192 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/LICENSE +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/MANIFEST.in +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/setup.cfg +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/_config.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/_logging.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/__init__.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/_cifio.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/_extxyz.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/_fileio.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/_geometry.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/_gpumd.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/_gpumd_final_structure.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/_gpumd_msd.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/_gpumd_run.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/_gpumd_status.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/_gpumd_thermo.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/_ionhop.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/_lattice.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/_msd_auto.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/_msd_conductivity.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/_msd_fit.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/_msd_provenance.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/_msd_range.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/_msd_thermo.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/_msd_uncertainty.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/_oxidation.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/_parallel.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/_precision.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/_pred_msd_plan.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/_pred_msd_reference.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/_reduction.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/_submit.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/_submit_vasp.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/_supercell.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/_symmetry.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/_vasp_ehull.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/_vasp_final_structure.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/_vasp_output.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/_vaspset.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/chemsys_entry.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/compute_rmsd.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/config.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/convert.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/dope.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/ewald.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/gpumd_job.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/gpumd_out.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/ionhop.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/nep_rmse.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/perturb.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/pred_msd_time.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/rd.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/realloc_occ.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/submit.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/supercell.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/trjconv.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/commands/vasp_job.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit/pymdkit_main.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit.egg-info/dependency_links.txt +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit.egg-info/entry_points.txt +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit.egg-info/requires.txt +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/src/pymdkit.egg-info/top_level.txt +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/tests/data/88-Li2YCl3-63-d1.cif +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/tests/test_config_logging.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/tests/test_convert.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/tests/test_dope_certify.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/tests/test_dope_optimize.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/tests/test_dope_performance.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/tests/test_ehull.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/tests/test_gpumd_job_fixes.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/tests/test_gpumd_out.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/tests/test_ionhop.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/tests/test_lattice_symmetry.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/tests/test_msd_auto.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/tests/test_msd_fit.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/tests/test_msd_large.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/tests/test_msd_phase3.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/tests/test_msd_range.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/tests/test_msd_reuse.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/tests/test_msd_uncertainty.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/tests/test_parallel.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/tests/test_pred_msd_time.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/tests/test_progress.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/tests/test_realloc_occ.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/tests/test_rmsd_gpu.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/tests/test_rmsd_max.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/tests/test_rmsd_two_folder.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/tests/test_submit.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/tests/test_v165.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/tests/test_v170_job_infrastructure.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/tests/test_v170_vasp_consolidation.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/tests/test_v172_vasp_writing.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/tests/test_vasp_out.py +0 -0
- {pymdkit-1.7.7 → pymdkit-1.7.8}/tests/test_vaspset.py +0 -0
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.7.8
|
|
4
|
+
|
|
5
|
+
- Validate wrapped-only GPUMD schemas, preserve streaming MIC reconstruction and COM semantics, and record coordinate provenance and sampling diagnostics.
|
|
6
|
+
- Prune exact doping thresholds with applicable packing bounds; add exact graph reductions, verified clique constraints and LP bounds, and maximum-independent-set certification with validated witnesses.
|
|
7
|
+
- Preserve timeout status semantics, deterministic heuristic restarts, and all existing CLI defaults.
|
|
8
|
+
|
|
3
9
|
## 1.7.7
|
|
4
10
|
|
|
5
11
|
- Speed up automatic dope exchange scoring using exact incremental distances and bounded two-dimensional work arrays.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pymdkit
|
|
3
|
-
Version: 1.7.
|
|
3
|
+
Version: 1.7.8
|
|
4
4
|
Summary: A Python command-line toolkit for high-throughput atomistic workflows in AI-driven materials design.
|
|
5
5
|
Author-email: Yueda Wang <ydwang0608@ustc.edu.cn>
|
|
6
6
|
License-Expression: GPL-3.0-or-later
|
|
@@ -37,7 +37,16 @@ materials design. Install `pymdkit` once and call its tools from anywhere as
|
|
|
37
37
|
Commands expose explicit, documented CLI interfaces designed for reproducible shell,
|
|
38
38
|
HPC, and AI-agent workflows, and each underlying script is still runnable on its own.
|
|
39
39
|
|
|
40
|
-
## 1.7.
|
|
40
|
+
## 1.7.8 release notes
|
|
41
|
+
|
|
42
|
+
Wrapped-only GPUMD trajectories now receive strict schema validation, a sampling
|
|
43
|
+
warning, and versioned coordinate provenance. Explicit unwrapped trajectories
|
|
44
|
+
retain the existing numerical analysis. Exact doping certification now filters
|
|
45
|
+
distance levels with applicable packing bounds and strengthens the graph model
|
|
46
|
+
with safe reductions, verified cliques, and corrected LP dual bounds.
|
|
47
|
+
See `reports/1.7.8/development-report.md` for measured results and limitations.
|
|
48
|
+
|
|
49
|
+
### Previous 1.7.7 improvements
|
|
41
50
|
|
|
42
51
|
- Automatic `pmk dope` uses exact incremental exchange scores and bounded 2D
|
|
43
52
|
work arrays, preserving the three ranking metrics and search budgets.
|
|
@@ -149,7 +158,7 @@ installed.
|
|
|
149
158
|
On a machine with Internet access, run:
|
|
150
159
|
|
|
151
160
|
```bash
|
|
152
|
-
python -m pip download pymdkit==1.7.
|
|
161
|
+
python -m pip download pymdkit==1.7.8 -d pymdkit-offline
|
|
153
162
|
```
|
|
154
163
|
|
|
155
164
|
This downloads `pymdkit` and the dependencies resolved by pip into the
|
|
@@ -157,14 +166,14 @@ This downloads `pymdkit` and the dependencies resolved by pip into the
|
|
|
157
166
|
system. Then, inside the target pymdkit Python or conda environment, run:
|
|
158
167
|
|
|
159
168
|
```bash
|
|
160
|
-
python -m pip install --no-index --find-links=pymdkit-offline pymdkit==1.7.
|
|
169
|
+
python -m pip install --no-index --find-links=pymdkit-offline pymdkit==1.7.8
|
|
161
170
|
```
|
|
162
171
|
|
|
163
172
|
For optional GPU use, prepare the bundle on a networked machine compatible with
|
|
164
173
|
the target HPC platform and Python environment:
|
|
165
174
|
|
|
166
175
|
```bash
|
|
167
|
-
python -m pip download "pymdkit[gpu-cuda12]==1.7.
|
|
176
|
+
python -m pip download "pymdkit[gpu-cuda12]==1.7.8" -d pymdkit-offline
|
|
168
177
|
```
|
|
169
178
|
|
|
170
179
|
Transfer the whole `pymdkit-offline` directory, then install from it on the
|
|
@@ -172,7 +181,7 @@ target system:
|
|
|
172
181
|
|
|
173
182
|
```bash
|
|
174
183
|
python -m pip install --no-index --find-links=pymdkit-offline \
|
|
175
|
-
"pymdkit[gpu-cuda12]==1.7.
|
|
184
|
+
"pymdkit[gpu-cuda12]==1.7.8"
|
|
176
185
|
```
|
|
177
186
|
|
|
178
187
|
This GPU bundle includes the optional `cupy-cuda12x` package. Its wheels must also
|
|
@@ -620,7 +629,26 @@ E-hull mode preserves Materials Project/local-reference handling, cache files,
|
|
|
620
629
|
deterministic ordering, and writes `ehull.txt`. A supplied `-mp-api-key` is
|
|
621
630
|
redacted in `vasp-out.log`. NEP-training mode preserves converged VASP
|
|
622
631
|
structures and extxyz energy/force/stress metadata; its default output is
|
|
623
|
-
`train.xyz
|
|
632
|
+
`train.xyz`. When available, Born effective charge (BEC) tensors are automatically
|
|
633
|
+
included as the per-atom extxyz property `bec:R:9`, after forces. BEC extraction
|
|
634
|
+
independently follows `vaspout.h5 > vasprun.xml > OUTCAR`, so its source may differ
|
|
635
|
+
from the structure/energy source. PMK uses py4vasp's `charge_tensors` and the
|
|
636
|
+
existing quantity-reader fallback; pymatgen versions without Vasprun BEC support
|
|
637
|
+
continue to OUTCAR. OUTCAR extraction checks complete blocks and uses the final
|
|
638
|
+
complete block if several occur.
|
|
639
|
+
|
|
640
|
+
Each `(n_atoms, 3, 3)` tensor collection is validated for atom count, shape and
|
|
641
|
+
finite values, then flattened in printed OUTCAR row order (`xx xy xz yx yy yz zx
|
|
642
|
+
zy zz`), without transposition, atom reordering or unit conversion (units of
|
|
643
|
+
elementary charge, `|e|`). Available py4vasp structure metadata is checked against
|
|
644
|
+
the final structure. Output files in one calculation directory must describe the
|
|
645
|
+
same atomic ordering. Missing or invalid BEC leaves the configuration intact,
|
|
646
|
+
with a diagnostic and no placeholder values. Mixed datasets retain independent
|
|
647
|
+
per-frame property declarations, and the summary counts frames with/without BEC.
|
|
648
|
+
`-position-only` skips BEC extraction and omits BEC together with other calculation
|
|
649
|
+
results. No additional CLI option is needed.
|
|
650
|
+
|
|
651
|
+
Final-structure
|
|
624
652
|
mode defaults to `CONTCAR`, requires an output folder, and optionally applies
|
|
625
653
|
the strict `-max-ehull` filter using `ehull.txt` by default. All modes use
|
|
626
654
|
`vasp-out.log`, separate from scientific artifacts. The standalone `ehull` and
|
|
@@ -689,7 +717,7 @@ Its default is 120 seconds for the entire certification stage; it does not chang
|
|
|
689
717
|
the heuristic budget. Certification requires the automatic `-sn/-on/-ref` mode.
|
|
690
718
|
Small enumerated spaces reuse their proof without invoking a solver. Otherwise
|
|
691
719
|
SciPy's `optimize.milp` (SciPy >= 1.9, bundled HiGHS) tests sparse conflict graphs:
|
|
692
|
-
binary x_i selects a site, sum(x_i)
|
|
720
|
+
binary x_i selects a site, maximize sum(x_i), and x_i+x_j<=1 when d_ij<t. Candidate sites
|
|
693
721
|
too close to fixed dopants are disabled; conflicting fixed pairs make t infeasible.
|
|
694
722
|
Binary search over discrete periodic distance levels finds the largest feasible
|
|
695
723
|
threshold. A validated configuration plus proof that the next level is infeasible
|
|
@@ -700,7 +728,21 @@ Conflicts use strict d<t; returned configurations must satisfy d>=t with no dist
|
|
|
700
728
|
relaxation. Binary variables are checked within 1e-6 of 0 or 1. This conservative
|
|
701
729
|
policy may require extra solves for nearly identical distances. Proofs refer to
|
|
702
730
|
the computed geometry subject to HiGHS numerical tolerances, not exact arithmetic.
|
|
703
|
-
The
|
|
731
|
+
The validated heuristic score excludes already feasible levels. The packing upper
|
|
732
|
+
bound prunes larger levels only when the shortest self-image distance exceeds the
|
|
733
|
+
bound (with conservative numerical slack); thin cells retain the unpruned search.
|
|
734
|
+
Isolated vertices are forced into a maximum independent set. Closed-neighborhood
|
|
735
|
+
domination removes a vertex only when it can be replaced without reducing the
|
|
736
|
+
maximum cardinality. Deterministic clique inequalities strengthen sparse models;
|
|
737
|
+
a verified partition into fewer than K cliques, accounting for reductions, proves
|
|
738
|
+
infeasibility. LP dual multipliers are corrected for constraint residuals before
|
|
739
|
+
using their upper bound. Otherwise SciPy MILP maximizes independent-set cardinality.
|
|
740
|
+
Validated incumbents of at least K yield exactly K witness sites; a conservative
|
|
741
|
+
dual bound below K proves infeasibility even at a time limit. An insufficient bound
|
|
742
|
+
at timeout is never a proof. Preprocessing, LP and MILP share one monotonic budget.
|
|
743
|
+
Connected component counts are reported; no crystallographic symmetry is assumed.
|
|
744
|
+
Large graphs can still exhaust the budget. No optional solver is auto-installed,
|
|
745
|
+
and `--n-jobs` controls heuristic restarts, not MILP threads or MIP starts.
|
|
704
746
|
|
|
705
747
|
`optimality-certificate.json` records input, species, site indices, seed, solver
|
|
706
748
|
and SciPy version, distance policy, per-threshold outcomes, runtime, bounds and
|
|
@@ -953,6 +995,19 @@ atoms without stable IDs cannot be identified and must not be supplied.
|
|
|
953
995
|
|
|
954
996
|
For fixed triclinic cells, consistent `unwrapped_position` is preferred; otherwise
|
|
955
997
|
ASE's general lattice minimum-image algorithm accumulates successive displacements.
|
|
998
|
+
For example, `dump_xyz 1000 dump.xyz` followed by `pmk msd -group 0 -ne`
|
|
999
|
+
needs no additional coordinate option. Properties are identified by declaration,
|
|
1000
|
+
including files with extra group or other fields. All atoms are reconstructed
|
|
1001
|
+
before whole-system COM correction and group selection. Reconstruction state
|
|
1002
|
+
persists across the 256-frame storage chunks; partial PBC is respected. Cells
|
|
1003
|
+
must remain constant within rtol=1e-10 and atol=1e-8 Angstrom.
|
|
1004
|
+
The maximum reconstructed step is recorded; a step exceeding 40% of the smallest
|
|
1005
|
+
periodic face spacing emits a heuristic sampling warning. It cannot detect all
|
|
1006
|
+
missed crossings, including motion by an entire cell between samples.
|
|
1007
|
+
Provenance records `unwrapped_position` or `reconstructed_from_wrapped_pos`, the
|
|
1008
|
+
`ase-mic-v1` reconstruction version, cell, and PBC. Fingerprint checks remain.
|
|
1009
|
+
Legacy explicit-unwrapped results remain reusable; legacy wrapped results lacking
|
|
1010
|
+
coordinate provenance must be moved aside and recomputed with schema validation.
|
|
956
1011
|
Wrapped output must be frequent enough to resolve each displacement uniquely;
|
|
957
1012
|
multiple unseen boundary crossings cannot be recovered from saved frames.
|
|
958
1013
|
**MSD analysis supports fixed-cell NVT production.** NPT and changing-cell
|
|
@@ -7,7 +7,16 @@ materials design. Install `pymdkit` once and call its tools from anywhere as
|
|
|
7
7
|
Commands expose explicit, documented CLI interfaces designed for reproducible shell,
|
|
8
8
|
HPC, and AI-agent workflows, and each underlying script is still runnable on its own.
|
|
9
9
|
|
|
10
|
-
## 1.7.
|
|
10
|
+
## 1.7.8 release notes
|
|
11
|
+
|
|
12
|
+
Wrapped-only GPUMD trajectories now receive strict schema validation, a sampling
|
|
13
|
+
warning, and versioned coordinate provenance. Explicit unwrapped trajectories
|
|
14
|
+
retain the existing numerical analysis. Exact doping certification now filters
|
|
15
|
+
distance levels with applicable packing bounds and strengthens the graph model
|
|
16
|
+
with safe reductions, verified cliques, and corrected LP dual bounds.
|
|
17
|
+
See `reports/1.7.8/development-report.md` for measured results and limitations.
|
|
18
|
+
|
|
19
|
+
### Previous 1.7.7 improvements
|
|
11
20
|
|
|
12
21
|
- Automatic `pmk dope` uses exact incremental exchange scores and bounded 2D
|
|
13
22
|
work arrays, preserving the three ranking metrics and search budgets.
|
|
@@ -119,7 +128,7 @@ installed.
|
|
|
119
128
|
On a machine with Internet access, run:
|
|
120
129
|
|
|
121
130
|
```bash
|
|
122
|
-
python -m pip download pymdkit==1.7.
|
|
131
|
+
python -m pip download pymdkit==1.7.8 -d pymdkit-offline
|
|
123
132
|
```
|
|
124
133
|
|
|
125
134
|
This downloads `pymdkit` and the dependencies resolved by pip into the
|
|
@@ -127,14 +136,14 @@ This downloads `pymdkit` and the dependencies resolved by pip into the
|
|
|
127
136
|
system. Then, inside the target pymdkit Python or conda environment, run:
|
|
128
137
|
|
|
129
138
|
```bash
|
|
130
|
-
python -m pip install --no-index --find-links=pymdkit-offline pymdkit==1.7.
|
|
139
|
+
python -m pip install --no-index --find-links=pymdkit-offline pymdkit==1.7.8
|
|
131
140
|
```
|
|
132
141
|
|
|
133
142
|
For optional GPU use, prepare the bundle on a networked machine compatible with
|
|
134
143
|
the target HPC platform and Python environment:
|
|
135
144
|
|
|
136
145
|
```bash
|
|
137
|
-
python -m pip download "pymdkit[gpu-cuda12]==1.7.
|
|
146
|
+
python -m pip download "pymdkit[gpu-cuda12]==1.7.8" -d pymdkit-offline
|
|
138
147
|
```
|
|
139
148
|
|
|
140
149
|
Transfer the whole `pymdkit-offline` directory, then install from it on the
|
|
@@ -142,7 +151,7 @@ target system:
|
|
|
142
151
|
|
|
143
152
|
```bash
|
|
144
153
|
python -m pip install --no-index --find-links=pymdkit-offline \
|
|
145
|
-
"pymdkit[gpu-cuda12]==1.7.
|
|
154
|
+
"pymdkit[gpu-cuda12]==1.7.8"
|
|
146
155
|
```
|
|
147
156
|
|
|
148
157
|
This GPU bundle includes the optional `cupy-cuda12x` package. Its wheels must also
|
|
@@ -590,7 +599,26 @@ E-hull mode preserves Materials Project/local-reference handling, cache files,
|
|
|
590
599
|
deterministic ordering, and writes `ehull.txt`. A supplied `-mp-api-key` is
|
|
591
600
|
redacted in `vasp-out.log`. NEP-training mode preserves converged VASP
|
|
592
601
|
structures and extxyz energy/force/stress metadata; its default output is
|
|
593
|
-
`train.xyz
|
|
602
|
+
`train.xyz`. When available, Born effective charge (BEC) tensors are automatically
|
|
603
|
+
included as the per-atom extxyz property `bec:R:9`, after forces. BEC extraction
|
|
604
|
+
independently follows `vaspout.h5 > vasprun.xml > OUTCAR`, so its source may differ
|
|
605
|
+
from the structure/energy source. PMK uses py4vasp's `charge_tensors` and the
|
|
606
|
+
existing quantity-reader fallback; pymatgen versions without Vasprun BEC support
|
|
607
|
+
continue to OUTCAR. OUTCAR extraction checks complete blocks and uses the final
|
|
608
|
+
complete block if several occur.
|
|
609
|
+
|
|
610
|
+
Each `(n_atoms, 3, 3)` tensor collection is validated for atom count, shape and
|
|
611
|
+
finite values, then flattened in printed OUTCAR row order (`xx xy xz yx yy yz zx
|
|
612
|
+
zy zz`), without transposition, atom reordering or unit conversion (units of
|
|
613
|
+
elementary charge, `|e|`). Available py4vasp structure metadata is checked against
|
|
614
|
+
the final structure. Output files in one calculation directory must describe the
|
|
615
|
+
same atomic ordering. Missing or invalid BEC leaves the configuration intact,
|
|
616
|
+
with a diagnostic and no placeholder values. Mixed datasets retain independent
|
|
617
|
+
per-frame property declarations, and the summary counts frames with/without BEC.
|
|
618
|
+
`-position-only` skips BEC extraction and omits BEC together with other calculation
|
|
619
|
+
results. No additional CLI option is needed.
|
|
620
|
+
|
|
621
|
+
Final-structure
|
|
594
622
|
mode defaults to `CONTCAR`, requires an output folder, and optionally applies
|
|
595
623
|
the strict `-max-ehull` filter using `ehull.txt` by default. All modes use
|
|
596
624
|
`vasp-out.log`, separate from scientific artifacts. The standalone `ehull` and
|
|
@@ -659,7 +687,7 @@ Its default is 120 seconds for the entire certification stage; it does not chang
|
|
|
659
687
|
the heuristic budget. Certification requires the automatic `-sn/-on/-ref` mode.
|
|
660
688
|
Small enumerated spaces reuse their proof without invoking a solver. Otherwise
|
|
661
689
|
SciPy's `optimize.milp` (SciPy >= 1.9, bundled HiGHS) tests sparse conflict graphs:
|
|
662
|
-
binary x_i selects a site, sum(x_i)
|
|
690
|
+
binary x_i selects a site, maximize sum(x_i), and x_i+x_j<=1 when d_ij<t. Candidate sites
|
|
663
691
|
too close to fixed dopants are disabled; conflicting fixed pairs make t infeasible.
|
|
664
692
|
Binary search over discrete periodic distance levels finds the largest feasible
|
|
665
693
|
threshold. A validated configuration plus proof that the next level is infeasible
|
|
@@ -670,7 +698,21 @@ Conflicts use strict d<t; returned configurations must satisfy d>=t with no dist
|
|
|
670
698
|
relaxation. Binary variables are checked within 1e-6 of 0 or 1. This conservative
|
|
671
699
|
policy may require extra solves for nearly identical distances. Proofs refer to
|
|
672
700
|
the computed geometry subject to HiGHS numerical tolerances, not exact arithmetic.
|
|
673
|
-
The
|
|
701
|
+
The validated heuristic score excludes already feasible levels. The packing upper
|
|
702
|
+
bound prunes larger levels only when the shortest self-image distance exceeds the
|
|
703
|
+
bound (with conservative numerical slack); thin cells retain the unpruned search.
|
|
704
|
+
Isolated vertices are forced into a maximum independent set. Closed-neighborhood
|
|
705
|
+
domination removes a vertex only when it can be replaced without reducing the
|
|
706
|
+
maximum cardinality. Deterministic clique inequalities strengthen sparse models;
|
|
707
|
+
a verified partition into fewer than K cliques, accounting for reductions, proves
|
|
708
|
+
infeasibility. LP dual multipliers are corrected for constraint residuals before
|
|
709
|
+
using their upper bound. Otherwise SciPy MILP maximizes independent-set cardinality.
|
|
710
|
+
Validated incumbents of at least K yield exactly K witness sites; a conservative
|
|
711
|
+
dual bound below K proves infeasibility even at a time limit. An insufficient bound
|
|
712
|
+
at timeout is never a proof. Preprocessing, LP and MILP share one monotonic budget.
|
|
713
|
+
Connected component counts are reported; no crystallographic symmetry is assumed.
|
|
714
|
+
Large graphs can still exhaust the budget. No optional solver is auto-installed,
|
|
715
|
+
and `--n-jobs` controls heuristic restarts, not MILP threads or MIP starts.
|
|
674
716
|
|
|
675
717
|
`optimality-certificate.json` records input, species, site indices, seed, solver
|
|
676
718
|
and SciPy version, distance policy, per-threshold outcomes, runtime, bounds and
|
|
@@ -923,6 +965,19 @@ atoms without stable IDs cannot be identified and must not be supplied.
|
|
|
923
965
|
|
|
924
966
|
For fixed triclinic cells, consistent `unwrapped_position` is preferred; otherwise
|
|
925
967
|
ASE's general lattice minimum-image algorithm accumulates successive displacements.
|
|
968
|
+
For example, `dump_xyz 1000 dump.xyz` followed by `pmk msd -group 0 -ne`
|
|
969
|
+
needs no additional coordinate option. Properties are identified by declaration,
|
|
970
|
+
including files with extra group or other fields. All atoms are reconstructed
|
|
971
|
+
before whole-system COM correction and group selection. Reconstruction state
|
|
972
|
+
persists across the 256-frame storage chunks; partial PBC is respected. Cells
|
|
973
|
+
must remain constant within rtol=1e-10 and atol=1e-8 Angstrom.
|
|
974
|
+
The maximum reconstructed step is recorded; a step exceeding 40% of the smallest
|
|
975
|
+
periodic face spacing emits a heuristic sampling warning. It cannot detect all
|
|
976
|
+
missed crossings, including motion by an entire cell between samples.
|
|
977
|
+
Provenance records `unwrapped_position` or `reconstructed_from_wrapped_pos`, the
|
|
978
|
+
`ase-mic-v1` reconstruction version, cell, and PBC. Fingerprint checks remain.
|
|
979
|
+
Legacy explicit-unwrapped results remain reusable; legacy wrapped results lacking
|
|
980
|
+
coordinate provenance must be moved aside and recomputed with schema validation.
|
|
926
981
|
Wrapped output must be frequent enough to resolve each displacement uniquely;
|
|
927
982
|
multiple unseen boundary crossings cannot be recovered from saved frames.
|
|
928
983
|
**MSD analysis supports fixed-cell NVT production.** NPT and changing-cell
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "pymdkit"
|
|
7
|
-
version = "1.7.
|
|
7
|
+
version = "1.7.8"
|
|
8
8
|
description = "A Python command-line toolkit for high-throughput atomistic workflows in AI-driven materials design."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.9"
|
|
@@ -17,7 +17,11 @@ except ImportError: # direct command script
|
|
|
17
17
|
from _dope_optimize import scores
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
def certify_sites(matrix, eligible_count, count, initial, time_limit=120, *, enumerated=False
|
|
20
|
+
def certify_sites(matrix, eligible_count, count, initial, time_limit=120, *, enumerated=False,
|
|
21
|
+
packing_upper=None, graph_preprocessing=False):
|
|
22
|
+
if graph_preprocessing and not enumerated:
|
|
23
|
+
from ._dope_exact import certify_graph
|
|
24
|
+
return certify_graph(matrix, eligible_count, count, initial, time_limit, packing_upper)
|
|
21
25
|
if not np.isfinite(time_limit) or time_limit <= 0:
|
|
22
26
|
raise ValueError("certification time limit must be finite and positive")
|
|
23
27
|
started = time.monotonic()
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
"""Bounded discrete max-min search with exact graph preprocessing."""
|
|
2
|
+
import time
|
|
3
|
+
import numpy as np
|
|
4
|
+
from ._dope_optimize import scores
|
|
5
|
+
from ._dope_graph import threshold_model, lp_bound
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def certify_graph(matrix, n, count, initial, time_limit, packing_upper=None):
|
|
9
|
+
if not np.isfinite(time_limit) or time_limit <= 0:
|
|
10
|
+
raise ValueError('certification time limit must be finite and positive')
|
|
11
|
+
started = time.monotonic()
|
|
12
|
+
deadline = started+time_limit
|
|
13
|
+
matrix = np.minimum(matrix, matrix.T)
|
|
14
|
+
best = tuple(sorted(initial))
|
|
15
|
+
if len(best) != count or len(set(best)) != count or any(i < 0 or i >= n for i in best):
|
|
16
|
+
raise ValueError('invalid initial certification configuration')
|
|
17
|
+
anchors = list(range(n, len(matrix)))
|
|
18
|
+
heuristic = best_distance = float(scores(matrix, [list(best)+anchors])[0, 0])
|
|
19
|
+
pairs = matrix[np.triu_indices(len(matrix), 1)]
|
|
20
|
+
if not np.isfinite(pairs).all() or np.any(pairs < 0):
|
|
21
|
+
raise ValueError('invalid periodic distance matrix')
|
|
22
|
+
levels = np.unique(pairs)
|
|
23
|
+
total_levels = len(levels)
|
|
24
|
+
if packing_upper is not None:
|
|
25
|
+
if not np.isfinite(packing_upper) or packing_upper < heuristic:
|
|
26
|
+
raise ValueError('packing bound contradicts validated feasible witness')
|
|
27
|
+
levels = levels[levels <= packing_upper]
|
|
28
|
+
levels = levels[levels > heuristic]
|
|
29
|
+
level_seconds = time.monotonic()-started
|
|
30
|
+
low, high = -1, len(levels)
|
|
31
|
+
checks, additions = [], []
|
|
32
|
+
complete, reason = False, 'discrete search complete'
|
|
33
|
+
solver_seconds = preprocessing_seconds = model_seconds = 0.
|
|
34
|
+
milp_best = None
|
|
35
|
+
import scipy
|
|
36
|
+
from scipy.optimize import Bounds, LinearConstraint, milp
|
|
37
|
+
ii, jj = np.triu_indices(n, 1)
|
|
38
|
+
distances = matrix[ii, jj]
|
|
39
|
+
while low+1 < high:
|
|
40
|
+
if time.monotonic() >= deadline:
|
|
41
|
+
reason = 'global certification time limit reached'
|
|
42
|
+
break
|
|
43
|
+
middle = (low+high)//2
|
|
44
|
+
threshold = float(levels[middle])
|
|
45
|
+
check = dict(threshold=threshold, solver_called=False, status=None)
|
|
46
|
+
checks.append(check)
|
|
47
|
+
if np.any(matrix[n:, n:] < threshold):
|
|
48
|
+
check.update(status=2, message='fixed-site constraints prove infeasibility')
|
|
49
|
+
high = middle
|
|
50
|
+
continue
|
|
51
|
+
allowed = np.all(matrix[:n, n:] >= threshold, axis=1)
|
|
52
|
+
if allowed.sum() < count:
|
|
53
|
+
check.update(status=2, message='fixed-site constraints prove infeasibility')
|
|
54
|
+
high = middle
|
|
55
|
+
continue
|
|
56
|
+
stage = time.monotonic()
|
|
57
|
+
edges = distances < threshold
|
|
58
|
+
left, right = ii[edges], jj[edges]
|
|
59
|
+
check['graph_seconds'] = time.monotonic()-stage
|
|
60
|
+
try:
|
|
61
|
+
graph, vertices, forced, info = threshold_model(n, left, right, allowed, deadline)
|
|
62
|
+
except TimeoutError as exc:
|
|
63
|
+
reason = str(exc)
|
|
64
|
+
check['message'] = reason
|
|
65
|
+
break
|
|
66
|
+
check.update(info)
|
|
67
|
+
preprocessing_seconds += info['preprocessing_seconds']
|
|
68
|
+
if info['clique_cover_upper_bound'] < count:
|
|
69
|
+
check.update(status=2, message='verified clique partition and exact reductions prove infeasibility')
|
|
70
|
+
high = middle
|
|
71
|
+
continue
|
|
72
|
+
selected = forced[:count] if len(forced) >= count else None
|
|
73
|
+
if selected is None:
|
|
74
|
+
remaining = deadline-time.monotonic()
|
|
75
|
+
if remaining <= 0:
|
|
76
|
+
reason = 'global certification time limit reached'
|
|
77
|
+
break
|
|
78
|
+
stage = time.monotonic()
|
|
79
|
+
try:
|
|
80
|
+
bound = lp_bound(graph, remaining)
|
|
81
|
+
except Exception as exc:
|
|
82
|
+
reason = 'LP solver failure: '+str(exc)
|
|
83
|
+
check.update(status=4, message=reason)
|
|
84
|
+
break
|
|
85
|
+
check['lp_seconds'] = time.monotonic()-stage
|
|
86
|
+
solver_seconds += check['lp_seconds']
|
|
87
|
+
check['lp_upper_bound'] = None if bound is None else bound+len(forced)
|
|
88
|
+
if bound is not None and bound+len(forced) < count-1e-6:
|
|
89
|
+
check.update(status=2, message='residual-corrected LP dual upper bound excludes target')
|
|
90
|
+
high = middle
|
|
91
|
+
continue
|
|
92
|
+
stage = time.monotonic()
|
|
93
|
+
constraints = LinearConstraint(graph, np.full(graph.shape[0], -np.inf), np.ones(graph.shape[0]))
|
|
94
|
+
model_seconds += time.monotonic()-stage
|
|
95
|
+
remaining = deadline-time.monotonic()
|
|
96
|
+
if remaining <= 0:
|
|
97
|
+
reason = 'global certification time limit reached'
|
|
98
|
+
break
|
|
99
|
+
stage = time.monotonic()
|
|
100
|
+
try:
|
|
101
|
+
# A short first solve lets us consume a sufficient dual bound
|
|
102
|
+
# without waiting for the (unneeded) full MIS optimum. SciPy has
|
|
103
|
+
# no callback/MIP-start API. Retry with the remaining budget only
|
|
104
|
+
# if the first result cannot settle the target cardinality.
|
|
105
|
+
calls = 0
|
|
106
|
+
result = None
|
|
107
|
+
for budget in (min(2., remaining), remaining):
|
|
108
|
+
budget = min(budget, deadline-time.monotonic())
|
|
109
|
+
if budget <= 0:
|
|
110
|
+
break
|
|
111
|
+
result = milp(-np.ones(len(vertices)), integrality=np.ones(len(vertices)),
|
|
112
|
+
bounds=Bounds(0, 1), constraints=constraints,
|
|
113
|
+
options=dict(time_limit=budget, presolve=True, mip_rel_gap=0.))
|
|
114
|
+
calls += 1
|
|
115
|
+
dual = getattr(result, 'mip_dual_bound', None)
|
|
116
|
+
x = getattr(result, 'x', None)
|
|
117
|
+
if x is not None:
|
|
118
|
+
x = np.asarray(x)
|
|
119
|
+
if (x.shape != (len(vertices),) or not np.isfinite(x).all()
|
|
120
|
+
or np.any(np.minimum(abs(x), abs(x-1)) > 1e-6)):
|
|
121
|
+
raise ValueError('invalid nonbinary MILP incumbent')
|
|
122
|
+
trial = forced+[vertices[i] for i in np.flatnonzero(x > .5)]
|
|
123
|
+
if ((len(trial) > 1 and np.min(matrix[np.ix_(trial, trial)]) < threshold)
|
|
124
|
+
or not allowed[trial].all()):
|
|
125
|
+
raise ValueError('MILP incumbent violates periodic distance threshold')
|
|
126
|
+
if (result.status != 1 or (dual is not None and np.isfinite(dual)
|
|
127
|
+
and -dual+len(forced) < count-1e-6)
|
|
128
|
+
or (x is not None and np.count_nonzero(np.asarray(x) > .5)+len(forced) >= count)):
|
|
129
|
+
break
|
|
130
|
+
check['milp_calls'] = calls
|
|
131
|
+
if result is None:
|
|
132
|
+
raise TimeoutError('global certification time limit reached before MILP')
|
|
133
|
+
except ValueError:
|
|
134
|
+
raise
|
|
135
|
+
except Exception as exc:
|
|
136
|
+
reason = 'solver failure: '+str(exc)
|
|
137
|
+
check.update(status=4, solver_called=True, message=reason)
|
|
138
|
+
break
|
|
139
|
+
check['milp_seconds'] = time.monotonic()-stage
|
|
140
|
+
solver_seconds += check['milp_seconds']
|
|
141
|
+
check.update(status=int(result.status), message=str(result.message), solver_called=True)
|
|
142
|
+
for key in ('mip_dual_bound', 'mip_gap', 'mip_node_count'):
|
|
143
|
+
value = getattr(result, key, None)
|
|
144
|
+
check[key] = float(value) if value is not None and np.isfinite(value) else None
|
|
145
|
+
if result.status not in (0, 1):
|
|
146
|
+
reason = 'abnormal maximum-independent-set solver outcome: '+str(result.message)
|
|
147
|
+
break
|
|
148
|
+
x = getattr(result, 'x', None)
|
|
149
|
+
if x is not None:
|
|
150
|
+
x = np.asarray(x)
|
|
151
|
+
if (x.shape != (len(vertices),) or not np.isfinite(x).all()
|
|
152
|
+
or np.any(np.minimum(abs(x), abs(x-1)) > 1e-6)):
|
|
153
|
+
raise ValueError('invalid nonbinary MILP incumbent')
|
|
154
|
+
incumbent = forced+[vertices[i] for i in np.flatnonzero(x > .5)]
|
|
155
|
+
if len(incumbent) > 1 and np.min(matrix[np.ix_(incumbent, incumbent)]) < threshold:
|
|
156
|
+
raise ValueError('MILP incumbent violates periodic distance threshold')
|
|
157
|
+
if not allowed[incumbent].all():
|
|
158
|
+
raise ValueError('MILP incumbent violates fixed-reference constraints')
|
|
159
|
+
check['incumbent_cardinality'] = len(incumbent)
|
|
160
|
+
if len(incumbent) >= count:
|
|
161
|
+
selected = incumbent[:count]
|
|
162
|
+
if selected is None:
|
|
163
|
+
dual = check['mip_dual_bound']
|
|
164
|
+
# min(-sum x) dual is a LOWER bound; negate for cardinality.
|
|
165
|
+
if dual is not None and -dual+len(forced) < count-1e-6:
|
|
166
|
+
check.update(status=2, message='MILP dual bound excludes target cardinality')
|
|
167
|
+
high = middle
|
|
168
|
+
continue
|
|
169
|
+
if result.status == 0 and x is not None:
|
|
170
|
+
check.update(status=2, message='optimal MIS cardinality below target')
|
|
171
|
+
high = middle
|
|
172
|
+
continue
|
|
173
|
+
reason = 'solver limit without sufficient witness or dual bound'
|
|
174
|
+
break
|
|
175
|
+
selected = tuple(sorted(selected))
|
|
176
|
+
distance = float(scores(matrix, [list(selected)+anchors])[0, 0])
|
|
177
|
+
if len(selected) != count or len(set(selected)) != count or distance < threshold:
|
|
178
|
+
raise ValueError('invalid reconstructed certification witness')
|
|
179
|
+
check.update(validated_distance=distance, witness=list(selected), status=0)
|
|
180
|
+
additions.append(selected)
|
|
181
|
+
milp_best = max(milp_best or distance, distance)
|
|
182
|
+
if distance > best_distance:
|
|
183
|
+
best, best_distance = selected, distance
|
|
184
|
+
low = int(np.searchsorted(levels, best_distance, side='right'))-1
|
|
185
|
+
else:
|
|
186
|
+
complete = True
|
|
187
|
+
upper = float(levels[high]) if high < len(levels) else packing_upper
|
|
188
|
+
if upper is None:
|
|
189
|
+
upper = float(np.max(pairs))
|
|
190
|
+
status = ('CERTIFIED_OPTIMAL' if complete else
|
|
191
|
+
'IMPROVED_NOT_CERTIFIED' if best_distance > heuristic else 'NOT_CERTIFIED')
|
|
192
|
+
return additions, dict(status=status, method='maximum-independent-set', eligible_sites=n,
|
|
193
|
+
selected_sites=count, fixed_sites=len(anchors), heuristic_best=heuristic,
|
|
194
|
+
best_found=best_distance, milp_best=milp_best, certified_optimum=best_distance if complete else None,
|
|
195
|
+
certified_lower_bound=best_distance, certified_upper_bound=best_distance if complete else upper,
|
|
196
|
+
packing_upper_bound=packing_upper, candidate_levels=total_levels, filtered_candidate_levels=len(levels),
|
|
197
|
+
time_limit=time_limit, runtime=time.monotonic()-started, distance_level_seconds=level_seconds,
|
|
198
|
+
preprocessing_seconds=preprocessing_seconds, solver_seconds=solver_seconds, model_seconds=model_seconds,
|
|
199
|
+
lp_seconds=sum(c.get('lp_seconds', 0.) for c in checks),
|
|
200
|
+
milp_seconds=sum(c.get('milp_seconds', 0.) for c in checks),
|
|
201
|
+
feasibility_checks=sum(c.get('milp_calls', int(c['solver_called'])) for c in checks),
|
|
202
|
+
proven_feasible_thresholds=sum('validated_distance' in c for c in checks),
|
|
203
|
+
proven_infeasible_thresholds=sum(c['status'] == 2 for c in checks),
|
|
204
|
+
last_proven_feasible_threshold=best_distance,
|
|
205
|
+
first_proven_infeasible_threshold=float(levels[high]) if high < len(levels) else None,
|
|
206
|
+
distance_tolerance=0., binary_tolerance=1e-6,
|
|
207
|
+
distance_policy='all distinct float64 levels; strict conflicts; no distance relaxation',
|
|
208
|
+
solver='SciPy MILP (bundled HiGHS)', scipy_version=scipy.__version__,
|
|
209
|
+
termination=reason, checks=checks, best_local_indices=list(best))
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"""Exact graph reductions and independently checked clique/LP bounds."""
|
|
2
|
+
import time
|
|
3
|
+
import numpy as np
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def preprocess(n, left, right, allowed, deadline):
|
|
7
|
+
adjacency = [set() for _ in range(n)]
|
|
8
|
+
for u, v in zip(left, right):
|
|
9
|
+
if allowed[u] and allowed[v]:
|
|
10
|
+
adjacency[u].add(int(v))
|
|
11
|
+
adjacency[v].add(int(u))
|
|
12
|
+
active = set(np.flatnonzero(allowed).tolist())
|
|
13
|
+
forced, dominated = [], []
|
|
14
|
+
# If N[u] subset N[v] (closed neighborhoods), an independent set
|
|
15
|
+
# containing v may replace it by u. Remove v, preserving alpha exactly.
|
|
16
|
+
changed = True
|
|
17
|
+
while changed:
|
|
18
|
+
changed = False
|
|
19
|
+
for u in sorted(active):
|
|
20
|
+
if time.monotonic() >= deadline:
|
|
21
|
+
raise TimeoutError('global certification time limit reached in graph reductions')
|
|
22
|
+
if u not in active:
|
|
23
|
+
continue
|
|
24
|
+
neighbors = adjacency[u] & active
|
|
25
|
+
if not neighbors:
|
|
26
|
+
active.remove(u)
|
|
27
|
+
forced.append(u)
|
|
28
|
+
changed = True
|
|
29
|
+
continue
|
|
30
|
+
closed = neighbors | {u}
|
|
31
|
+
for v in sorted(neighbors):
|
|
32
|
+
if closed <= (adjacency[v] & active) | {v}:
|
|
33
|
+
active.remove(v)
|
|
34
|
+
dominated.append(v)
|
|
35
|
+
changed = True
|
|
36
|
+
vertices = sorted(active)
|
|
37
|
+
remaining = set(vertices)
|
|
38
|
+
partition = []
|
|
39
|
+
while remaining:
|
|
40
|
+
if time.monotonic() >= deadline:
|
|
41
|
+
raise TimeoutError('global certification time limit reached in clique cover')
|
|
42
|
+
candidates = remaining.copy()
|
|
43
|
+
clique = []
|
|
44
|
+
while candidates:
|
|
45
|
+
v = max(candidates, key=lambda x: (len(adjacency[x] & candidates), -x))
|
|
46
|
+
clique.append(v)
|
|
47
|
+
candidates &= adjacency[v]
|
|
48
|
+
partition.append(sorted(clique))
|
|
49
|
+
remaining.difference_update(clique)
|
|
50
|
+
# One maximal greedy clique per vertex, bounded and deterministic.
|
|
51
|
+
cliques = {tuple(c) for c in partition if len(c) > 2}
|
|
52
|
+
for u in vertices:
|
|
53
|
+
if time.monotonic() >= deadline:
|
|
54
|
+
raise TimeoutError('global certification time limit reached in clique generation')
|
|
55
|
+
clique, candidates = [u], adjacency[u] & active
|
|
56
|
+
while candidates:
|
|
57
|
+
v = max(candidates, key=lambda x: (len(adjacency[x] & candidates), -x))
|
|
58
|
+
clique.append(v)
|
|
59
|
+
candidates &= adjacency[v]
|
|
60
|
+
if len(clique) > 2:
|
|
61
|
+
cliques.add(tuple(sorted(clique)))
|
|
62
|
+
# Sparse crystallographic graphs often have modest maximal-clique counts.
|
|
63
|
+
# Bounded Bron--Kerbosch adds overlapping cliques missed by one greedy
|
|
64
|
+
# choice. Hitting the cap weakens the bound only; it never changes validity.
|
|
65
|
+
stack = [((), set(vertices), set())]
|
|
66
|
+
cap = max(1000, 8*len(vertices))
|
|
67
|
+
while stack and len(cliques) < cap:
|
|
68
|
+
if time.monotonic() >= deadline:
|
|
69
|
+
raise TimeoutError('global certification time limit reached in maximal cliques')
|
|
70
|
+
clique, possible, excluded = stack.pop()
|
|
71
|
+
if not possible and not excluded:
|
|
72
|
+
if len(clique) > 2:
|
|
73
|
+
cliques.add(tuple(sorted(clique)))
|
|
74
|
+
continue
|
|
75
|
+
pivot = max(possible | excluded, key=lambda v: (len(possible & adjacency[v]), -v))
|
|
76
|
+
for v in sorted(possible-adjacency[pivot]):
|
|
77
|
+
stack.append((clique+(v,), possible & adjacency[v], excluded & adjacency[v]))
|
|
78
|
+
possible.remove(v)
|
|
79
|
+
excluded.add(v)
|
|
80
|
+
# Verify the proof objects before using them.
|
|
81
|
+
if sorted(v for c in partition for v in c) != vertices:
|
|
82
|
+
raise ValueError('invalid clique partition coverage')
|
|
83
|
+
for clique in list(cliques) + partition:
|
|
84
|
+
if not all(v in adjacency[u] for i, u in enumerate(clique) for v in clique[i+1:]):
|
|
85
|
+
raise ValueError('invalid generated clique')
|
|
86
|
+
return vertices, forced, dominated, partition, sorted(cliques)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def threshold_model(n, left, right, allowed, deadline):
|
|
90
|
+
from scipy import sparse
|
|
91
|
+
from scipy.sparse.csgraph import connected_components
|
|
92
|
+
start = time.monotonic()
|
|
93
|
+
vertices, forced, dominated, partition, cliques = preprocess(n, left, right, allowed, deadline)
|
|
94
|
+
mapping = {v: i for i, v in enumerate(vertices)}
|
|
95
|
+
constraints = [(mapping[int(u)], mapping[int(v)]) for u, v in zip(left, right)
|
|
96
|
+
if u in mapping and v in mapping]
|
|
97
|
+
constraints += [tuple(mapping[v] for v in c) for c in cliques]
|
|
98
|
+
rows = [i for i, c in enumerate(constraints) for _ in c]
|
|
99
|
+
cols = [v for c in constraints for v in c]
|
|
100
|
+
graph = sparse.coo_matrix((np.ones(len(rows)), (rows, cols)),
|
|
101
|
+
shape=(len(constraints), len(vertices))).tocsc()
|
|
102
|
+
degree = np.bincount(np.r_[left, right], minlength=n)
|
|
103
|
+
adjacency = sparse.coo_matrix((np.ones(2*len(left)), (np.r_[left, right], np.r_[right, left])), shape=(n, n))
|
|
104
|
+
info = dict(vertices=n, edges=len(left), density=2*len(left)/max(1, n*(n-1)),
|
|
105
|
+
min_degree=int(degree.min()), max_degree=int(degree.max()), mean_degree=float(degree.mean()),
|
|
106
|
+
components=int(connected_components(adjacency, directed=False, return_labels=False)),
|
|
107
|
+
removed_vertices=n-len(vertices), forced_vertices=forced, dominated_vertices=dominated,
|
|
108
|
+
disabled_vertices=np.flatnonzero(~allowed).tolist(),
|
|
109
|
+
clique_constraints=len(cliques), clique_partition=partition,
|
|
110
|
+
clique_cover_upper_bound=len(forced)+len(partition),
|
|
111
|
+
preprocessing_seconds=time.monotonic()-start)
|
|
112
|
+
return graph, vertices, forced, info
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def lp_bound(graph, remaining):
|
|
116
|
+
"""Dual feasible upper bound with explicit correction for residuals.
|
|
117
|
+
|
|
118
|
+
Any y>=0 gives alpha <= sum(y)+sum(max(0,1-A.T@y)), since 0<=x<=1.
|
|
119
|
+
Thus approximate LP multipliers cannot create a false bound through small
|
|
120
|
+
dual infeasibilities. A conservative floating point margin is added.
|
|
121
|
+
"""
|
|
122
|
+
from scipy.optimize import linprog
|
|
123
|
+
result = linprog(-np.ones(graph.shape[1]), A_ub=graph,
|
|
124
|
+
b_ub=np.ones(graph.shape[0]), bounds=(0, 1), method='highs',
|
|
125
|
+
options=dict(time_limit=remaining))
|
|
126
|
+
if result.status != 0:
|
|
127
|
+
return None
|
|
128
|
+
y = np.maximum(0., -result.ineqlin.marginals)
|
|
129
|
+
if not np.isfinite(y).all():
|
|
130
|
+
return None
|
|
131
|
+
residual = np.maximum(0., 1-graph.T@y)
|
|
132
|
+
return float(y.sum()+residual.sum()+1e-7*(1+y.sum()+graph.shape[1]))
|