Skip to content

Instantly share code, notes, and snippets.

View metab0t's full-sized avatar
🚀
Work hard

Yue Yang metab0t

🚀
Work hard
  • Hefei University of Technology
  • China
  • 02:27 (UTC +08:00)
View GitHub Profile
@metab0t
metab0t / bench.py
Last active May 24, 2024 01:59
Example of pyoframe and pyoptinterface
import pandas as pd
import numpy as np
import time
from pyoframe import Model, Variable, sum
import gurobipy as gp
import pyoptinterface as poi
from pyoptinterface import gurobi
@metab0t
metab0t / test.py
Last active April 10, 2024 14:56
linopy example
import time
import numpy as np
from numpy import arange
import pyoptinterface as poi
from linopy import Model
from pyoptinterface import gurobi
def to_poi(m):
@metab0t
metab0t / result.md
Created June 8, 2022 17:27
`strtod_l` speed

The following two files represent two ways to convert string to double considering locale.

  • strtod_fast.c uses standard C runtime function
  • strtod_slow.c uses a hand written implementation

I experiment the code on 3 compilers

  1. MinGW-UCRT in msys2
$ gcc -v
@metab0t
metab0t / dll.c
Created November 16, 2020 12:34
Test Julia dlopen function
#include <windows.h>
#include <direct.h>
#include <assert.h>
#include <stdio.h>
#define _OS_WINDOWS_
int isabspath(const char *in) {
#ifdef _OS_WINDOWS_
char c0 = in[0];
if (c0 == '/' || c0 == '\\') {
#include <concepts>
template <typename T> concept CPLEXArrayLite = requires(T o)
{
{
o.getEnv()
}
->std::same_as<int>;
{
o.getSize()
@metab0t
metab0t / notes.md
Created June 16, 2020 15:26
Fix Qt issues when using PyCall.jl
@metab0t
metab0t / multinorm.py
Created May 8, 2020 00:30
Generate multivariate normal distribution samples
from scipy.stats import multivariate_normal as multinorm
import numpy as np
mean = np.zeros(3)
cov = np.eye(3)
dist = multinorm(mean=mean, cov=cov)
n_samples = 1000
samples = dist.rvs(size=n_samples)
samples.shape
# = (1000, 3)
@metab0t
metab0t / prelude.py
Last active May 6, 2020 13:01
[Snippets for matplotlib plotting] Here are some snippets I use with matplotlib #Python #matplotlib
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
matplotlib.rcParams["font.family"] = "Sarasa Gothic SC"
plt.style.use("seaborn-poster")
fig, ax = plt.subplots(figsize=(15,7.5), facecolor="w", edgecolor="k")
fig.savefig("xx.png", dpi=300, bbox_inches="tight")
@metab0t
metab0t / .clang-format
Created June 29, 2019 02:18
My clang-format config
BasedOnStyle: LLVM
IndentWidth: 4
SortIncludes: false
@metab0t
metab0t / subsetperm.cpp
Created May 18, 2019 08:07
Generate subset of a vector
#include <vector>
#include <iostream>
#include <algorithm>
using std::cout;
using std::vector;
template <typename T> void printvec(const vector<T> &vec) {
cout << "{";
for (const auto &v : vec) {