• Stars
    star
    904
  • Rank 50,534 (Top 1.0 %)
  • Language
    Python
  • License
    Other
  • Created about 4 years ago
  • Updated 26 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Pytorch-based framework for solving parametric constrained optimization problems, physics-informed system identification, and parametric model predictive control.

NeuroMANCER v1.3.2

Tests PyPI Downloads Documentation

Neural Modules with Adaptive Nonlinear Constraints and Efficient Regularizations.

Authors: Aaron Tuor, Jan Drgona, Mia Skomski, Stefan Dernbach, James Koch, Zhao Chen, Christian Møldrup Legaard, Draguna Vrabie, Madelyn Shapiro

Colab tutorials

  • Parametric programming
    • Rosenbrook
Open In Colab + Himmelblau Open In Colab
  • System Identification
Open In Colab
  • Double Integrator
Open In Colab
  • Control
Open In Colab

Version 1.3.2 Release Notes

  • Merged Structured Linear Maps and Pyton Systems Library into Neuromancer
    • The code in neuromancer was closely tied to psl and slim. A decision was made to integrate the packages as submodules of neuromancer. This also solves the issue of the package names "psl" and "slim" already being taken on PyPI.

Import changes for psl and slim

# before
import psl
import slim

# now
from neuromancer import psl
from neuromancer import slim

Documentation

The documentation for the library can be found online and in the pdf form. There is also an introduction video covering core features of the library.

# Neuromancer syntax example for differentiable parametric programming
import neuromancer as nm

# primal solution map to be trained
func = nm.blocks.MLP(insize=2, outsize=2, hsizes=[80] * 4)
sol_map = nm.maps.Map(func,
        input_keys=["a", "p"],
        output_keys=["x"],
        name='primal_map')

# problem primal variables
x = nm.constraint.variable("x")[:, [0]]
y = nm.constraint.variable("x")[:, [1]]

# sampled problem parameters
p = nm.constraint.variable('p')
a = nm.constraint.variable('a')

# nonlinear objective function
f = (1-x)**2 + a*(y-x**2)**2
obj = f.minimize(weight=1., name='obj')

# constraints
con_1 = 100*(x >= y)
con_2 = 100*((p/2)**2 <= x**2+y**2)
con_3 = 100*(x**2+y**2 <= p**2)

# create constrained optimization loss
objectives = [obj]
constraints = [con_1, con_2, con_3]
loss = nm.loss.PenaltyLoss(objectives, constraints)
# construct constrained optimization problem
components = [sol_map]
problem = nm.problem.Problem(components, loss)

UML diagram UML diagram of NeuroMANCER classes.

Installation

For either pip or conda installation, first clone the neuromancer package. A dedicated virtual environment (conda or otherwise) is recommended.

Note: If you have a previous neuromancer env it would be best at this point to create a new environment given the following instructions.

git clone -b master https://github.com/pnnl/neuromancer.git --single-branch

Conda install

Conda install is recommended for GPU acceleration. In many cases the following simple install should work for the specified OS

Ubuntu

conda env create -f linux_env.yml
conda activate neuromancer

Windows

conda env create -f windows_env.yml
conda activate neuromancer
conda install -c defaults intel-openmp -f

MacOS (Apple M1)

conda env create -f osxarm64_env.yml
conda activate neuromancer

Other operating system

!!! Pay attention to comments for non-Linux OS !!!

conda create -n neuromancer python=3.10.4
conda activate neuromancer
conda install pytorch pytorch-cuda=11.6 -c pytorch -c nvidia
## OR (for Mac): conda install pytorch -c pytorch
conda config --append channels conda-forge
conda install scipy numpy matplotlib scikit-learn pandas dill mlflow pydot=1.4.2 pyts numba
conda install networkx=3.0 plum-dispatch 
conda install -c anaconda pytest hypothesis
conda install cvxpy cvxopt casadi seaborn imageio
conda install tqdm torchdiffeq toml
## (for Windows): conda install -c defaults intel-openmp -f

