---
# System prepended metadata

title: Bayesian Network Metamodel Package
tags: [metamodel]

---

---
tags: metamodel
---

# Bayesian Network Metamodel Package

---

## Idea

The Bayesian Network Metamodel (BNM; working name) package is a software implementation of a novel methodology designed and developed by Zack Xuereb Conti in his [PhD thesis (2019)](https://www.zackxuerebconti.com/_files/ugd/4e5554_e14b055acfd94a048ff687661f32f80b.pdf), aimed at solving inverse design problems in engineering design and other fields. The versatility of the novel methodology has potential to contribute directly to Turing 2.0 key areas, namely Health and Environment and Sustainability. 

The original package relied on some outdated packages and the codebase is in need of a bit of refactoring. Kalle Westerling, RAM, has together with Zack created a prioritised and sized issue list, but to bolster the effectiveness and reach of this project, this proposal outlines the critical need of bringing a REG member (David Salvador Jasin) for 2 months, starting in December. The aim is to bring the project to a point where we can cultivate a vibrant user and contributor community around the BNM tool. The RSE responsibilities will be:

1. Codebase Upgrade/Refactoring:
    - The RSE will be tasked with updating the existing codebase to ensure its compatibility with Python 3. This is a fundamental step toward ensuring that the tool remains robust, secure, and in line with current software standards.
    - there is a dependency on an external package (libpgm) that needs to be replaced with a new package (or custom code). One currently proposed package is [PyBBN](https://pypi.org/project/pybbn/) but the RSE would bring their expertise here, in recommending other potential candidates. 
    
**[Update]** _Since our first pitch, we have done a general clean-up and eliminated all dependencies on the Python 2. Any dependency on the 'libpgm' Bayesian Network modeling package has now been replaced with 'PyBBN'._

2. Testing Pipeline Implementation and Documentation:
    - The RSE will be tasked with implementing a basic Continuous Integration (CI) testing pipeline. This will enable ongoing verification of the code’s integrity, thereby fostering a stable and reliable foundation on which a contributor community can be built.
    - They will also work closely with a RAM resource (Kalle Westerling), who will be principally focused on the creation of detailed documentation for the tool. While the RAM resource will lead this documentation effort, it is expected that the Research Software Engineer will review and, as necessary, provide input into this critical aspect of the project to ensure technical accuracy.

**[Update]** _A Git framework for continous intergration has now been set up by RAM Kalle Westerling. Generation of docstrings and documentation (via Sphinx) is also underway._

3. Future Feature Planning:
    - The RSE will be asked to contribute with input on best practices for future planned features, outlined under "Scope for Expansion" below.

The Force Multiplier project has already undergone preliminary scoping by Research Application Manager Kalle Westerling. This early-stage planning has helped to outline the key objectives, resources, and stages of the project, providing a solid foundation upon which to build. There are now marked up connections between issues in the GitHub repository and lines in the Python codebase.

Based on this scoping, the workload for an RSE for 2 months FTE has been assessed and is expected to be manageable. It is projected that the RSE will be able to complete their contributions to the project within 2 months of the start. This timeline has been designed to align with the critical path of the project, ensuring that key milestones can be met in a timely and efficient manner, while also accommodating for the iterative nature of the design and analysis that this project involves.

---

## Description

### High-level overview

This software allows users to construct bi-directional metamodels (aka surrogates or emulators) of input-output numerical solvers such as finite element analysis (FEA) in the form of a more computationally-efficient and user-intuitive metamodel, using Bayesian Networks. In contrast with traditional metamodeling approaches, a Bayesian-network metamodel does not distinguish between inputs and ouptuts and thus, enables inference in both foward and inverse directions; i.e. from input to output and output to input. The inverse capability facilitates to a) efficiently infer likely causal input configurations that would yield to a desired target output or engineering performance criterion, while b) provide explainable insight into complex cause-and-effect relationships between multi-input-output variables. 

