Skip to content

Instantly share code, notes, and snippets.

@mlubin
mlubin / elec50.jl
Created June 20, 2018 20:22
demo for JuMP issue 1355
# Copyright 2018 Google LLC.
# SPDX-License-Identifier: Apache-2.0
using JuMP
splice_into_expression(ex, x) = ex
function splice_into_expression(ex::Expr, x)
if Meta.isexpr(ex, :ref)
if ex.args[1] != :x
error("Unrecognized expression $ex")
end
@mlubin
mlubin / process_and_solve.jl
Last active April 19, 2018 15:11
Script to solve root relaxations of pure 0/1 miplib problems
# Copyright 2018 Google LLC.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
@mlubin
mlubin / infeasible.jl
Created August 29, 2016 19:51
ConicIP reports infeasible, ECOS and Mosek optimal
using ECOS, ConicIP, Mosek
c = [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0
@mlubin
mlubin / dump.jld.bz2
Last active August 29, 2016 00:26
Example of slow NL writing
This file has been truncated, but you can view the full file.
@mlubin
mlubin / mosektiming.jl
Created August 24, 2016 16:13
Mosek doesn't report timings
using Mosek
b = [0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,-1.0,-10.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.2,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0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.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.
@mlubin
mlubin / fail.jl
Created August 17, 2016 02:30
Optimal problem declared dual infeasible
using ECOS, ConicIP
c = [0.163973846,0.533179677,1.09407106,0.182902458,0.554139215,0.567489093,0.731063981,0.149004507,1.64458497,0.14275369,8137.86778,2852.37715,7957.49463,11317.1837,22038.7814,9512.84638,32448.222,4601.27644,12316.0304,2771.71585,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]
b = [-16670.1538,0.0,0.0,1.41421356,0.0,0.0,1.41421356,0.0,0.0,1.41421356,0.0,0.0,1.41421356,0.0,0.0,1.41421356,0.0,0.0,1.41421356,0.0,0.0,1.41421356,0.0,0.0,1.41421356,0.0,0.0,1.41421356,0.0,0.0,1.41421356,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]
con_cones = [(:NonPos,[1]),(:Zero,[2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]),(:SOC,[32,33,34]),(:SOC,[35,36,37]),(:SOC,[38,39,40]),(:SOC,[41,42,43]),(:SOC,[44,45,46]),(:SOC,[47,48,49]),(:SOC,[50,51,52]),(:SOC,[53,54,55]),(:SOC,[56,57,58]),(:SOC,[59,60,61])]
var_cones = [(:NonNeg,[
@mlubin
mlubin / fail.jl
Created August 16, 2016 22:32
ConicIP failing to detect infeasibility
using ECOS, ConicIP
c = [-0.0314514366364,-0.140066530531,-0.101481112582,-0.0896788789081,-0.0623322546876,-0.0715007016099,-0.0414012394119,-0.0427797721554,-0.123926899062,-0.0113752176021,-0.0394797478448,-0.0442318588416,-0.0472748306646,-0.0629738483482,-0.0309081568087,-0.148705689344,-0.0377827405953,-0.0215013837744,-0.0132097716294,-0.0374431650663,-0.0654803135324,-0.127416862275,-0.0631330997176,-0.0878126089614,-0.0412963652708,-0.0191748751409,-0.0206637964956,-0.0793031051092,-0.102128665084,-0.0602494739115,-0.0646745186267,-0.188050706821,-0.00699576056141,-0.0352458247454,-0.0597094198611,-0.0572050688987,-0.0525709156995,-0.0184249616408,-0.192324736986,-0.158041803894,-0.0380825412642,-0.153319254475,-0.0479675113811,-0.0202574279786,-0.0664901393557,-0.0449016594387,-0.0210495138202,-0.045759308444,-0.0284224966367,-0.0362094771936,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.
@mlubin
mlubin / fail.jl
Last active August 16, 2016 03:01
ConicIP incorrectly reports infeasible
using ECOS, ConicIP
c = [101.694104,375.559556,242.996185,274.45252,168.179886,271.828411,286.858066,427.461022,120.942543,244.334243,299.824754,210.180312,388.892135,422.59942,286.344197,256.977626,113.64941,200.502313,329.434173,305.032801,266.014052,227.507071,348.05538,256.668778,141.252367,220.980567,300.996731,304.402129,182.737715,118.292891,328.086548,275.544938,249.30281,666.250009,129.036119,257.180466,302.986897,565.452727,213.580365,712.799593,282.103532,503.020468,112.07971,114.749608,376.581031,535.628369,61.305196,506.511515,199.884708,54.876085,318.249896,261.212247,333.560946,287.95327,308.196084,9.2809114,146.600278,378.517476,54.629471,82.980989,243.86939,379.31011,69.320146,395.511019,436.180797,729.454703,299.194726,439.267364,259.43267,504.245329,367.903981,775.329267,143.302061,286.234398,24.004148,76.187937,175.307064,275.846331,32.137771,294.815597,323.149362,499.890448,249.494355,336.089448,189.470927,331.170643,292.570164,531.886787,386.379613,352.257299,589.301628,594.297104,379.0
@mlubin
mlubin / install.md
Last active May 18, 2016 04:50
JuMP install instructions for Optimization Days/Journées de l'Optimisation 2016

Install Julia

You should use Julia 0.4.0 or later. Binaries of Julia for all platforms are available here.

  • Windows and Linux users should choose the 64-bit version, unless using a very old computer.

Install IJulia/Jupyter

Jupyter is a convenient notebook-based interface to present documents which interleave code, text, and equations.