File: pymatgen.optimization.html

package info (click to toggle)
pymatgen 2025.2.18%2Bdfsg1-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 85,888 kB
  • sloc: python: 176,173; javascript: 780; makefile: 221; sh: 78
file content (202 lines) | stat: -rw-r--r-- 12,766 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202


<!DOCTYPE html>
<html class="writer-html5" lang="en" data-content_root="./">
<head>
  <meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />

  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>pymatgen.optimization package &mdash; pymatgen 2025.1.24 documentation</title>
      <link rel="stylesheet" type="text/css" href="assets/pygments.css?v=fa44fd50" />
      <link rel="stylesheet" type="text/css" href="assets/css/theme.css?v=e59714d7" />
      <link rel="stylesheet" type="text/css" href="assets/css/custom.css" />

  
    <link rel="canonical" href="https://pymatgen.orgpymatgen.optimization.html"/>
      <script src="assets/jquery.js?v=5d32c60e"></script>
      <script src="assets/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
      <script src="assets/documentation_options.js?v=d2bc030c"></script>
      <script src="assets/doctools.js?v=9bcbadda"></script>
      <script src="assets/sphinx_highlight.js?v=dc90522c"></script>
    <script src="assets/js/theme.js"></script>
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" /> 
</head>

<body class="wy-body-for-nav"> 
  <div class="wy-grid-for-nav">
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search"  style="background: linear-gradient(0deg, rgba(23,63,162,1) 0%, rgba(0,70,192,1) 100%)" >

          
          
          <a href="index.html">
            
          </a>
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>
        </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
              <!-- Local TOC -->
              <div class="local-toc"><ul>
<li><a class="reference internal" href="#">pymatgen.optimization package</a><ul>
<li><a class="reference internal" href="#submodules">Submodules</a></li>
<li><a class="reference internal" href="#module-pymatgen.optimization.linear_assignment">pymatgen.optimization.linear_assignment module</a><ul>
<li><a class="reference internal" href="#pymatgen.optimization.linear_assignment.LinearAssignment"><code class="docutils literal notranslate"><span class="pre">LinearAssignment</span></code></a><ul>
<li><a class="reference internal" href="#pymatgen.optimization.linear_assignment.LinearAssignment.min_cost"><code class="docutils literal notranslate"><span class="pre">LinearAssignment.min_cost</span></code></a></li>
<li><a class="reference internal" href="#pymatgen.optimization.linear_assignment.LinearAssignment.solution"><code class="docutils literal notranslate"><span class="pre">LinearAssignment.solution</span></code></a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference internal" href="#module-pymatgen.optimization.neighbors">pymatgen.optimization.neighbors module</a><ul>
<li><a class="reference internal" href="#pymatgen.optimization.neighbors.find_points_in_spheres"><code class="docutils literal notranslate"><span class="pre">find_points_in_spheres()</span></code></a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu"  style="background: linear-gradient(0deg, rgba(23,63,162,1) 0%, rgba(0,70,192,1) 100%)" >
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="index.html">pymatgen</a>
      </nav>

      <div class="wy-nav-content">
        <div class="rst-content style-external-links">
          <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="index.html" class="icon icon-home" aria-label="Home"></a></li>
      <li class="breadcrumb-item active">pymatgen.optimization package</li>
      <li class="wy-breadcrumbs-aside">
              <a href="https://github.com/materialsproject/pymatgen/blob/master/docs_rst/pymatgen.optimization.rst" class="fa fa-github"> Edit on GitHub</a>
      </li>
  </ul>
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
             
  <section id="module-pymatgen.optimization">
<span id="pymatgen-optimization-package"></span><h1>pymatgen.optimization package<a class="headerlink" href="#module-pymatgen.optimization" title="Link to this heading"></a></h1>
<p>Optimization utilities.</p>
<section id="submodules">
<h2>Submodules<a class="headerlink" href="#submodules" title="Link to this heading"></a></h2>
</section>
<section id="module-pymatgen.optimization.linear_assignment">
<span id="pymatgen-optimization-linear-assignment-module"></span><h2>pymatgen.optimization.linear_assignment module<a class="headerlink" href="#module-pymatgen.optimization.linear_assignment" title="Link to this heading"></a></h2>
<p>This module contains the LAPJV algorithm to solve the Linear Assignment Problem.</p>
<dl class="py class">
<dt class="sig sig-object py" id="pymatgen.optimization.linear_assignment.LinearAssignment">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">LinearAssignment</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">costs</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">np.ndarray</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">epsilon</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">float</span></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">1e-13</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/materialsproject/pymatgen/blob/v2025.1.24/src/pymatgen/optimization/linear_assignment.py"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pymatgen.optimization.linear_assignment.LinearAssignment" title="Link to this definition"></a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
<p>This class finds the solution to the Linear Assignment Problem.
It finds a minimum cost matching between two sets, given a cost
matrix.</p>
<p>This class is an implementation of the LAPJV algorithm described in:
R. Jonker, A. Volgenant. A Shortest Augmenting Path Algorithm for
Dense and Sparse Linear Assignment Problems. Computing 38, 325-340
(1987)</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>costs</strong> – The cost matrix of the problem. cost[i,j] should be the
cost of matching x[i] to y[j]. The cost matrix may be
rectangular</p></li>
<li><p><strong>epsilon</strong> – Tolerance for determining if solution vector is &lt; 0</p></li>
</ul>
</dd>
</dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="pymatgen.optimization.linear_assignment.LinearAssignment.min_cost">
<span class="sig-name descname"><span class="pre">min_cost</span></span><a class="reference external" href="https://github.com/materialsproject/pymatgen/blob/v2025.1.24/src/pymatgen/optimization/linear_assignment.py"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pymatgen.optimization.linear_assignment.LinearAssignment.min_cost" title="Link to this definition"></a></dt>
<dd><p>The minimum cost of the matching.</p>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="pymatgen.optimization.linear_assignment.LinearAssignment.solution">
<span class="sig-name descname"><span class="pre">solution</span></span><a class="reference external" href="https://github.com/materialsproject/pymatgen/blob/v2025.1.24/src/pymatgen/optimization/linear_assignment.py"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pymatgen.optimization.linear_assignment.LinearAssignment.solution" title="Link to this definition"></a></dt>
<dd><p>The matching of the rows to columns. i.e solution = [1, 2, 0]
would match row 0 to column 1, row 1 to column 2 and row 2
to column 0. Total cost would be c[0, 1] + c[1, 2] + c[2, 0].</p>
</dd></dl>

</dd></dl>

</section>
<section id="module-pymatgen.optimization.neighbors">
<span id="pymatgen-optimization-neighbors-module"></span><h2>pymatgen.optimization.neighbors module<a class="headerlink" href="#module-pymatgen.optimization.neighbors" title="Link to this heading"></a></h2>
<dl class="py function">
<dt class="sig sig-object py" id="pymatgen.optimization.neighbors.find_points_in_spheres">
<span class="sig-name descname"><span class="pre">find_points_in_spheres</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">all_coords</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">center_coords</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">r</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">pbc</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">lattice</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tol</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1e-08</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">min_r</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1.0</span></span></em><span class="sig-paren">)</span><a class="reference external" href="https://github.com/materialsproject/pymatgen/blob/v2025.1.24/src/pymatgen/optimization/neighbors.py"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#pymatgen.optimization.neighbors.find_points_in_spheres" title="Link to this definition"></a></dt>
<dd><p>For each point in <cite>center_coords</cite>, get all the neighboring points in <cite>all_coords</cite>
that are within the cutoff radius <cite>r</cite>. All the coordinates should be Cartesian.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>all_coords</strong> – (np.ndarray[double, dim=2]) all available points.
When periodic boundary is considered, this is all the points in the lattice.</p></li>
<li><p><strong>center_coords</strong> – (np.ndarray[double, dim=2]) all centering points</p></li>
<li><p><strong>r</strong> – (float) cutoff radius</p></li>
<li><p><strong>pbc</strong> – (np.ndarray[np.int64_t, dim=1]) whether to set periodic boundaries</p></li>
<li><p><strong>lattice</strong> – (np.ndarray[double, dim=2]) 3x3 lattice matrix</p></li>
<li><p><strong>tol</strong> – (float) numerical tolerance</p></li>
<li><p><strong>min_r</strong> – (float) minimal cutoff to calculate the neighbor list
directly. If the cutoff is less than this value, the algorithm
will calculate neighbor list using min_r as cutoff and discard
those that have larger distances.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>Indexes of center_coords.
index2 (n, ): Indexes of all_coords that form the neighbor pair.
offset_vectors (n, 3): The periodic image offsets for all_coords.
distances (n, ).</p>
</dd>
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p>index1 (n, )</p>
</dd>
</dl>
</dd></dl>

</section>
</section>


           </div>
          </div>
          <footer>

  <hr/>

  <div role="contentinfo">
    <p>&#169; Copyright 2011, Pymatgen Development Team.</p>
  </div>

  Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
    <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
    provided by <a href="https://readthedocs.org">Read the Docs</a>.
   

</footer>
        </div>
      </div>
    </section>
  </div>
  <script>
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script> 

</body>
</html>