Skip to content

Instantly share code, notes, and snippets.

View geoffleyland's full-sized avatar

Geoff Leyland geoffleyland

View GitHub Profile
@geoffleyland
geoffleyland / ortools_vrp_4_depots_14_stops.cpp
Last active February 7, 2019 08:45
Ortools RoutingModel not finding best solution to a VRP in a 14-node example
#include "or_tools_route.h"
#include "ortools/constraint_solver/routing.h"
#include <vector>
#include <cstdio>
using operations_research::RoutingModel;
#define DEPOT_COUNT 4#include "or_tools_route.h"
#include "ortools/constraint_solver/routing.h"
Vehicle codes
Code,Vehicle
C,car
T,truck
V,"van, ute"
M,motorcycle
X,taxi or taxi van
P,moped
B,bus
@geoffleyland
geoffleyland / undo-20026256-deletes.osc
Last active August 29, 2015 13:56
Undo OSM deletes
This file has been truncated, but you can view the full file.
<?xml version="1.0" encoding="UTF-8"?>
<osmChange version="0.6" generator="ugly revert script">
<create>
<node id="-673983125" version="3" timestamp="2014-02-13T04:44:04Z" uid="142831" user="Rudy355" changeset="#CHANGESET" lat="-36.8704049" lon="174.7604200">
<tag k="ref" v="8505"/>
<tag k="highway" v="bus_stop"/>
<tag k="name" v="Kelly Street"/>
</node>
</create>
<create>
@geoffleyland
geoffleyland / ray-object.lua
Created July 5, 2012 00:50
Raytrace using vector objects
local sqrt = math.sqrt
local huge = math.huge
local delta = 1
while delta * delta + 1 ~= 1 do
delta = delta * 0.5
end
-- vectors -------------------------------------------------------------------
@geoffleyland
geoffleyland / ray-stack.lua
Created July 5, 2012 00:50
Raytrace avoiding vector objects
local sqrt = math.sqrt
local huge = math.huge
local delta = 1
while delta * delta + 1 ~= 1 do
delta = delta * 0.5
end
-- vectors -------------------------------------------------------------------
@geoffleyland
geoffleyland / test_ipairs.lua
Created June 13, 2012 22:52
Lua ipairs and numeric for test
-- Changing TABLE_SIZE didn't seem to change much
local TABLE_SIZE = 10000
local ITERATIONS = (jit and 100000000 or 10000000) / TABLE_SIZE
local a = {}
for i = 1, TABLE_SIZE do
a[i] = i * i
end
local sum, start
@geoffleyland
geoffleyland / test_map_and_filter.lua
Created June 7, 2012 03:35
Map and filter without intermediate tables
-- Testing map and filter without intermediate tables
-- So far it's slower and more complicated than with those 'wasteful'
-- intermediate tables
-- If you're comparing PUC lua and luajit, note that the tests to 10 times
-- more iterations for luajit.
local TABLE_SIZE = 100
local ITERATIONS = jit and 1000000 or 100000