Skip to content

Instantly share code, notes, and snippets.

View davidagold's full-sized avatar

David Gold davidagold

View GitHub Profile
@davidagold
davidagold / metamerge.jl
Last active August 29, 2015 14:20
Merge two functions from different modules
function metamerge(f::Function, modulef::Module, g::Function, moduleg::Module, h::Function)
# Generate arrays of Method objects for f, g
const fmethods = methods(f, (Any...))
const gmethods = methods(g, (Any...))
# println(gmethods)
# Generate arrays of method signatures for f, g.
# Note that the 'sig' field of a Method is a tuple of types.
@davidagold
davidagold / simplexmethod.jl
Last active August 29, 2015 14:18
Perform the simplex method on a linear programming problem in canonical form
function simplex() # (A::Array{Float64, 2}, b::Array{Float64, 1}, c::Array{Float64, 1})
# Initialize the constraint matrix A, constraint vector b, objective function c
# In the future these will be passed as arguments to simplex()
A = Float64[4 2 5 15 4; 1 4 5 1 2; 1 0 3 1 11]
b = Float64[17, 9, 16]
c = Float64[15, 4, 10, 11, 27]
println("We first find a basic feasible solution to the given problem (or show that none exists).")
# Perform Phase I on given problem