Skip to content

Commit

Permalink
Webpage
Browse files Browse the repository at this point in the history
  • Loading branch information
michelbierlaire committed Dec 21, 2023
1 parent eb2efb3 commit 227bab6
Show file tree
Hide file tree
Showing 5 changed files with 177 additions and 93 deletions.
58 changes: 50 additions & 8 deletions webpage/faq.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,42 @@
faq = {}

faq['What was new in Biogeme 3.2.12?'] = """
faq[
'What was new in Biogeme 3.2.13?'
] = """
<dl>
<dt>MDCEV</dt>
<dd>The Multiple Discrete Continuous Extreme Value model has been implemented. The code is still experimental, and the documentation is not ready yet.
</dd>
<dt>Local-sensitivy hashing</dt>
<dd>The data reduction method introduced by <a href='https://transp-or.epfl.ch/documents/technicalReports/OrteLappBier2023.pdf'>Ortelli et al. (2023)</a> has been implemented. It has not yet been integrated in the optimization framework.</dd>
<dt>Nests definition</dt>
<dd>The definition of the nests for the nested logit and the cross-nested logit models has been improved, using specific objects. See <a href="sphinx/nests.html">the module documentation.</a> The calculation of the correlation structure among the alternatives is now performed by those objects, and not anymore by the <samp>bioResults</samp> object as in previous versions.</dd>
<dt>Sampling of alternatives</dt>
<dd>The methods for the sampling of alternatives have been completely reimplemented. A report with a complete documentation will be available soon.</dd>
<dt>Examples</dt>
<dd>The structure of the examples has been revisited. They are now integrated in the Sphinx documentation, and available both as Python scripts and Jupyter notebooks. <a href='sphinx/auto_examples/index.html'>Click here.</a></dd>
<dt>Non convergence</dt>
<dd>The reporting has been improved when the algorithm does not converge. </dd>
<dt>Logging</dt>
<dd>The logging module has been renamed from <code>biogeme.logging</code> into <code>biogeme.biogeme_logging.py</code>. It was necessary because of the ambiguity with the <code>logging</code> module from Python.
</dd>
<dt>File organization</dt>
<dd>Several scripts have bben reorganized into modules. This improves the code readability and should be transparent for the user.</dd>
</dl>
"""
faq[
'What was new in Biogeme 3.2.12?'
] = """
<p>
This release mainly implements some re-organization of the code and bugs fixes. In particular, the generic optimization algorithms are now distributed in a different package, called biogeme_optimization.
</p>
"""

faq['What was new in Biogeme 3.2.11?'] = """
faq[
'What was new in Biogeme 3.2.11?'
] = """
<dl>
<dt>Sampling of alternatives</dt>
Expand Down Expand Up @@ -43,7 +73,9 @@
</dl>
"""

faq['What was new in Biogeme 3.2.10?'] = """
faq[
'What was new in Biogeme 3.2.10?'
] = """
<p><strong>Note</strong>: versions 3.2.9 and 3.2.10 are
identical. Therefore, version 3.2.9 has been removed from
the official distribution platform. </p>
Expand Down Expand Up @@ -116,7 +148,9 @@
</dl>
"""
faq['What was new in Biogeme 3.2.8?'] = """
faq[
'What was new in Biogeme 3.2.8?'
] = """
<p>Note that version 3.2.7 and 3.2.8 are almost
identical. The description belows compares to version 3.2.6.
<dl>
Expand Down Expand Up @@ -192,7 +226,9 @@
"""

faq['What was new in Biogeme 3.2.6?'] = """
faq[
'What was new in Biogeme 3.2.6?'
] = """
<dl>
<dt>Optimization</dt>
<dd>New optimization algorithms are
Expand Down Expand Up @@ -380,7 +416,9 @@
</p>
"""

faq['ImportError: DLL load failed while importing cythonbiogeme: The specified module could not be found'] = """
faq[
'ImportError: DLL load failed while importing cythonbiogeme: The specified module could not be found'
] = """
The issue is that in Python 3.8 and older on Windows, DLLs are loaded from trusted locations only (<a href ="https://docs.python.org/3/whatsnew/3.8.html#ctypes" target="_blank">see this</a>). It is necessary to add the path of the DLLs. Here is a way proposed by Facundo Storani, University of Salerno:
<ul>
<li>Search the DLLs folder of anaconda3. It may be similar to: <code>C:\\Users\\[USER_NAME]\\anaconda3\\DLLs or C:\\ProgramData\\Anaconda3\\DLLs</code>.</li>
Expand All @@ -392,7 +430,9 @@
</ul> (credit: Facundo Storani)
"""

