Skip to content

Instantly share code, notes, and snippets.

@Mizux
Mizux / test.cpp
Created October 25, 2024 13:47
Compile issue on x64 msvc 17 VS 2022 (19.41)
#include <iostream>
#include <cstdint>
#include <functional>
#include <string>
#include <optional>
//using F = std::function<int(int,int)>;
template <typename RType, typename DummyType = int64_t,
typename PType = int32_t,
@Mizux
Mizux / cvrptw_pd.py
Last active July 4, 2024 14:14
CVRPTW_PD
#!/usr/bin/env python3
"""Development In Progress
CVRPTW.
or-tools == 9.9.3963
python == 3.11.7
Number of Regular Nodes = 16,
Depot Nodes = 1
@Mizux
Mizux / tsp_node_with_various_cost.py
Created February 5, 2024 09:56
TSP with node having various cost
#!/usr/bin/env python3
"""
Having a cost different if a node is visited last or along the route
"""
from ortools.constraint_solver import routing_enums_pb2
from ortools.constraint_solver import pywrapcp
def create_data_model():
@Mizux
Mizux / multi_knapsack_with_color_sat.py
Created December 5, 2023 22:10
multi knapsacks with color constraint
#!/usr/bin/env python3
"""Solve a multiple knapsack problem using the CP-SAT solver."""
from ortools.sat.python import cp_model
def main():
data = {}
data["weights"] = [48, 30, 42, 36, 36, 48, 42, 42, 36, 24, 30, 30, 42, 36, 36]
data["values"] = [10, 30, 25, 50, 35, 30, 15, 40, 30, 35, 45, 10, 20, 30, 25]
assert len(data["weights"]) == len(data["values"])
data["num_items"] = len(data["weights"])
@Mizux
Mizux / test.sh
Last active August 28, 2023 08:57
sysctl hw.optional on Apple M1
```sh
$ sysctl hw.optional
hw.optional.arm.FEAT_FlagM: 1
hw.optional.arm.FEAT_FlagM2: 1
hw.optional.arm.FEAT_FHM: 1
hw.optional.arm.FEAT_DotProd: 1
hw.optional.arm.FEAT_SHA3: 1
hw.optional.arm.FEAT_RDM: 1
hw.optional.arm.FEAT_LSE: 1
hw.optional.arm.FEAT_SHA256: 1
@Mizux
Mizux / filtering_sat.py
Last active May 23, 2023 22:18
filtering.py
#!/usr/bin/env python3
'''Simple test
'''
from ortools.sat.python import cp_model
import pandas as pd
# Define the dataframe with feature columns and the target column
data = {
'A': [1.59, 0.9, 2.82,2.44,2.61],
'B': [0.68,0.1,1.3,1.64,1.59],
@Mizux
Mizux / main.cpp
Last active October 13, 2022 22:19
c++ read/write to a file
#include <cstdio>
#include <iostream>
#include <filesystem>
#include <fstream>
namespace fs = std::filesystem;
int main()
{
const std::string filename = std::tmpnam(nullptr);
@Mizux
Mizux / vrp_vmax.py
Last active August 8, 2022 16:06
VRP with 2 Vehicles max for same physical locations
#!/usr/bin/env python3
"""Vehicles Routing Problem (VRP).
Some point are on the same physical location
No more than two vehicle to visit a physical location
"""
from ortools.constraint_solver import routing_enums_pb2
from ortools.constraint_solver import pywrapcp
@Mizux
Mizux / squirrel3.js
Created August 5, 2022 14:29 — forked from psema4/squirrel3.js
An implementation of the Squirrel3 Noise-based RNG
// Based on the GDC 2017 talk "Math for Game Programmers: Noise-Based RNG"
// https://www.youtube.com/watch?v=LWFzPP8ZbdU&ab_channel=GDC
const BIT_NOISE1 = 0xB5297A4D
const BIT_NOISE2 = 0x68E31DA4
const BIT_NOISE3 = 0x1B56C4E9
const PRIME1 = 198491317
const PRIME2 = 6542989
class Squirrel3 {
@Mizux
Mizux / hack-a-digital-card-game.markdown
Created July 25, 2022 13:53
Hack. A digital card game