Skip to content

Instantly share code, notes, and snippets.

View andrewandrepowell's full-sized avatar

Andrew Powell andrewandrepowell

View GitHub Profile
@andrewandrepowell
andrewandrepowell / Build_GLPK_with_MinGW.bat
Last active June 17, 2021 13:28
MinGW batch and make files for building GNU Linear Programming Kit glpk-4.60. Remember to change the HOME environmental variable to the directory of MinGW. These files should be located in either "glpk-4.60/w64" or "glpk-4.60/w32".
rem Build GLPK with MinGW
rem NOTE: Make sure that HOME variable specifies correct path
set HOME="C:\TDM-GCC-64"
set PATH=%HOME%\bin;%HOME%\libexec\gcc\x86_64-w64-mingw32\5.1.0;%PATH%
copy config_MinGW config.h
%HOME%\bin\mingw32-make.exe -f Makefile_MinGW
%HOME%\bin\mingw32-make.exe -f Makefile_MinGW check
@andrewandrepowell
andrewandrepowell / starting_craft_management.lua
Last active September 19, 2020 06:44
Beginnings of Dual Universe scripting. Will become more organized later.
--
Item = {
-- Create a new Item.
new = function(name)
name = name or "none"
assert(type(name)=="string")
return {
name = name,
ingredients = false,
produced = false,
@andrewandrepowell
andrewandrepowell / mcfp_cf_script.m
Last active July 29, 2020 04:21
Solves the Concurrent Flow variant of the Multi-Commodity Flow Problem in MATLAB with linprog.
%% Solve the Multi-Commodity Flow Problem in MATLAB.
%
% The goal of this script is to solve the Concurrent-Flow variant of the
% Multi-Commodity Flow Problem ( MCFP ) with MATLAB's Linear Programming
% ( LP ) tools.
%
% The documentation generated from this script is a tex file. The PDF can
% be generated from the tex, but \usagepackage{amsmath} needs to be added
% to the tex file's preamble.
@andrewandrepowell
andrewandrepowell / gmpl_mcfp_cl.mod
Last active November 14, 2018 01:07
Solves the Multicommodity Flow Problem for Concurrent Flow with GNU MathProg.
# Multicommodity Flow Problem for Directed Networks,
## Optimized for Concurrent Flow
set V; # Vertex Set
set E, within V cross V; # Edge Set
set K; # Commodity Set
param s {K}, symbolic in V; # Source Vertex of Commodity
param t {K}, symbolic in V; # Sink Vertex of Commodity
param d {K}, >= 0; # Demand of Commodity
param c, >= 0; # Capacity of Edge
@andrewandrepowell
andrewandrepowell / mcfp_cf_itermaxflow_lemon.cc
Last active October 24, 2016 19:34
Solves the Concurrent Flow variant of the Multi-Commodity Flow Problem with an iterative algorithm, which breaks down the problem into Maximum Flow Problems.
/**
* @file mcfp_cf_itermaxflow_lemon.cc
* @author Andrew Powell
* @date Oct 9, 2016
*
* @brief Solves the Concurrent Flow variant of the Multi-
* Commodity Flow Problem.
*
* In this example, the Concurent Flow variant
* of the Multi-Commodity Flow Problem is solved with
@andrewandrepowell
andrewandrepowell / matlab_mcfp_cf_tdm_lp.m
Last active October 13, 2016 18:06
Solves a Time Division Multiplexing Concurrent Flow variant of the Multi Commodity Flow Problem in MATLAB.
%% Solve the Time Division Multiplexing variant of the Multi Commodity Flow Problem in MATLAB.
%
% The goal of this script is to solve the Multi Commodity Flow Problem
% modified for Time Division Multiplexing ( TDM ) as seen in Contention
% Free Routing ( CFR ). The Multi Commodity Flow Problem is solved for the
% Concurrent Flow variant ( MCFP-CF ) with mixed-integer linear programming
% ( MILP ).
%
% The documentation generated from this script is a tex file. The PDF can
% be published from the tex, but \usagepackage{amsmath} needs to be added
@andrewandrepowell
andrewandrepowell / mcfp_cf_lp_lemon_glpk.cc
Last active October 9, 2016 22:57
Solves the Concurrent Flow variant of the Multi-Commodity Flow Problem with GLPK via LEMON interface.
/*
* mcfp_cf_lp_lemon_glpk.cc
* LEMON provides a simple interface to known solvers! In
* this example the Concurrent Flow variant of the
* Multi-Commodity Flow Problem is solved with the glpk
* solver.
*
* The following libraries are needed to run this application:
*
* lemon
@andrewandrepowell
andrewandrepowell / gplk_sample_0.cpp
Last active October 4, 2016 00:09
Solves a basic linear programming problem with the GPLK ( GNU MathProg ) API. Don't really see too many examples online, so I plan to add a bunch of these.
/* Purpose: Solves the following GNU MathProg program:
*
var x;
var y;
s.t. A: x + 2*y <= 14;
s.t. B: 3*x - y >= 0;
s.t. C: x - y <= 2;
maximize z: 3*x + 4*y;
*
* References: