Skip to content

Commit

Permalink
Merge pull request #15 from MetExplore/development
Browse files Browse the repository at this point in the history
Minor pre-release fixes for 0.9.0-beta.2
  • Loading branch information
pablormier authored Aug 16, 2021
2 parents 059bbde + f53de15 commit 9d3c866
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 7 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div align="center">
<a href="https://metexplore.github.io/miom"><img align="center" src="https://github.com/MetExplore/miom/raw/development/docs/assets/img/miom_v1.png" alt="MIOM" width="545" title="MIOM: Mixed Integer Optimization for Metabolism"/>
<a href="https://metexplore.github.io/miom"><img align="center" src="https://github.com/MetExplore/miom/raw/development/docs/assets/img/miom_v1.png" alt="MIOM" title="MIOM: Mixed Integer Optimization for Metabolism"/>
</a>
</div>

Expand All @@ -11,9 +11,11 @@

</div>

---
<h4 align="center">
<a href="https://metexplore.github.io/miom">https://metexplore.github.io/miom</a>
</h4>

https://metexplore.github.io/miom
---

__MIOM__ (Mixed Integer Optimization for Metabolism) is a python library for creating and solving complex optimization problems using genome-scale metabolic networks, in just a few lines.

Expand Down
Binary file modified docs/assets/img/miom_v1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/assets/img/miom_v1_fit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions docs/stylesheets/extra.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
:root {
--md-primary-fg-color: #132a4b;
--md-primary-fg-color--light: #2f5a96;
--md-primary-fg-color--dark: #0b1b31;
--md-primary-bg-color: hsla(0, 0%, 100%, 1);
--md-primary-bg-color--light: hsla(0, 0%, 100%, 0.7);
--md-text-link-color: #386eb9;

/* Accent color shades */
--md-accent-fg-color: #6896d6;
--md-accent-fg-color--transparent: hsla(189, 100%, 37%, 0.1);
--md-accent-bg-color: hsla(0, 0%, 100%, 1);
--md-accent-bg-color--light: hsla(0, 0%, 100%, 0.7);
}
14 changes: 10 additions & 4 deletions miom/miom.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ def keep(self, reactions):
return dict(idxs=idxs, valid_rxn_idx=valid_rxn_idx)

@_partial
def subset_selection(self, rxn_weights, eps=1e-2):
def subset_selection(self, rxn_weights, direction='max', eps=1e-2):
"""Transform the current model into a subset selection problem.
The subset selection problem consists of selecting the positive weighted
Expand Down Expand Up @@ -556,7 +556,7 @@ def subset_selection(self, rxn_weights, eps=1e-2):
rxnw = _weighted_rxns(self.network.R, rxn_weights)
if self.variables.indicators is None:
self.variables._assigned_reactions = rxnw
return dict(eps=eps)
return dict(eps=eps, direction=direction)
else:
warnings.warn("Indicator variables were already assigned")
return False
Expand Down Expand Up @@ -867,7 +867,7 @@ def _subset_selection(self, *args, **kwargs):
P.add_constraint((1 - X[i]) * rd.lb - V[rd.index] <= 0)
else:
raise ValueError("Unknown type of reaction")
P.set_objective('max', C.T * X)
P.set_objective(kwargs['direction'], C.T * X)
self.variables._indicator_vars = X
return True

Expand Down Expand Up @@ -982,6 +982,7 @@ def _set_flux_bounds(self, *args, **kwargs):

def _subset_selection(self, *args, **kwargs):
eps = kwargs["eps"]
direction = kwargs["direction"]
weighted_rxns = self.variables.assigned_reactions
P = self.problem
V = self.variables.fluxvars
Expand All @@ -998,7 +999,12 @@ def _subset_selection(self, *args, **kwargs):
else:
raise ValueError("Unknown type of reaction")
P.objective = mip.xsum((c * X[i] for i, c in enumerate(C)))
P.sense = mip.MAXIMIZE
if direction == "max" or direction == "maximize":
P.sense = mip.MAXIMIZE
elif direction == "min" or direction == "minimize":
P.sense = mip.MINIMIZE
else:
raise ValueError("Unknown optimization sense")
self.variables._indicator_vars = X
return True

Expand Down
4 changes: 4 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ repo_url: https://www.github.com/metexplore/miom
copyright: Copyright &copy; 2021 INRAE Toxalim
theme:
name: material
palette:
primary: '#2e5c87'
custom_dir: docs/overrides
plugins:
- search
Expand Down Expand Up @@ -38,6 +40,8 @@ extra:
property: G-5SV6WE1KMZ
version:
provider: mike
extra_css:
- stylesheets/extra.css
extra_javascript:
- https://polyfill.io/v3/polyfill.min.js?features=es6
- https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js

0 comments on commit 9d3c866

Please sign in to comment.