PIP Install

Pip installation is broken up into required dependencies for core Neuromancer and dependencies associated with the examples, tests, and generating the documentation. Below we give instructions to install all dependencies in a conda virtual enviroment via pip.

Create and activate virtual environment

conda create -n neuromancer python=3.10.4
conda activate neuromancer

Install neuromancer and all dependencies.

From top level directory of cloned neuromancer run:

pip install -e.[docs,tests,examples]

See the pyproject.toml file for reference.

[project.optional-dependencies]
tests = ["pytest", "hypothesis"]
examples = ["casadi", "cvxpy", "imageio"]
docs = ["sphinx", "sphinx-rtd-theme"]

Test NeuroMANCER install

Run pytest on the test folder. It should take about 2 minutes to run the tests on CPU. There will be a lot of warnings that you can safely ignore. These warnings will be cleaned up in a future release.

Examples

For detailed examples of NeuroMANCER usage for control, system identification, and parametric programming as well as tutorials for basic usage, see the scripts in the examples folder.

New in 1.3.1: Interactive notebook versions of examples are available on Google Colab! Test out NeuroMANCER functionality before cloning the repository and setting up an environment. We currently have three interactive notebook examples:

  • Open In Colab examples/control/double_integrator_DPC_interactive.ipynb
  • Open In Colab examples/parametric_programming/Himmelblau_interactive.ipynb
  • Open In Colab examples/duffing_parameter_interactive.ipynb

Community

Contributing examples

If you have an example of using NeuroMANCER to solve an interesting problem, or of using NeuroMANCER in a unique way, we would love to see it incorporated into our current library of examples. To submit an example, create a folder for your example/s in the example folder if there isn't currently an applicable folder and place either your executable python file or notebook file there. Push your code back to github and then submit a pull request. Please make sure to note in a comment at the top of your code if there are additional dependencies to run your example and how to install those dependencies.

Contributing code

We welcome contributions to NeuroMANCER. Please accompany contributions with some lightweight unit tests via pytest (see test/ folder for some examples of easy to compose unit tests using pytest). In addition to unit tests a script utilizing introduced new classes or modules should be placed in the examples folder. To contribute a new feature please submit a pull request.

Reporting issues or bugs

If you find a bug in the code or want to request a new feature, please open an issue.

NeuroMANCER development plan

Here are some upcoming features we plan to develop. Please let us know if you would like to get involved and contribute so we may be able to coordinate on development. If there is a feature that you think would be highly valuable but not included below, please open an issue and let us know your thoughts.

  • Faster dynamics modeling via Torchscript
  • Control and modelling for networked systems
  • Easy to implement modeling and control with uncertainty quantification
  • Online learning examples
  • Benchmark examples of DPC compared to deep RL
  • Conda and pip package distribution
  • CVXPY-like interface for optimization via Problem.solve method
  • More versatile and simplified time series dataloading
  • Pytorch Lightning trainer compatibility
  • Discovery of governing equations from learned RHS via NODEs and SINDy

Publications

Cite as