The existing version of the software takes the form of a Python package that can work independently or as a back-end to an [independently-developed plug-in to Rhino](https://www.youtube.com/watch?v=tNa2Bd8nFk0&ab_channel=ZackXuerebConti), an industry-standard 3D parametric CAD modelling software.

Using BNM, a versatility of users including architects, engineers, designers and other various other stakeholders will benefit from the ability to leverage Bayesian networks to model and infer valuble insight about complex causal relationships between input parameters and numerical responses of interest, especially when the order of inputs is large and or when users lack in-depth understanding of the underlying science.

### Additional context

In traditional, iterative design and analysis and/or operational processes, it becomes very difficult to make global inferences about cause and effect when multiple variables are involved, often resorting to black-box optimisation algorithms, whose opaqueness can impede on insight into cause and effect. This project's approach seeks to internalise the cause and effect relationships learned from data, within a computational model (probabalistic graphical model) and subsequently facilitate navigation of these relationships through Bayesian inference.

The software revolves around the generation of a simulated input-ouptut dataset via design of (computer) experiments approaches (using a pseudo-random sampling approach). Design of Experiments (DoE) is a critical step in any data-driven modeling applications because in general, the quality of the model can only be as good as the quality of the data used to identify it. The simulated input-output data is processed and stored in a CSV file, which then serves as a foundation for learning the parameters (conditional probabilities) of a BN metamodel, which this project proposes as a substitution for computationally expensive numerical simulations. The bi-directionality of inference in BN metamodels facilitates instant and intuitive insight on the complex cause-and-effect relationships between design parameters and engineering responses.

Related publications: 
[Book chapter including applied examples](https://www.routledgehandbooks.com/pdf/doi/10.4324/9780367824259-20)
[Conference publication](https://www.researchgate.net/publication/320076055_Enabling_Inference_in_Performance-Driven_Design_Exploration)

### Nomination of Project Manager / PI:

Zack Xuereb Conti

---

## Justification

### Why is it interesting?

Traditionally, inverse design problems are hard to solve because the reverse mapping can be non-deterministic, especially when involving numerous variables, as there are infinitely many possible solutions even for the simplest conditions. Viewing an input-output problem using Bayesian Networks introduces bi-directionality which facilitates both forward (input to output) and inverse (output to input) computations. Furthermore, the latter facilitates interpretability of the design problem through cause and effect.

Aside from bypassing computational expense, this approach can potentially offer an intuitive wrapper around complex numerical solvers enabling both experienced and novice users to explore and make inferences about the behaviour of the subject being simulated, by offering clear insights into how changes in design parameters will impact the response/behaviour. Here, the BN metamodel acts as a translational mechanism from inaccessible/exepertise-dependant complex solver code to intuitive cause and effect relationships. 


### Describe the Impact (including who benefits)

#### Short version

In summary, the Bayesian Network Metamodel package promises to empower various user-types across a range of critical disciplines such as architectural design, material engineering, energy, etc., to make quick inferences about complex numerical analysis problems and to rapidly achieve solutions that maximise efficiency. Such applications could plug in towards delivering Turing 2.0 goals espeically in environment and sustainability, and health where optimisation strategies play a key role designing efficient systems and assets.

#### Long version

**Numerical solver users across fields** will likely be the primary beneficiaries of the Bayesian Network Metamodel package. The model's ability to rapidly infer likely parameters based on target outcomes equips these professionals with a powerful tool to make *more informed and data-driven decisions*, leading to *more efficient and effective solutions*.

Furthermore, the package has the potential to compresses/shorten analysis cycles across various fields. For example, in civil engineering, where consultant experts and non-experts are involved, encapsulating feedback from expert analyses as an intuitive BN metamodel could assist the non-experts in the team to make informed decisions, based on cause and effect. In engineering design, the BN Metamodel package is set to make waves in **design space inference and optimization across a diverse array of fields**. Further examples include:

- **Structural Engineering:** The package can be used to instantly identify feasible structural design parameters that satisfy given target criteria. This allows structural engineers to quickly zero in on designs that are both innovative and compliant with safety and performance standards.
- **Fusion Energy:** Researchers and engineers in the field of fusion energy can use this tool to instantly identify optimal fusion power plant design parameters and operational settings that satisfy target capital costs. This could be a game-changer in accelerating the development of sustainable and cost-effective energy solutions. (Research in this area is underway, and will provide a good case study for the package.)
- **Material Design:** For professionals engaged in the design of innovative materials, this package offers a way to systematically and rapidly identify the engineering parameters that are likely to result in desired material properties. This could revolutionise the development of new, innovative materials.

### Scope for Expansion

**Broad Applications and Collaborative Opportunities**: This method is not limited to architectural applications; it has the capacity to extend to various engineering problems and any scenario requiring an understanding of inverse relationships. Recognizing the rich, interdisciplinary potential of this project, it is openly inviting collaboration with professionals across various disciplines. This includes *data scientists, engineers, urban planners, policy makers*, and more. Such collaborative efforts hold the promise of expanding the method's applications across various industries.

**User-Friendly Interface for Broader Accessibility**: A significant expansion opportunity for this project lies in the development of a *user-friendly interface* that enables designers, engineers, and other stakeholders to easily interact with the Bayesian Network model. This envisioned interface would allow users to input design parameters, run simulations, and visualise results and inferences in an intuitive manner. Such an enhancement is aimed not only at solving complex problems but also at democratising access to this powerful tool. This would enable a wider range of professionals, beyond those with expertise in data science or statistical modelling, to leverage this resource in their work, making it a standard tool that provides instant, data-driven feedback throughout the design process. An existing userface implementation exists as a plug-in to a popular industry CAD modeling software, [see demo here]((https://www.youtube.com/watch?v=tNa2Bd8nFk0&ab_channel=ZackXuerebConti)) 

**Integration into Existing Software Tools**: Another potential expansion pathway is the integration of this tool as a *plugin or module within existing design and simulation software*. This integration would allow designers and engineers to seamlessly incorporate this powerful inference engine into their regular workflows, harmonising it with other tools they are already familiar with.

**Future Developments in Interactive Design and Analysis**: The project aspires to evolve into a comprehensive, interactive design and analysis suite. Some anticipated developments include:
- The incorporation of **fast sensitivity analysis methods** for model order reduction and inference
- The **implementation of state-of-the-art, faster inference and sampling algorithms**
- An **interactive user interface**, operational implementation of which is already underway, as exemplified by the existing prototype (see https://www.zackxuerebconti.com/bi-directional-inference).

---

## Required Resources

### Datasets (already existing)
- Simulation data generated from numerical analysis tools (e.g., structural FE, thermal FE, and lighting simulations).

### People (who can help)?
- RAM: Kalle Westerling
- REG: David Salvador Jasin, 2 months FTE

### Compute Time (Azure, etc)?
- No extensive compute time needed for this project, but development and testing should be possible on local computers.
