Skip to main content

A light-weight package to solve large systems of interactions

Project description

CounterFusion

This repository implements algorithms for a paper in preparation. To dive deeper, please visit my personal website.

Prerequisites

To effectively engage with the notebook, the following Python packages are required:

  • numpy: For handling numerical computations and array operations.
  • matplotlib: Essential for creating and displaying graphs and visualizations.

Installation

Ensure you have the necessary packages installed by running:

pip install numpy matplotlib

Usage

For details, please refer to the jupyter notebook which provides many demo cases. Here you may find python snippets to showcase step-by-step the build-up from the bottom, a single interaction, to a system containing multiple sequences of interactions.

  1. Define a single interaction
from counterfusion import interaction_builder
left_stochastic_matrix = interaction_builder(dim=2,id1=0,id2=1,value=[0.1,0.3])
right_stochastic_matrix = left_stochastsic_matrix.T
doubly_stochastic_matrix = interaction_builder(dim=2,id1=0,id2=1,value=0.5)
  1. Define a sequence of interactions
from counterfusion import *
#===============================================================
# General information for the edge - Hyperparameters
totalNumMover = 4
numForwardMover = 2
initStates = [1,1,0.2,0.2]
#===============================================================
# Information of scattering events 
# Interaction parameters
v03 = 0.3
v01 = 0.5
v23 = 0.8
edgeDef = [[0,3,v03,10],[0,1,v01,10],[2,3,v23,10]]
edgeInfo = generate_bynumber(edgeDef)
edge = Edge(edgeInfo,totalNumMover,numForwardMover)
  1. Define a system constituted by several Edge instances.
from counterfusion import *
# Define a six-terminal system
# C1--M1--C2--M2--C3--M3--C4--M4--C5--M5--C6--M6--C1
# Total number of edge states: 4
# Number of forward-moving edge states: 2 (#0,#1)
# Number of backward-moving edge states: 2 (#2,#3)
#===============================================================
# General information for the system - Hyperparameters
totalNumMover = 4
numForwardMover = 2
zeroVoltTerminal = 3
#===============================================================
# Information of scattering events 
# Interaction parameters
v02 = 0.9
v13 = 0.7
v12 = 0.3
# Define interaction between nodes (contacts)
# C1--M1--C2
edgeDef1 = [[0,2,v02,10],[1,3,v13,10]]
# C2--M2--C3
edgeDef2 = [[0,2,v02,10],[1,2,v12,10]]
# C3--M3--C4
edgeDef3 = [[0,2,v02,10],[1,3,v13,10]]
# C4--M4--C5
edgeDef4 = [[0,2,v02,10],[1,2,v12,10]]
# C5--M5--C6
edgeDef5 = [[0,2,v02,10],[1,3,v13,10]]
# C6--M6--C1
edgeDef6 = [[0,2,v02,10],[1,2,v12,10]]
#================================================================
edgesDef = [edgeDef1,edgeDef2,edgeDef3,edgeDef4,edgeDef5,edgeDef6]
edgesInfo = []
for edgeDef in edgesDef:
    edgesInfo.append(generate_bynumber(edgeDef))
graph = []
for edgeInfo in edgesInfo:
    graph.append(Edge(edgeInfo,totalNumMover,numForwardMover))
nodesCurrent = [1,0,0,-1,0,0]
sys = System(nodesCurrent,graph,numForwardMover,zeroVoltTerminal)
  1. Define individual paths of flows
# The definition of blocking_state should strictly follow this rule: 
# [[index_of_terminal#1,[all blocked states in this terminal]],[[index_of_terminal#2,[all blocked states in this terminal],...]]]
blockStates = [[1,[0]],[0,[2]],[2,[3]],[3,[1]]]
sys = System(nodesCurrent,graph,numForwardMover,zeroVoltTerminal,blockStates)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

counterfusion-0.1.1.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

counterfusion-0.1.1-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file counterfusion-0.1.1.tar.gz.

File metadata

  • Download URL: counterfusion-0.1.1.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.9.7

File hashes

Hashes for counterfusion-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6c5874ec80ad63e5e8e51e70bcb9420decdc7f52ecd1da0d47c57fd3db9cc689
MD5 e7cca95dc15a5c9c7b09671ece033f13
BLAKE2b-256 95d8773f001776a9899597babfdeba0cffdc660fe1a9d18aba23df2fb763a984

See more details on using hashes here.

File details

Details for the file counterfusion-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: counterfusion-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 12.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.9.7

File hashes

Hashes for counterfusion-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 744cafa3cad49be8a0b932ae49e493d109be9c452fea01afbb215617a8902735
MD5 ae625ff85527b82350b62190df31810e
BLAKE2b-256 d54957c07bf5a4a55f06fd718a142d99d55418d4cfde7239c7f49d012d14cab0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page