Skip to content

Instantly share code, notes, and snippets.

View mdmitry1's full-sized avatar
:atom:
🦁

Dmitry Messerman mdmitry1

:atom:
🦁
View GitHub Profile
import pytest
# Mark all tests in this directory to run forked
def pytest_collection_modifyitems(items):
for item in items:
# Check if test is in this directory
if "z3" in str(item.fspath):
item.add_marker(pytest.mark.forked)
# Configure logging for forked tests
#!/usr/bin/python3.14
# -*- coding: utf-8 -*-
import torch
import math
from hashlib import sha256
from matplotlib import pyplot as plt
def main(timeout: int=5000, size: int=100000) -> int:
dtype = torch.float
device = torch.device("cpu")
{
"version": "1.2",
"variables": [
{"label":"X1", "interface":"knob", "type":"real", "range":[0,5], "rad-abs": 0.0},
{"label":"X2", "interface":"knob", "type":"real", "range":[0,3], "rad-abs": 0.0},
{"label":"F1", "interface":"output", "type":"real"},
{"label":"F2", "interface":"output", "type":"real"}
],
"alpha": "(X1-5)*(X1-5)+X2*X2-25 and -(X1-8)*(X1-8)-(X2+3)*(X2+3)+7.7",
"objectives": {

Eggholder Function Optimization

This project demonstrates global optimization techniques using SciPy on the Eggholder function, a complex mathematical function commonly used for testing optimization algorithms.

Overview

The Eggholder function is a challenging optimization problem with many local minima, making it an excellent benchmark for testing global optimization algorithms.
Eggholder function figure

Eggholder function formula

Global minimum: f(x*) = -959.6407, at x* = (512, 404.2319)

#!/usr/bin/python3.12
def visualize_quadtree(quadtree, points, query_rect=None, found_points=None,
filename="quadtree", title="Quadtree Visualization"):
"""Visualize the quadtree structure with points."""
fig, ax = plt.subplots(figsize=(12, 12))
# Draw all quadtree boundaries
boundaries = quadtree.get_all_boundaries()
for boundary in boundaries:
x = boundary.x - boundary.width/2

General Performance Comparison

VF2 advantages

VF2 tends to perform better on graphs that are sparse (fewer connections), small, or have a regular structure (e.g., 2D meshes or bounded valence graphs with low valence). In some cases, Nauty cannot find a solution for these regular graphs if they exceed a certain size (a few dozen nodes).

Nauty advantages

Nauty (via pynauty) is generally the better algorithm for dense or large randomly connected graphs.

#!/usr/bin/python3.14
import arxiv,sh
from json import load, loads, dump, dumps, JSONDecodeError
from sys import argv
from os import makedirs, listdir, getcwd
from os.path import join, isdir, isfile, realpath, dirname
from typing import List, Tuple
from pydantic import RootModel
from operator import itemgetter
from rich import print as rprint
.env
#!/usr/bin/python3.12
# coding: utf-8
# author: github.com/vuiseng9
# dependency ubt1804: graphviz libgraphviz-dev libgl1-mesa-glx
import os, sys
import pygraphviz
from glob import glob
from natsort import natsorted
from rich import print as rprint
#!/usr/bin/python3.14
"""Query GitHub API"""
from datetime import datetime
from urllib.request import urlopen
from pprint import pformat
from sys import argv
import json
from os import popen
def user_time(login):