Skip to content

Instantly share code, notes, and snippets.

@hros
hros / gist:cce27480b50bd7fe20a286554cf054fd
Created November 13, 2023 17:00
poetry-pyproject.toml
[tool.poetry]
name = "tproj"
version = "0.1.0"
description = ""
authors = ["Your Name <you@example.com>"]
readme = "README.md"
[tool.poetry.dependencies]
python = "^3.11"
@hros
hros / mergeshuffle.jl
Last active July 11, 2020 23:46
julia version of mergeshuffle
using Random: AbstractRNG, GLOBAL_RNG, MersenneTwister,shuffle!; import Future
using Base.Threads: nthreads, threadid
using BenchmarkTools
println("nthreads = $(nthreads())")
PAR_RNG = let m = MersenneTwister(1)
[m; accumulate(Future.randjump, fill(big(10)^20, nthreads() - 1), init = m)]
end;
@hros
hros / cxx_eq.jl
Created July 1, 2019 10:14
Julia Cxx issue with operator==
using Cxx
cxx"""
class A{
private:
int a;
public:
A(int n) : a(n) {}
friend int operator==(const A& x, const A& y);
A operator+(const A& other) const {return A(a+other.a);}
@hros
hros / ed_milp.py
Last active October 13, 2018 21:19
from typing import Dict, Tuple, List
from math import ceil
import gurobipy as grb
from gurobipy import GRB
from simulation import Scenario, \
cost_of_preemption, risk_of_adverse_outcome, \
Patient, SubVisit
# a helper dictionary to iterate over each treatment visit of patients
# a patient with two visit will result in two keys: (p,0), (p,1)
@hros
hros / offline_mip.py
Last active December 4, 2017 08:57
MIP solution to offline scheduling of generalized Rm|rj,prmp|\sum w_j U_j
from gurobipy import *
# inputs to code snippet:
# m - gurobi model object
# s - a scenario object containing the tasks' and agents' parameters (self explanatory)
N = s.num_tasks
C = s.num_agents
# add one time step to time range to simplify preemption constraints
t_range = range(s.t_range[0], s.t_range[-1] + 2)
# agent dependent task processing time ($j_p /\eta^i_{j_\tau}$)