faq['Why is Cython library not found?'] = """
faq[
'Why is Cython library not found?'
] = """
On Mac OSX, the
following error is sometimes
generated: <pre>
Expand Down Expand Up @@ -440,7 +480,9 @@
If it does not work... I don't know :-(
"""

faq['Why is it trying to compile during installation?'] = """
faq[
'Why is it trying to compile during installation?'
] = """
On Mac OSX and Windows, the procedure is designed to install
from binaries, not sources. If you get messages that look like the
following, it means that pip is trying to compile from sources. And
Expand Down
13 changes: 8 additions & 5 deletions webpage/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
CARD_FILE = 'card.html'
SPECIAL_FILE = 'special.html'


def replace(orig_text, dictionary):
for k, v in dictionary.items():
orig_text = orig_text.replace(k, v)
return orig_text


def get_section(content):
all_html = ''
id = 0
Expand Down Expand Up @@ -58,7 +60,7 @@ def get_special(content):
all_html = ''
with open(SPECIAL_FILE, 'r', encoding='utf-8') as f:
html = f.read()

for special_title, special_content in content.items():
my_html = html
replacements = {
Expand All @@ -67,7 +69,8 @@ def get_special(content):
}
all_html += replace(my_html, replacements)
return all_html



def get_portfolio_grid(doc):
all_html = ''
for data, values in doc.items():
Expand Down Expand Up @@ -135,7 +138,7 @@ def get_portfolio_modals(doc):
'__DOC__': get_section(documentation),
'__RES__': get_section(resources),
'__ARCHIVES__': get_section(archives),
'__SPECIAL__': get_special(special)
'__SPECIAL__': get_special(special),
}

html = replace(html, replacements)
Expand All @@ -157,9 +160,9 @@ def get_portfolio_modals(doc):
# Copy the Bootstrap assets
shutil.copytree('assets', 'website/assets')


# Copy the PythonBiogeme distribution
shutil.copytree('otherFiles/distrib', 'website/distrib')

# Copy the sphinx documentation
shutil.copytree('../sphinx/_build/html', 'website/sphinx')
shutil.copytree('../docs/build/html', 'website/sphinx')
10 changes: 6 additions & 4 deletions webpage/index.html.orig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" >
<meta name="description" content="" >
<meta name="author" content="" >
<title>Biogeme 3.2.12</title>
<title>Biogeme 3.2.13</title>
<!-- Favicon-->
<link rel="icon" type="image/x-icon" href="assets/favicon.ico" >
<!-- Font Awesome icons (free version)-->
Expand Down Expand Up @@ -34,7 +34,7 @@
<li class="nav-item"><a class="nav-link" href="#help">Help</a></li>
<li class="nav-item"><a class="nav-link" href="#doc">Documentation</a></li>
<li class="nav-item"><a class="nav-link"
href="https://github.com/michelbierlaire/biogeme/tree/master/examples"
href="sphinx/auto_examples/index.html"
target="_blank">Examples</a></li>
<li class="nav-item"><a class="nav-link" href="#res">Resources</a></li>
<li class="nav-item"><a class="nav-link" href="#archives">Archives</a></li>
Expand All @@ -51,7 +51,8 @@
<div class="container">
<div class="masthead-subheading">Estimating discrete choice
models with</div>
<div class="masthead-heading text-uppercase">Biogeme</div>
<div class="masthead-heading text-uppercase">Biogeme <span id="version"></span></div>

<a class="btn btn-primary btn-xl text-uppercase" href="#start">Start</a>
</div>
</header>
Expand Down Expand Up @@ -317,7 +318,7 @@
<div class="container">
<div class="row align-items-center">
<div class="col-lg-4 text-lg-start">Copyright
&copy; Michel Bierlaire 2022</div>
&copy; Michel Bierlaire 2024</div>
<div class="col-lg-4 my-3 my-lg-0">
<a class="btn btn-dark btn-social mx-2"
target="_blank" href="https://groups.google.com/d/forum/biogeme"
Expand All @@ -343,5 +344,6 @@

<!-- Core theme JS-->
<script src="js/scripts.js"></script>
<script src="js/get_version.js"></script>
</body>
</html>
31 changes: 31 additions & 0 deletions webpage/js/get_version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// This script connects to the pypi.org server and checks the latest available version of Biogeme

const CACHE_DURATION = 24 * 60 * 60 * 1000; // 1 day in milliseconds

function fetchVersion() {
fetch('https://pypi.org/pypi/biogeme/json')
.then(response => response.json())
.then(data => {
const version = data.info.version;
document.getElementById('version').textContent = version;

// Cache the version and current timestamp
localStorage.setItem('biogemeVersion', version);
localStorage.setItem('biogemeTimestamp', Date.now());
})
.catch(error => {
console.error('Error fetching the version:', error);
document.getElementById('version').textContent = 'Error fetching version';
});
}

// Check if we have a cached version and it's still valid
const cachedVersion = localStorage.getItem('biogemeVersion');
const cachedTimestamp = localStorage.getItem('biogemeTimestamp');
if (cachedVersion && cachedTimestamp && Date.now() - cachedTimestamp < CACHE_DURATION) {
// Use the cached version
document.getElementById('version').textContent = cachedVersion;
} else {
// Fetch the latest version
fetchVersion();
}
Loading

0 comments on commit 227bab6

Please sign in to comment.