Skip to content

Instantly share code, notes, and snippets.

@gidden
gidden / thiel.md
Last active February 17, 2016 16:52
math talk

$S = -k \sum_{n \in N} p_n \ln p_n$

@gidden
gidden / sum.py
Created January 18, 2016 20:23
sum of squares
# given an array of data called x:
import numpy as np
sum_of_squares = np.sum(x ** 2)
# if your data is in a list, not a numpy array:
sum_of_squares = np.sum(np.array(x) ** 2)
@gidden
gidden / LICENSE.RST
Last active September 30, 2015 15:22
MPS to LP Format

Copyright (c) 2015, Matthew Gidden All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
@gidden
gidden / gist:542c3005b6d5139a5c58
Created August 19, 2015 17:54
go get cyan failure
$ go get github.com/rwcarlsen/cyan/cmd/cyan
package github.com/rwcarlsen/cyan/cmd/cyan
imports runtime: C source files not allowed when not using cgo: atomic_amd64x.c defs.c float.c heapdump.c lfstack.c malloc.c mcache.c mcentral.c mem_linux.c mfixalloc.c mgc0.c mheap.c msize.c os_linux.c panic.c parfor.c proc.c runtime.c signal.c signal_amd64x.c signal_unix.c stack.c string.c sys_x86.c vdso_linux_amd64.c
import cycle not allowed
package github.com/rwcarlsen/cyan/cmd/cyan
imports github.com/rwcarlsen/cyan/Godeps/_workspace/src/code.google.com/p/go-uuid/uuid
imports net
imports runtime/cgo
imports runtime/cgo
@gidden
gidden / gist:2329b706ec716511b339
Created August 3, 2015 19:42
cyclus.github.com docker error
$ docker build -t cyclus/site .
Sending build context to Docker daemon 111 MB
Sending build context to Docker daemon
Step 0 : FROM cyclus/cycamore
---> c9e8370a5885
Step 1 : RUN apt-get -y --force-yes update
---> Using cache
---> 510880db9298
Step 2 : RUN apt-get install -y wget
---> Using cache
@gidden
gidden / README.md
Last active August 29, 2015 14:24
CBC 2.8.7 Constraint Violation

Setup

This is a network flow representation within a simulation. Binary variables represent real flows and linear variables represent "fake" slack flows (to guarantee feasibility). Everything is automatically generated based on the simulation context, so in this very simple example there are constraints that appear which are superfluous, e.g., 0 <= y <= 1 is superfluous with y \in {0, 1}. There are 20 binary variables in two categories (supplier 1, supplier 2) and 20 linear variables.

Issue

There is a constraint of the form \sum a_1 y + \sum a_2 y &lt;= 10.01. Values of a_1 and a_2 are chosen such that 10 a_1 + 8 a_2 == 10.004 &lt; 10.01 and 10 a_1 + 9 a_2 == 10.349 &gt; 10.01. However, the solution reported by CBC is setting all supplier 1 variables to 1 and 9 supplier 2 variables to 1, which violates the constraint. I would expect only 8 supplier 2 variables to be set to 1.

H/W path Device Class Description
====================================================
system MacBookAir6,2 (System SKU#)
/0 bus Mac-7DF21CB3ED6977E5
/0/0 processor Intel(R) Core(TM) i5-4260U CPU @ 1.40GHz
/0/0/2 memory 64KiB L1 cache
/0/0/3 memory 512KiB L2 cache
/0/0/4 memory 3MiB L3 cache
/0/1 memory 64KiB L1 cache
/0/5 memory 4GiB System Memory
H/W path Device Class Description
====================================================
system MacBookAir6,2 (System SKU#)
/0 bus Mac-7DF21CB3ED6977E5
/0/0 processor Intel(R) Core(TM) i5-4260U CPU @ 1.40GHz
/0/0/2 memory 64KiB L1 cache
/0/0/3 memory 512KiB L2 cache
/0/0/4 memory 3MiB L3 cache
/0/1 memory 64KiB L1 cache
/0/5 memory 4GiB System Memory
H/W path Device Class Description
======================================================
system OptiPlex 9010 ()
/0 bus 0W2F8G
/0/0 memory 64KiB BIOS
/0/5c processor Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz
/0/5c/38 memory 256KiB L1 cache
/0/5c/39 memory 1MiB L2 cache
/0/5c/3a memory 8MiB L3 cache
/0/3b memory 16GiB System Memory
@gidden
gidden / gist:0d7ad5f4e13bd0516d33
Created June 25, 2015 16:53
cyan -db local.sqlite inv ALWR
Time Quantity
0 0
1 99000
2 99000
3 198000
4 198000
5 297000
6 297000
7 396000
8 396000