@article{Neuromancer2022,
  title={{NeuroMANCER: Neural Modules with Adaptive Nonlinear Constraints and Efficient Regularizations}},
  author={Tuor, Aaron and Drgona, Jan and Skomski, Mia and Koch, James and Chen, Zhao and Dernbach, Stefan and Legaard, Christian Møldrup and Vrabie, Draguna},
  Url= {https://github.com/pnnl/neuromancer}, 
  year={2022}
}

Acknowledgments

This research was partially supported by the Mathematics for Artificial Reasoning in Science (MARS) and Data Model Convergence (DMC) initiatives via the Laboratory Directed Research and Development (LDRD) investments at Pacific Northwest National Laboratory (PNNL), by the U.S. Department of Energy, through the Office of Advanced Scientific Computing Research's “Data-Driven Decision Control for Complex Systems (DnC2S)” project, and through the Energy Efficiency and Renewable Energy, Building Technologies Office under the “Dynamic decarbonization through autonomous physics-centric deep learning and optimization of building operations” and the “Advancing Market-Ready Building Energy Management by Cost-Effective Differentiable Predictive Control” projects. PNNL is a multi-program national laboratory operated for the U.S. Department of Energy (DOE) by Battelle Memorial Institute under Contract No. DE-AC05-76RL0-1830.

Prior release notes

Version 1.3.1 release notes

  • New example scripts and notebooks
    • Interactive Colab notebooks for testing Neuromancer functionality without setting up an environment
    • RC-Network modeling using Graph Neural Time-steppers example:
      • See neuromancer/examples/graph_timesteppers/
    • Baseline NODE dynamics modeling results for all nonautonomous systems in Python Systems Library
      • See neuromancer/examples/benchmarks/node/
    • Updated install instructions for Linux, Windows, and MAC operating systems
      • New linux_env.yml, windows_env.yml, osxarm64_env.yml files for installation of dependencies across OS
  • Corresponding releases of SLiM and PSL packages
    • Make sure to update these packages if updating Neuromancer
    • Release 1.4 will roll SLiM and PSL into core Neuromancer for ease of installation and development

Version 1.3 release notes

  • Tutorial YouTube videos to accompany tutorial scripts in examples folder:
  • Closed loop control policy learning examples with Neural Ordinary Differential Equations
    • examples/control/
      • vdpo_DPC_cl_fixed_ref.py
      • two_tank_sysID_DPC_cl_var_ref.py
      • two_tank_DPC_cl_var_ref.py
      • two_tank_DPC_cl_fixed_ref.py
  • Closed loop control policy learning example with Linear State Space Models.
    • examples/control/
      • double_integrator_dpc_ol_fixed_ref.py
      • vtol_dpc_ol_fixed_ref.py
  • New class for Linear State Space Models (LSSM)
    • LinearSSM in dynamics.py
  • Refactored closed loop control policy simulations
    • simulator.py
  • Interfaces for open and closed loop simulation (evaluation after training) for several classes
    • Dynamics
    • Estimator
    • Policy
    • Constraint
    • PSL Emulator classes
  • New class for closed-loop policy learning of non-autonomous ODE systems
    • ControlODE class in ode.py
  • Added support for NODE systems
    • Torchdiffeq integration with fast adjoint method for NODE optimization

More Repositories

1

HyperNetX

Python package for hypergraph analysis and visualization.
Python
544
star
2

safekit

Python
140
star
3

SHAD

Scalable High-performance Algorithms and Data-structures
C++
122
star
4

OpenCGRA

OpenCGRA is an open-source framework for modeling, testing, and evaluating CGRAs.
Verilog
97
star
5

NWGraph

Complete Project Documentation
C++
93
star
6

cmaputil

Python
80
star
7

QASMBench

A low-level OpenQASM benchmark suite for NISQ evaluation and simulation. Please see our paper for details.
OpenQASM
79
star
8

ExaGO

High-performance power grid optimization for stochastic, security-constrained, and multi-period ACOPF problems.
C++
64
star
9

isicle

In silico chemical library engine for high-accuracy chemical property prediction
Python
58
star
10

DM-Sim

DM-Sim: Quantum Simulator on GPU Cluster using Density Matrix
OpenQASM
51
star
11

deps_arXiv2020

Differentiable predictive control (DPC) policy optimization examples.
MATLAB
47
star
12

lamellar-runtime

Lamellar is an asynchronous tasking runtime for HPC systems developed in RUST
Rust
42
star
13

DHSVM-PNNL

C
39
star
14

tesp

Python
39
star
15

COMET

C++
34
star
16

soda-opt

C++
32
star
17

deimos

Python
31
star
18

ripples

A C++ Library for Influence Maximization
C++
31
star
19

darkchem

Python
31
star
20

TCBNN

Cuda
31
star
21

chemreasoner

ChemReasoner - Catalyst Discovery via Large Language Model-driven Reasoning
Python
31
star
22

chgl

Chapel HyperGraph Library (CHGL) - HPC-class Hypergraphs in Chapel
Chapel
29
star
23

SLiCE

Subgraph Based Learning of Contextual Embedding
Python
28
star
24

gmt

Global Memory and Threading runtime system
C
23
star
25

chissl

Interactive machine learning interface
Jupyter Notebook
22
star
26

s-blas

This package includes the implementation for four sparse linear algebra kernels: Sparse-Matrix-Vector-Multiplication (SpMV), Sparse-Triangular-Solve (SpTRSV), Sparse-Matrix-Transposition (SpTrans) and Sparse-Matrix-Matrix-Multiplication (SpMM) for Single-node Multi-GPU (scale-up) platforms such as NVIDIA DGX-1 and DGX-2.
C++
22
star
27

MSAC

Jupyter Notebook
21
star
28

socialsim

Python
20
star
29

qasmtrans

A C++ based quantum transpiler for NISQ devices
OpenQASM
20
star
30

cactus

LLM Agent that leverages cheminformatics tools to provide informed responses.
Jupyter Notebook
20
star
31

torchntk

Jupyter Notebook
19
star
32

buildingid

Unique Building Identifier (UBID)
18
star
33

mol_dgnn

Molecular Dynamic Graph Neural Network
Python
18
star
34

DeepDataProfiler

Python library for analyzing the internal structure of deep neural networks.
Jupyter Notebook
18
star
35

mercat

MerCat: python code for versatile k-mer counting and diversity estimation for database independent property analysis for meta -ome data
Python
18
star
36

leapR

R
17
star
37

E4D

Standard ML
17
star
38

socialsim_package

Jupyter Notebook
17
star
39

DDKS

A high-dimensional Kolmogorov-Smirnov distance for comparing high dimensional distributions
Jupyter Notebook
16
star
40

GridSTAGE

MATLAB
16
star
41

slim

Drop-in replacements for PyTorch nn.Linear for stable learning and inductive priors in physics informed machine learning applications.
Cuda
16
star
42

pychip_gui

pyCHIP is a tool for segmentation and feature classification in transmission electron microscopy (TEM) images based on a small support set of user-provided examples.
HTML
16
star
43

NWQ-Sim

OpenQASM
15
star
44

sven

JavaScript
15
star
45

arena

The programming runtime and interfaces for ARENA.
C++
14
star
46

fqc

📈 Extensible quality control dashboard built around FASTQ assessment.
JavaScript
14
star
47

buildingid-py

Unique Building Identifier (UBID)
Python
14
star
48

hundo

💯 Snakemake-based amplicon processing protocol for 16S and ITS sequences.
HTML
14
star
49

memgaze

C
12
star
50

SV-Sim

SV-Sim: Scalable PGAS-based State Vector Simulation of Quantum Circuits
OpenQASM
11
star
51

Neural-Modules-for-Differential-Algebraic-Equations

Jupyter Notebook
11
star
52

rofi

C
10
star
53

hexwatershed

Flow routing using a hexagonal grid.
C++
10
star
54

HiParTI

C
10
star
55

solubility-prediction-paper

Jupyter Notebook
10
star
56

blueprint-styler

Make custom blueprint.css styles
TypeScript
10
star
57

copper

Performance curve generator for building energy simulation
Python
9
star
58

hypernetx-widget

JavaScript
9
star
59

building-energy-standards-data

Database of building energy standards data for building energy simulation.
Python
8
star
60

eqc

Python
8
star
61

ANIMATE

Jupyter Notebook
8
star
62

i2x

Interconnection Innovation e-Xchange (i2x) Test Systems
Python
8
star
63

esteem

JavaScript
8
star
64

psl

Jupyter Notebook
8
star
65

GeoCLUSTER

GeoCLUSTER is a Python-based web application that provides a collection of interactive methods for streamlining the visualization of the technical and economic modeling of closed-loop geothermal systems.
Python
8
star
66

mcl

C
7
star
67

grid_prediction

Jupyter Notebook
7
star
68

ruleset-checking-tool

Python
7
star
69

ARTS

Abstract RunTime System
C
7
star
70

ConStrain

ConStrain is a data-driven knowledge-integrated framework that automatically verifies that building system controls function as intended.
Jupyter Notebook
7
star
71

gparm

A tool for developing parametric inputs for other software.
Perl
6
star
72

sds

Jupyter Notebook
6
star
73

DMIPL

Differentiable Mixed-Integer Programming Layers
Jupyter Notebook
6
star
74

brislawn-2018-founders-species

🦠 📓 a microbiome paper
HTML
6
star
75

DPC_for_robotics

Python
6
star
76

AutoMicroED

Python
6
star
77

qFeature

Extract features from time series using moving windows of regression fits
HTML
6
star
78

STOMP-W

Fortran 90 source code, example problems, and output conversion scripts for the STOMP-W simulator.
Fortran
6
star
79

lamellar

Lamellar is an asynchronous tasking runtime for HPC systems developed in RUST
5
star
80

ThermalTracker

C++
5
star
81

Active-Sampling-for-Atomistic-Potentials

Active sampling for neural network potentials: Accelerated simulations of shear-induced deformation in Cu–Ni multilayers
Python
5
star
82

NWPEsSE

Python
5
star
83

NWHypergraph

C++
4
star
84

nwqbench

Python
4
star
85

nmrfit

Quantitative NMR analysis through least-squares fit of spectroscopy data
Python
4
star
86

LOPO

Learning to Optimize with Proximal Operators (LOPO)
Jupyter Notebook
4
star
87

DieselWolf

Open source data set for radio frequency machine learning research
Jupyter Notebook
4
star
88

pytorch_soo

Second Order Optimizers for Machine Learning
HTML
4
star
89

pecblocks

Generalized block diagram modeling of power electronic converters for grid solar and storage applications.
Python
4
star
90

external_sort

Rust
4
star
91

conformer_selection

Jupyter Notebook
4
star
92

neural_ODE_ICLR2020

Python
4
star
93

sppsi_cppf

Simulate microstructure evolution using the coupled CP and PF methods for the SPPSI project.
GLSL
4
star
94

rsed

Stream editing in R: Manipulating text files with insertions, replacements, deletions, substitutions, and commenting
R
4
star
95

ssass-e

SSASSE software is responsible for validating, and verifying innovative safe scanning methodologies, models, architectures, and prototypes to safely assess operational technology (OT) installed in critical energy infrastructure.
Python
4
star
96

oedisi_dopf

OpenEDI - System Integration (OEDI-SI) - PNNL Distributed Optimal Power Flow (DOPF)
Jupyter Notebook
4
star
97

DREAM_V2

The DREAM tool is an optimization software that determines subsurface monitoring configurations which detect carbon dioxide (CO2) leakage in the least amount of time. DREAM reads ensembles of CO2 leakage scenarios and determines optimal monitoring locations and techniques to deploy based on user-identified constraints. These data result in well configurations with the highest potential to detect leakage and minimize aquifer degradation in the shortest amount of time. DREAM was developed as part of the National Risk Assessment Partnership.
Java
4
star
98

pakman

PaKman: A Scalable Algorithm for Generating Genomic Contigs on Distributed Memory Machines
C++
4
star
99

renyiqnets

Python
3
star
100

mass1

Modular Aquatic Simulation System 1D (MASS1)
Fortran
3
star