# 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) |
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:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- 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.
- 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.
$ 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 |
$ 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 |
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.
There is a constraint of the form \sum a_1 y + \sum a_2 y <= 10.01
. Values of a_1 and a_2 are chosen such that 10 a_1 + 8 a_2 == 10.004 < 10.01
and 10 a_1 + 9 a_2 == 10.349 > 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 |
Time Quantity | |
0 0 | |
1 99000 | |
2 99000 | |
3 198000 | |
4 198000 | |
5 297000 | |
6 297000 | |
7 396000 | |
8 396000 |