Skip to content

Instantly share code, notes, and snippets.

@JackDunnNZ
JackDunnNZ / cbc.bat
Created July 21, 2014 21:50
OpenSolver CBC Crash
@echo off
"D:\Jack\Dropbox\Scratch\OpenSolver\OpenSolver\cbc64.exe" -directory C:\Users\Jack\AppData\Local\Temp\ -import "C:\Users\Jack\AppData\Local\Temp\model.lp" -ratioGap .05 -seconds 100 -solve -printingOptions all -solution C:\Users\Jack\AppData\Local\Temp\modelsolution.txt -printingOptions rhs -solution rhsranges.txt -printingOptions objective -solution costranges.txt
g3 1 1 0
1604 1204 1 0 1204 0
400 0
0 0
1604 0 0
0 0 0 0
0 0 0 0 0
4804 1
0 0
0 0 0 0 0
@JackDunnNZ
JackDunnNZ / gist:917ad455b290161ed59d
Last active August 29, 2015 14:24
OpenSolver API example
Sub Model_Creation()
Dim TestSheet As Worksheet
Set TestSheet = Sheets("test")
OpenSolver.ResetModel Sheet:=TestSheet
'Objective Definition
OpenSolver.SetObjectiveFunctionCell TestSheet.Cells(1, 1), Sheet:=TestSheet
OpenSolver.SetObjectiveSense MinimiseObjective, Sheet:=TestSheet
@JackDunnNZ
JackDunnNZ / gist:d29684f1a97a64ccd946
Created July 7, 2015 15:47
Building variable range incrementally using OpenSolver API
Sub Test()
Set TestSheet = Sheets("Test")
OpenSolver.ResetModel TestSheet
AddVariables Range("A2"), TestSheet
AddVariables Range("B3"), TestSheet
End Sub
Sub AddVariables(VariableRange As Range, Sheet As Worksheet)
Dim CurrentVariables As Range
Set CurrentVariables = OpenSolver.GetDecisionVariablesWithDefault(Sheet)
@JackDunnNZ
JackDunnNZ / example.tex
Last active September 10, 2015 14:22
Latex optimization example
$\begin{array}{rlllllllll}
\min& \sum\limits_{j=1}^7 x_j \\
{\rm s.t.} &x_1 + & & & x_4 + & x_5 + & x_6 + & x_7 & \geq & d_1 \\
&x_1 + & x_2 & & & x_5 + & x_6 + & x_7 & \geq & d_2 \\
&x_1 + & x_2 + & x_3 & & & x_6 + & x_7 & \geq & d_3 \\
&x_1 + & x_2 + & x_3 + & x_4 + & & & x_7 & \geq & d_4 \\
&x_1 + & x_2 + & x_3 + & x_4 + & x_5 & & & \geq & d_5 \\
& & x_2 + & x_3 + & x_4 + & x_5 + & x_6 & & \geq & d_6 \\
& & & x_3 + & x_4 + & x_5 + & x_6 + & x_7 & \geq & d_7 \\
& x_j \geq 0 & & & & & & & &
@JackDunnNZ
JackDunnNZ / Output from wantsol=4
Created September 12, 2015 13:33
Ipopt duals via .nl
Ipopt 3.12.0: Optimal Solution Found
constraint dual value
_scon[1] 22089.391601562464
_scon[2] 22089.39160156247
@JackDunnNZ
JackDunnNZ / user.css
Created March 28, 2016 16:53
Userstyle to add 80-character ruler for Google Apps Script Editor. Use with Stylish
.CodeMirror-lines > div > div:last-child {
width: 80ch;
background-color: rgba(211,211,211, 0.2);
}
@JackDunnNZ
JackDunnNZ / SimpleLP.bas
Last active May 5, 2016 13:02
Example of constructing a model with OpenSolver API
Option Explicit
Function Test()
Dim Sheet as Worksheet
Set Sheet = ThisWorkbook.Sheets("Sheet1")
OpenSolver.ResetModel Sheet
OpenSolver.SetDecisionVariables Sheet.Range("D4:F4"), Sheet
OpenSolver.SetObjectiveFunctionCell Sheet.Range("H6"), Sheet
OpenSolver.AddConstraint Sheet.Range("H8:H9"), RelationLE, Sheet.Range("J8:J9"), sheet:=Sheet
@JackDunnNZ
JackDunnNZ / test.jl
Created November 2, 2016 22:43
Gurobi 7.0 solution pool proof of concept via Gurobi.jl
using Gurobi, JuMP
# New versions of getvalue, getobjectivevalue for solution pool
"Get the variable values for the `solnumber`th solution in the pool"
function grb_get_xn(m::JuMP.Model, solnumber::Int)
g = getrawsolver(m)
Gurobi.set_int_param!(g, "SolutionNumber", solnumber - 1)
Gurobi.get_dblattrarray(g, "Xn", 1, Gurobi.num_vars(g))
end
--- /Users/jack/Downloads/glm/glmnet5dpclean.f.txt
+++ /Users/jack/Downloads/glm/glmnet5.f90.txt
@@ -1,9 +1,6 @@
- mortran 2.0 (version of 7/04/75 mod 7/4/87 (ajc))
- subroutine get_int_parms(sml,eps,big,mnlam,rsqmax,pmin,exmx,itrace
-*)
- implicit double precision(a-h,o-z)
- data sml0,eps0,big0,mnlam0,rsqmax0,pmin0,exmx0,itrace0 /1.0d-5,1.
-*0d-6,9.9d35,5,0.999,1.0d-9,250.0,0/
+ subroutine get_int_parms(sml,eps,big,mnlam,rsqmax,pmin,exmx)