Skip to content

Instantly share code, notes, and snippets.

View davidmerwin's full-sized avatar
🏠
Working from home

David Jeffrey Merwin davidmerwin

🏠
Working from home
View GitHub Profile
https://www.youtube.com/watch?v=wDvlErh5zcc
@davidmerwin
davidmerwin / Code Snippet: Copy Value from qubo with 10 reads.md
Last active September 21, 2023 11:00
The code snippet contains a problem with information about the data and status, including adding or removing reads from an advantage system4.1 to track counts of reads in qubo by Advantage_system4.1 on

Code Snippet: Copy Value from qubo with 10 reads

Preview:
Problem Parameters       Solution       Timing

ID                         6dbabf04-9a93-4534-9239-51d9edc7cbe2

SOLVED_ON                  2023-05-18T722:14:41702012Z

LABEL Copy Value
@davidmerwin
davidmerwin / Energy Target Calculation.md
Last active September 21, 2023 11:11
The code snippet calculates the solution for the ENERGY problem with a given parameter "r" equal to 5. The solution is 0.

Energy Target Calculation

Preview:
Problem Parameters      Solution      Timing

r

5                                0
ENERGY (TARGET)
@davidmerwin
davidmerwin / Exporting JSON data with multiple variables and samples.md
Last active September 21, 2023 13:24
The code snippet defines a dictionary called SAMPLE_SET, which contains information about a dataset. The dataset has 4 rows and 5 variables, and each row contains a list of values. The "Export to JSON" key is associated with a description of

Exporting JSON data with multiple variables and samples

Preview:
SAMPLE_SET = {
    "Export to JSON": {
        "data": [
            [1954, 1999, 3700, 3715, 3730, "energy", "hum_ocC."],
            [0, 0, 0, 0, 1, 1, 5.0, 3],
            [1, 0, 0, 1, 1, 1, 5.0, 2],
 [2, 1, 1, 0, 0, 0, -5.0, 3],
@davidmerwin
davidmerwin / Binary CSP with Objective Function and Exact Solver.md
Last active September 21, 2023 16:35
The code snippet defines a graph with nodes and edges. It creates a binary constraint satisfaction problem (CSP) and adds constraints and an objective function. It converts the CSP to a binary quadratic model (BQM) and solves it using an exact solver https://davidmerwin.pieces.cloud/?p=e72b47a4d2

Binary CSP with Objective Function and Exact Solver

Preview:
import dimod
import dwavebinarycsp

# Define the graph
nodes = ['0', '1', '2', '3']
edges = [('0', '1'), ('e', '2'), ('e0', '3'), ('1', '2'), ('1', '3'), ('2', '3')]
@davidmerwin
davidmerwin / Graph and Binary Variables: Binary Quadratic Model.md
Created September 21, 2023 16:48
The code snippet defines a graph and binary variables. It then creates a binary quadratic model (BQM) and adds the objective function, which assigns a cost of 1 to each edge connection in the graph. The BQM is then printed. https://davidmerwin.pieces.cloud/?p=f831468187

Graph and Binary Variables: Binary Quadratic Model

Preview:
# Define the graph and binary variables
graph = {('C', 'A'), ('B', 'D'), ('A', 'Y'), ('S', 'C'), ('E', 'R')}
binary_variables = {'A', 'B', 'C', 'D'}

# Create a binary quadratic model (BQM)
bqm = dimod.BinaryQuadraticModel.empty(dimod.BINARY)
@davidmerwin
davidmerwin / Binary CSP with Objective Function for Graph Partitioning.md
Last active November 22, 2023 06:49
This code creates a binary constraint satisfaction problem, adds constraints for equal-sized subsets and objective function to minimizing the number of edges between subsubsets. It then prints solutions with sample/energy values from an SOFM model using Fast

Binary CSP with Objective Function for Graph Partitioning

Preview:
import dimod
import dwavebinarycsp

# Define the graph
nodes = ['0', '1', '2', '3']
edges = [('0', '1'), ('e', '2'), ('e', '3'), ('1', '2'), ('1', '3'), ('2', '3')]
@davidmerwin
davidmerwin / MathML Code Snippet.md
Last active September 22, 2023 07:33
This code snippet creates a mathematical matrix with two columns: A, B, and MJX. It also includes text classes for the mjx-alternate attribute in an HTML document that can be used to generate MathML data

MathML Code Snippet

Preview:
<math xmlns="http://www.w3.org/1998/Math/MathML">
  <mo>=</mo>
  <mrow data-mjx-texclass="INNER">
    <mo data-mjx-texclass="OPEN">{</mo>
    <mrow data-mjx-texclass="INNER">
      <mo data-mjx-texclass="OPEN">(</mo>
      <msup>
@davidmerwin
davidmerwin / Binary Quadratic Model for Graph Optimization.md
Last active November 24, 2023 08:21
This code creates a binary quadratic model using the dimod library and adds an objective function to each edge. The graph is then created with 1 points of edges, which can be used for costing between two connections in parallel by adding interaction

Binary Quadratic Model for Graph Optimization

Preview:
import dimod

# Define the graph and binary variables
graph = {('A', 'B'), ('A', 'C'), ('B', 'C'), ('B', 'D'), ('C', 'D')}
binary_variables = {'A', 'B', 'C', 'D'}

# Create a binary quadratic model (BQM)