Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew Powell andrewandrepowell

View GitHub Profile
@andrewandrepowell
andrewandrepowell / gplk_sample_0.cpp
Last active Oct 4, 2016
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.
View gplk_sample_0.cpp
/* 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:
@andrewandrepowell
andrewandrepowell / gmpl_mcfp_cl.mod
Last active Nov 14, 2018
Solves the Multicommodity Flow Problem for Concurrent Flow with GNU MathProg.
View gmpl_mcfp_cl.mod
# 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_script.m
Last active Jul 29, 2020
Solves the Concurrent Flow variant of the Multi-Commodity Flow Problem in MATLAB with linprog.
View mcfp_cf_script.m
%% 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 / mcfp_cf_lp_lemon_glpk.cc
Last active Oct 9, 2016
Solves the Concurrent Flow variant of the Multi-Commodity Flow Problem with GLPK via LEMON interface.
View mcfp_cf_lp_lemon_glpk.cc
/*
* 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 / mcfp_cf_itermaxflow_lemon.cc
Last active Oct 24, 2016
Solves the Concurrent Flow variant of the Multi-Commodity Flow Problem with an iterative algorithm, which breaks down the problem into Maximum Flow Problems.
View mcfp_cf_itermaxflow_lemon.cc
/**
* @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 Oct 13, 2016
Solves a Time Division Multiplexing Concurrent Flow variant of the Multi Commodity Flow Problem in MATLAB.
View matlab_mcfp_cf_tdm_lp.m
%% 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 / Build_GLPK_with_MinGW.bat
Last active Jun 17, 2021
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".
View Build_GLPK_with_MinGW.bat
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 Sep 19, 2020
Beginnings of Dual Universe scripting. Will become more organized later.
View starting_craft_management.lua
--
Item = {
-- Create a new Item.
new = function(name)
name = name or "none"
assert(type(name)=="string")
return {
name = name,
ingredients = false,
produced = false,