-
Notifications
You must be signed in to change notification settings - Fork 0
/
ObtainingABenchmarkForMantidFitting.html
257 lines (206 loc) · 16.2 KB
/
ObtainingABenchmarkForMantidFitting.html
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
<!DOCTYPE html>
<html lang="en" data-content_root="./">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Obtaining a Benchmark for Mantid Fitting</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=fa44fd50" />
<link rel="stylesheet" type="text/css" href="_static/bootstrap-sphinx.css?v=fadd4351" />
<link rel="stylesheet" type="text/css" href="_static/custom.css?v=77160d70" />
<script src="_static/documentation_options.js?v=a8da1a53"></script>
<script src="_static/doctools.js?v=9bcbadda"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Conda Package Manager" href="CondaPackageManager.html" />
<link rel="prev" title="Windows Subsystem for Linux (WSL2)" href="WindowsSubsystemForLinux.html" />
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-59110517-1', 'auto');
ga('send', 'pageview');
</script>
</head><body>
<div id="navbar" class="navbar navbar-default ">
<div class="container">
<div class="navbar-header">
<!-- .btn-navbar is used as the toggle for collapsed navbar content -->
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="http://www.mantidproject.org">
</a>
<span class="navbar-text navbar-version pull-left"><b>main</b></span>
</div>
<div class="collapse navbar-collapse nav-collapse">
<ul class="nav navbar-nav">
<li class="divider-vertical"></li>
<li><a href="index.html">Home</a></li>
<li><a href="https://download.mantidproject.org">Download</a></li>
<li><a href="https://docs.mantidproject.org">User Documentation</a></li>
<li><a href="http://www.mantidproject.org/contact">Contact Us</a></li>
</ul>
<form class="navbar-form navbar-right" action="search.html" method="get">
<div class="form-group">
<input type="text" name="q" class="form-control" placeholder="Search" />
</div>
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<p>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="nav-item nav-item-0"><a href="index.html">Documentation</a> »</li>
<li class="nav-item nav-item-this"><a href="">Obtaining a Benchmark for Mantid Fitting</a></li>
</ul>
</div> </p>
</div>
<div class="container">
<div class="row">
<div class="body col-md-12 content" role="main">
<section id="obtaining-a-benchmark-for-mantid-fitting">
<span id="obtainingabenchmarkformantidfitting"></span><h1>Obtaining a Benchmark for Mantid Fitting<a class="headerlink" href="#obtaining-a-benchmark-for-mantid-fitting" title="Link to this heading">¶</a></h1>
<nav class="contents local" id="contents">
<ul class="simple">
<li><p><a class="reference internal" href="#benchmarking-mantid-from-source" id="id2">Benchmarking Mantid from Source</a></p></li>
<li><p><a class="reference internal" href="#benchmarking-mantid-from-install" id="id3">Benchmarking Mantid from Install</a></p>
<ul>
<li><p><a class="reference internal" href="#initial-setup" id="id4">Initial Setup</a></p></li>
<li><p><a class="reference internal" href="#creating-your-benchmarking-environment" id="id5">Creating your Benchmarking Environment</a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#running-a-benchmark" id="id6">Running a Benchmark</a></p></li>
<li><p><a class="reference internal" href="#tips" id="id7">Tips</a></p></li>
</ul>
</nav>
<p>There are several scenarios in which obtaining a benchmark for the accuracy and runtime of Mantid minimizers might be useful:</p>
<ul class="simple">
<li><p>From the perspective of a <strong>Scientist</strong>, who wants to know the best Mantid minimizer to use for fitting their model to their data.</p></li>
<li><p>From the perspective of a <strong>Software Developer</strong>, who wants to optimize their code to improve its accuracy and runtime.</p></li>
</ul>
<p>This page will explain how to benchmark the accuracy and runtime of different fitting minimizers in Mantid for different fitting problems. To do this, we will use a package called <a class="reference external" href="https://fitbenchmarking.readthedocs.io/en/stable/">FitBenchmarking</a> which is a cross-platform open source tool for comparing different minimizers and fitting frameworks.</p>
<p>Before you continue, make sure you have a recent version of python installed, and access to git bash (which is the recommended terminal to use).</p>
<section id="benchmarking-mantid-from-source">
<h2><a class="toc-backref" href="#id2" role="doc-backlink">Benchmarking Mantid from Source</a><a class="headerlink" href="#benchmarking-mantid-from-source" title="Link to this heading">¶</a></h2>
<p>This section will show you how to benchmark Mantid using a source code directory. This is useful for software developers who want to make quick changes to the code to see how they affect the fit accuracy.</p>
<ol class="arabic simple">
<li><p>Open a git bash terminal and cd to the desired location.</p></li>
<li><p>Activate your mantid conda environment.</p></li>
<li><p>Pip install the FitBenchmarking package by following the <a class="reference external" href="https://fitbenchmarking.readthedocs.io/en/stable/users/install_instructions/fitbenchmarking.html">FitBenchmarking installation instructions</a>.</p></li>
<li><p>Follow the instructions in the <a class="reference internal" href="#running-a-benchmark-ref"><span class="std std-ref">Running a Benchmark</span></a> section below. Note that you <em>must</em> specify the <code class="docutils literal notranslate"><span class="pre">PYTHONPATH</span></code> in the last command, where the <code class="docutils literal notranslate"><span class="pre"><config></span></code> is only required on Windows:</p></li>
</ol>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span><span class="nv">PYTHONPATH</span><span class="o">=</span>/path/to/build/bin/<config><span class="w"> </span>fitbenchmarking<span class="w"> </span>-o<span class="w"> </span>fitting_options.ini<span class="w"> </span>-p<span class="w"> </span>examples/benchmark_problems/Muon
</pre></div>
</div>
</section>
<section id="benchmarking-mantid-from-install">
<h2><a class="toc-backref" href="#id3" role="doc-backlink">Benchmarking Mantid from Install</a><a class="headerlink" href="#benchmarking-mantid-from-install" title="Link to this heading">¶</a></h2>
<p>This section will show you how to benchmark Mantid using an installed version. This is useful when you want a more realistic benchmark for fit runtimes.</p>
<section id="initial-setup">
<h3><a class="toc-backref" href="#id4" role="doc-backlink">Initial Setup</a><a class="headerlink" href="#initial-setup" title="Link to this heading">¶</a></h3>
<ol class="arabic simple">
<li><p>Download and install the desired version of MantidWorkbench from the <a class="reference external" href="https://github.com/mantidproject/mantid/releases">releases page</a>. Note its installation path, hereby denoted as <code class="docutils literal notranslate"><span class="pre">[INSTALL_PATH]</span></code>.</p></li>
<li><p>Open a git bash terminal and cd to the desired location.</p></li>
<li><p>Pip install the virtual environment package as described in the <a class="reference external" href="https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/#installing-virtualenv">‘Installing virtualenv’ section</a>.</p></li>
</ol>
</section>
<section id="creating-your-benchmarking-environment">
<h3><a class="toc-backref" href="#id5" role="doc-backlink">Creating your Benchmarking Environment</a><a class="headerlink" href="#creating-your-benchmarking-environment" title="Link to this heading">¶</a></h3>
<ol class="arabic simple">
<li><p>From the same git bash terminal, run the following command:</p></li>
</ol>
<p>If using Windows:</p>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>py<span class="w"> </span>-m<span class="w"> </span>virtualenv<span class="w"> </span>-p<span class="o">=[</span>INSTALL_PATH<span class="o">]</span><span class="se">\b</span>in<span class="se">\p</span>ython.exe<span class="w"> </span>benchmark-env
</pre></div>
</div>
<p>This will create a virtual environment based on the python executable provided with your Mantid installation. For Windows, the location of this executable is <code class="docutils literal notranslate"><span class="pre">C:\MantidInstall\bin\python.exe</span></code>.</p>
<p>If using Ubuntu:</p>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>virtualenv<span class="w"> </span>--python<span class="o">=</span>python3<span class="w"> </span>benchmark-env
</pre></div>
</div>
<p>In this example, <code class="docutils literal notranslate"><span class="pre">benchmark-env</span></code> is the name given to your virtual environment.</p>
<ol class="arabic simple" start="2">
<li><p>Activate your environment. This is explained in the <a class="reference external" href="https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/#activating-a-virtual-environment">‘Activating a virtual environment’ section</a>.</p></li>
<li><p>It might be necessary to upgrade and install a few packages before installing FitBenchmarking if working from a Linux system:</p></li>
</ol>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>python3<span class="w"> </span>-m<span class="w"> </span>pip<span class="w"> </span>install<span class="w"> </span>--upgrade<span class="w"> </span>pip
python3<span class="w"> </span>-m<span class="w"> </span>pip<span class="w"> </span>install<span class="w"> </span>--upgrade<span class="w"> </span>pillow
sudo<span class="w"> </span>apt-get<span class="w"> </span>install<span class="w"> </span>libglu1-mesa
</pre></div>
</div>
<ol class="arabic simple" start="4">
<li><p>Install the FitBenchmarking package by following the <a class="reference external" href="https://fitbenchmarking.readthedocs.io/en/stable/users/install_instructions/fitbenchmarking.html">FitBenchmarking installation instructions</a>. Note that installing FitBenchmarking from source using the editable flag <code class="docutils literal notranslate"><span class="pre">-e</span></code> proved to be the most stable installation prior to the release of FitBenchmarking v0.2.</p></li>
</ol>
<p>Your environment should now be ready for performing a benchmark of Mantid minimizers.</p>
</section>
</section>
<section id="running-a-benchmark">
<span id="running-a-benchmark-ref"></span><h2><a class="toc-backref" href="#id6" role="doc-backlink">Running a Benchmark</a><a class="headerlink" href="#running-a-benchmark" title="Link to this heading">¶</a></h2>
<p>The process for how to run a benchmark is explained extensively in the <a class="reference external" href="https://fitbenchmarking.readthedocs.io/en/stable/users/index.html">FitBenchmarking documentation</a>, and so I recommend you give it a read. This section will give a basic example of how to perform a simple benchmark of three Mantid minimizers.</p>
<ol class="arabic simple">
<li><p>Create a file called <code class="docutils literal notranslate"><span class="pre">fitting_options.ini</span></code> with the following contents</p></li>
</ol>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>[FITTING]
software: mantid
num_runs: 1
[MINIMIZERS]
mantid: Levenberg-Marquardt
Levenberg-MarquardtMD
Simplex
[PLOTTING]
make_plots: yes
[LOGGING]
external_output: log_only
</pre></div>
</div>
<ol class="arabic simple" start="2">
<li><p>Download the examples folder from the <a class="reference external" href="https://github.com/fitbenchmarking/fitbenchmarking">FitBenchmarking github repo</a> by git cloning the repository. Alternatively, you can define your own fitting problems.</p></li>
<li><p>From your activated virtual environment, run the following command. This will run the Muon fitting problems assuming you have the same directory structure as seen on the Fitbenchmarking repo.</p></li>
</ol>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>fitbenchmarking<span class="w"> </span>-o<span class="w"> </span>fitting_options.ini<span class="w"> </span>-p<span class="w"> </span>examples/benchmark_problems/Muon
</pre></div>
</div>
<p>If benchmarking from source, you must also specify the <code class="docutils literal notranslate"><span class="pre">PYTHONPATH</span></code>. The <code class="docutils literal notranslate"><span class="pre">PYTHONPATH</span></code> needs to point to your build/bin/<config> folder where the <code class="docutils literal notranslate"><span class="pre"><config></span></code> is only required on Windows and should be replaced by the config of your build e.g. build/bin/Release.</p>
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span><span class="nv">PYTHONPATH</span><span class="o">=</span>/path/to/build/bin/<config><span class="w"> </span>fitbenchmarking<span class="w"> </span>-o<span class="w"> </span>fitting_options.ini<span class="w"> </span>-p<span class="w"> </span>examples/benchmark_problems/Muon
</pre></div>
</div>
<p>When the benchmark is complete, it should open a browser which contains the results. You should read the FitBenchmarking documentation if you need help with how to interpret these results. The results will also be stored in your current folder location.</p>
</section>
<section id="tips">
<h2><a class="toc-backref" href="#id7" role="doc-backlink">Tips</a><a class="headerlink" href="#tips" title="Link to this heading">¶</a></h2>
<ul class="simple">
<li><p>Make sure your git bash terminal is open in the correct location and has the virtual environment activated when running your benchmark.</p></li>
<li><p>Each time your run the benchmark, the old results will be overwritten unless you change the directory you run the <code class="docutils literal notranslate"><span class="pre">fitbenchmarking</span></code> command from. In later versions of FitBenchmarking (>v1.5) there will be an option to specify the results directory on the command line or via the <code class="docutils literal notranslate"><span class="pre">.ini</span></code> file.</p></li>
<li><p>Be aware that an ‘Unexpected Exception’ can sometimes occur when running the fitbenchmarking command after installing it from source without the editable flag <code class="docutils literal notranslate"><span class="pre">-e</span></code>.</p></li>
</ul>
</section>
</section>
</div>
</div>
</div>
<footer class="footer">
<div class="container">
<ul class="nav navbar-nav" style=" float: right;">
<li>
<a href="WindowsSubsystemForLinux.html" title="Previous Chapter: Windows Subsystem for Linux (WSL2)"><span class="glyphicon glyphicon-chevron-left visible-sm"></span><span class="hidden-sm hidden-tablet">« Windows Subsy...</span>
</a>
</li>
<li>
<a href="CondaPackageManager.html" title="Next Chapter: Conda Package Manager"><span class="glyphicon glyphicon-chevron-right visible-sm"></span><span class="hidden-sm hidden-tablet">Conda Package Manager »</span>
</a>
</li>
<li><a href="#">Back to top</a></li>
</ul>
<p>
</p>
</div>
</footer>
</body>
</html>