<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" version="2.0">

<channel>
	<title>Computers and Buildings</title>
	
	<link>http://computersandbuildings.com</link>
	<description>Programming energy-efficient buildings</description>
	<lastBuildDate>Thu, 26 Apr 2012 07:00:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/computersandbuildings" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="computersandbuildings" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Selenium script to reset a ZyXEL NBG4115 4G Router</title>
		<link>http://computersandbuildings.com/2012/04/selenium-script-to-reset-a-zyxel-nbg4115-4g-router/</link>
		<comments>http://computersandbuildings.com/2012/04/selenium-script-to-reset-a-zyxel-nbg4115-4g-router/#comments</comments>
		<pubDate>Thu, 26 Apr 2012 07:00:33 +0000</pubDate>
		<dc:creator>lindelof</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://computersandbuildings.com/?p=603</guid>
		<description><![CDATA[The ZyXEL NBG4115 is a small, cheap 3G router that can be used to build a wireless network where there is no access point available. You plug one of those 3G dongles into it, enter the PIN number, and you have a local access point in the middle of nowhere. At Neurobat we use these [...]
No related posts.]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://www.steg-electronics.ch/fr/article/zyxel-nbg4115-184952.aspx?doprint=yes">ZyXEL NBG4115</a> is a small, cheap 3G router that can be used to build a wireless network where there is no access point available. You plug one of those 3G dongles into it, enter the PIN number, and you have a local access point in the middle of nowhere. At <a href="http://neurobat.net">Neurobat</a> we use these devices whenever we require internet access to a test site that cannot have internet access otherwise.</p>
<div id="attachment_604" class="wp-caption alignnone" style="width: 297px"><a href="http://computersandbuildings.com/wp-content/uploads/2012/04/ZY_NBG4115_2524_F72.jpg"><img class="size-medium wp-image-604" title="ZyXEL NBG4115 Wireless N-lite 3G Router" src="http://computersandbuildings.com/wp-content/uploads/2012/04/ZY_NBG4115_2524_F72-287x300.jpg" alt="" width="287" height="300" /></a><p class="wp-caption-text">ZyXEL NBG4115 Wireless N-lite 3G Router</p></div>
<p>One problem we ran into very early on, however, is that the 3G connection provided by Swisscom tends to be, to put it charitably, flaky. Indeed, we have never had a single connection remain alive for more than a week. We have spoken with their tech support, upgraded the firmware on the 3G dongles, all to no avail. As a final solution we decided to write scripts on the local netbooks that would regularly (say, once every three hours) reset the connection through the router&#8217;s administrative web interface.</p>
<p>Only problem was that none of the &#8220;easy&#8221; screen-scraping tools out there (<code>wget</code>, Python&#8217;s <code>urllib</code>, etc) was Javascript-capable&#8212;which is something the web interface would detect, and refuse any client that was not Javascript-enabled.</p>
<div id="attachment_605" class="wp-caption alignnone" style="width: 310px"><a href="http://computersandbuildings.com/wp-content/uploads/2012/04/IMG_6575.jpg"><img class="size-medium wp-image-605" title="3G Router on a test site" src="http://computersandbuildings.com/wp-content/uploads/2012/04/IMG_6575-300x200.jpg" alt="" width="300" height="200" /></a><p class="wp-caption-text">3G Router on a test site</p></div>
<p>In the end we decided to install a <a href="http://seleniumhq.org/">Selenium</a> server on each netbook, and wrote a Python script that would talk to the Selenium server and reset the router. If this can help anyone, here is the (simple) Python script to reset a ZyXEL 3G router through Selenium, assuming a Selenium server has been started and is listening on port 4444:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#!/usr/bin/env python </span>
<span style="color: #ff7700;font-weight:bold;">from</span> selenium <span style="color: #ff7700;font-weight:bold;">import</span> webdriver 
browser = webdriver.<span style="color: black;">Remote</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;http://localhost:4444/wd/hub&quot;</span>, webdriver.<span style="color: black;">DesiredCapabilities</span>.<span style="color: black;">HTMLUNIT</span><span style="color: black;">&#41;</span> 
<span style="color: #808080; font-style: italic;"># Login </span>
browser.<span style="color: black;">get</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;http://192.168.1.1&quot;</span><span style="color: black;">&#41;</span> 
pass_field = browser.<span style="color: black;">find_element_by_name</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;textfield&quot;</span><span style="color: black;">&#41;</span> 
pass_field.<span style="color: black;">clear</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> 
pass_field.<span style="color: black;">send_keys</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;*****&quot;</span><span style="color: black;">&#41;</span> 
pass_field.<span style="color: black;">submit</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> 
<span style="color: #808080; font-style: italic;"># Click restart </span>
<span style="color: #ff7700;font-weight:bold;">try</span>: 
    browser.<span style="color: black;">get</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;http://192.168.1.1/mtenrestart.html&quot;</span><span style="color: black;">&#41;</span> 
<span style="color: #ff7700;font-weight:bold;">except</span>: 
    <span style="color: #ff7700;font-weight:bold;">pass</span> button = browser.<span style="color: black;">find_element_by_name</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'apply'</span><span style="color: black;">&#41;</span> 
button.<span style="color: black;">click</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>And here is the Bash script that controls it all, and that we call from a cronjob:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash </span>
<span style="color: #007800;">TOOLS</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">dirname</span> <span style="color: #007800;">$0</span><span style="color: #000000; font-weight: bold;">`</span> 
<span style="color: #666666; font-style: italic;"># Start Selenium server </span>
java <span style="color: #660033;">-jar</span> <span style="color: #007800;">$TOOLS</span><span style="color: #000000; font-weight: bold;">/</span>selenium-server-standalone.jar <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">&amp;</span> 
<span style="color: #007800;">SELENIUM</span>=<span style="color: #007800;">$!</span> 
<span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #000000;">10</span> 
<span style="color: #666666; font-style: italic;"># Reset router </span>
<span style="color: #007800;">$TOOLS</span><span style="color: #000000; font-weight: bold;">/</span>restart_zyxel.py 
<span style="color: #666666; font-style: italic;"># Kill Selenium </span>
<span style="color: #c20cb9; font-weight: bold;">kill</span> <span style="color: #007800;">$SELENIUM</span></pre></div></div>

<p>If you find this to be of use I&#8217;d be happy to hear from you in the comments below.</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://computersandbuildings.com/2012/04/selenium-script-to-reset-a-zyxel-nbg4115-4g-router/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Floating-point woes, part 1</title>
		<link>http://computersandbuildings.com/2012/03/floating-point-woes-part-1/</link>
		<comments>http://computersandbuildings.com/2012/03/floating-point-woes-part-1/#comments</comments>
		<pubDate>Mon, 12 Mar 2012 09:01:45 +0000</pubDate>
		<dc:creator>lindelof</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://computersandbuildings.com/?p=590</guid>
		<description><![CDATA[You may have several decades of programming experience, certain classes of problems seem to repeatedly cause endless confusion. Floating-point computation is one such class. I&#8217;ve been doing a fair amount of numerical analysis these past few months, implementing floating-point calculations on embedded platforms. In the process I&#8217;ve stumbled across a few programming gotchas which I&#8217;d [...]
No related posts.]]></description>
			<content:encoded><![CDATA[<p>You may have several decades of programming experience, certain classes of problems seem to repeatedly cause endless confusion. Floating-point computation is one such class.</p>
<p>I&#8217;ve been doing a fair amount of numerical analysis these past few months, implementing <a class="zem_slink" title="Floating point" href="http://en.wikipedia.org/wiki/Floating_point" rel="wikipedia" target="_blank">floating-point</a> calculations on embedded platforms. In the process I&#8217;ve stumbled across a few programming gotchas which I&#8217;d like to document in a (hopefully short) series of posts. I think that some of them are highly non-trivial, and that no amount of prior lecturing and/or reading (such as Goldberg&#8217;s excellent _<a href="http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html" target="_blank">What Every Computer Scientist Should Know About Floating-Point</a>_ paper), there are still some issues that might surprise any programmer. I begin with a relatively simple and well-known example drawn from the programming class I teach.</p>
<p>(All the code examples in this series are available from git@github.com:dlindelof/fpwoes.git)</p>
<p>Termination criteria for a square-root calculating routine<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>Consider this program for calculating square roots by <a class="zem_slink" title="Newton's method" href="http://en.wikipedia.org/wiki/Newton%27s_method" rel="wikipedia" target="_blank">Newton&#8217;s method</a>:</p>
<p>    &#8220;sqrt1.c&#8221;:<br />
    #include <stdlib.h><br />
    #include <stdio.h></p>
<p>    #define EPS 0.000001</p>
<p>    static float fabsf(float x) {<br />
      return x < 0 ? -x : x;<br />
    }</p>
<p>    static int sqrt_good_enough(float x, float guess) {<br />
      return fabsf(guess*guess - x) < EPS;<br />
    }</p>
<p>    static float sqrt_improve(float guess, float x) {<br />
      return (guess + x/guess)/2;<br />
    }</p>
<p>    static float sqrt_iter(float x, float guess) {<br />
      if (sqrt_good_enough(x, guess))<br />
        return guess;<br />
      else<br />
        return sqrt_iter(x, sqrt_improve(guess, x));<br />
    }</p>
<p>    float sqrt(float x) {<br />
      return sqrt_iter(x, 1.0f);<br />
    }</p>
<p>    int main(int argc, char** argv) {<br />
      float x = atof(argv[1]);<br />
      printf("The square root of %.2f is %.2f\n", x, sqrt(x));<br />
      return 0;<br />
    }</p>
<p>This program works well enough with arguments smaller than about 700. Above that value, one gets segmentation faults:</p>
<p>    $ ./sqrt1 600<br />
    The square root of 600.00 is 24.49<br />
    $ ./sqrt1 1000<br />
    Segmentation fault </p>
<p>Debugging the progam under `gdb` shows that a stack overflow happened:</p>
<p>    $ gdb ./sqrt1<br />
    Reading symbols from /home/dlindelof/Dropbox/Projects/fpwoes/sqrt1...done.<br />
    (gdb) run 1000<br />
    Starting program: /home/dlindelof/Dropbox/Projects/fpwoes/sqrt1 1000</p>
<p>    Program received signal SIGSEGV, Segmentation fault.<br />
    fabsf (x=Cannot access memory at address 0x7fffff7feff4<br />
    ) at sqrt1.c:6<br />
    6	static float fabsf(float x) {<br />
    (gdb) bt<br />
    #0  fabsf (x=Cannot access memory at address 0x7fffff7feff4<br />
    ) at sqrt1.c:6<br />
    #1  0x00000000004005aa in sqrt_good_enough (x=1000, guess=31.622776) at sqrt1.c:11<br />
    #2  0x0000000000400610 in sqrt_iter (x=1000, guess=31.622776) at sqrt1.c:19<br />
    #3  0x000000000040063a in sqrt_iter (x=1000, guess=31.622776) at sqrt1.c:22<br />
    #4  0x000000000040063a in sqrt_iter (x=1000, guess=31.622776) at sqrt1.c:22<br />
    #5  0x000000000040063a in sqrt_iter (x=1000, guess=31.622776) at sqrt1.c:22<br />
    #6  0x000000000040063a in sqrt_iter (x=1000, guess=31.622776) at sqrt1.c:22<br />
    #7  0x000000000040063a in sqrt_iter (x=1000, guess=31.622776) at sqrt1.c:22<br />
    #8  0x000000000040063a in sqrt_iter (x=1000, guess=31.622776) at sqrt1.c:22<br />
    #9  0x000000000040063a in sqrt_iter (x=1000, guess=31.622776) at sqrt1.c:22<br />
    #10 0x000000000040063a in sqrt_iter (x=1000, guess=31.622776) at sqrt1.c:22</p>
<p>What's happening should be quite clear here. The best estimate for the square root of 1000 in single precision is 31.622776, whose square is 999.999939, differing from 1000 by about 6.1e-5, i.e. way more than the specified tolerance of 1e-6. But it is the best approximation that can be represented in single precision. In hex, it is `0x41fcfb72`. One least-significant bit (LSB) less, or `0x41fcfb71`, represents 31.6227741 whose square is 999.999817, off by 18.3e-5. One LSB more is `0x41fcfb73` or 31.6227779, whose square is 1000.00006, off by 6.1e-5, i.e. the same difference as for 31.622776. 31.622776 is therefore the best approximation to the square root of 1000 with single-point precision.</p>
<p>To have the program terminate instead of entering an infinite loop we need to rethink the termination criteria. Obviously we cannot use an absolute difference between the square of our guess and the argument, for as we have just seen, for large values it might not be possible to get an answer whose square is close enough to the argument.</p>
<p>We could imagine using a _relative_ difference instead:</p>
<p>    static int sqrt_good_enough(float x, float guess) {<br />
      return fabsf(guess*guess - x) / x < EPS;<br />
    }</p>
<p>This gives us a second program `sqrt2.c`, which works much better:</p>
<p>    $ ./sqrt2 1000<br />
    The square root of 1000.00 is 31.62<br />
    $ ./sqrt2 5<br />
    The square root of 5.00 is 2.24<br />
    $ ./sqrt2 2<br />
    The square root of 2.00 is 1.41<br />
    $ ./sqrt2 1<br />
    The square root of 1.00 is 1.00<br />
    $ ./sqrt2 100000<br />
    The square root of 100000.00 is 316.23<br />
    $ ./sqrt2 10000000<br />
    The square root of 10000000.00 is 3162.28<br />
    $ ./sqrt2 1000000000<br />
    The square root of 1000000000.00 is 31622.78<br />
    $ ./sqrt2 0.5<br />
    The square root of 0.50 is 0.71<br />
    $ ./sqrt2 0.1<br />
    The square root of 0.10 is 0.32<br />
    $ ./sqrt2 0.01<br />
    The square root of 0.01 is 0.10<br />
    $ ./sqrt2 0.05<br />
    The square root of 0.05 is 0.22</p>
<p>Interestingly, Kernighan and Plauger (in their clasic _The Elements of Programming Style_) deal with a very similar problem in the first chapter, but introduce a slightly different termination criteria. Translated into C from the original Fortran, this would give:</p>
<p>    static int sqrt_good_enough(float x, float guess) {<br />
      return fabsf(x/guess - guess) < EPS * guess;<br />
    }</p>
<p>I asked the good folks on www.stackoverflow.com why one termination criteria might be better than another. I've accepted the answer that explained that the termination criteria should match the update definition. In other words, you want the termination criteria to be equivalent to saying `|guess[n+1] - guess[n]| < guess[n] * EPS`. Given that `guess[n+1] = (guess[n] + x/guess[n])/2`, one obtains a termination criteria that reads `|x/guess[n] - guess[n]| < guess[n] * EPS` --- which is exactly the termination criteria preferred by K&#038;P.</p>
<p>Note furthermore that this criteria correctly handles the case when `y == 0.0`. However, the program will still eventually produce nonsense on an input of `0.0`. Quoth the debugger:</p>
<p>    #1  0x0000000000400636 in sqrt_iter (x=0, guess=0) at sqrt3.c:22<br />
    #2  0x0000000000400646 in sqrt_iter (x=0, guess=1.40129846e-45) at sqrt3.c:22<br />
    #3  0x0000000000400646 in sqrt_iter (x=0, guess=2.80259693e-45) at sqrt3.c:22<br />
    #4  0x0000000000400646 in sqrt_iter (x=0, guess=5.60519386e-45) at sqrt3.c:22<br />
    #5  0x0000000000400646 in sqrt_iter (x=0, guess=1.12103877e-44) at sqrt3.c:22<br />
    #6  0x0000000000400646 in sqrt_iter (x=0, guess=2.24207754e-44) at sqrt3.c:22<br />
    #7  0x0000000000400646 in sqrt_iter (x=0, guess=4.48415509e-44) at sqrt3.c:22<br />
    #8  0x0000000000400646 in sqrt_iter (x=0, guess=8.96831017e-44) at sqrt3.c:22<br />
    #9  0x0000000000400646 in sqrt_iter (x=0, guess=1.79366203e-43) at sqrt3.c:22<br />
    #10 0x0000000000400646 in sqrt_iter (x=0, guess=3.58732407e-43) at sqrt3.c:22<br />
    #11 0x0000000000400646 in sqrt_iter (x=0, guess=7.17464814e-43) at sqrt3.c:22<br />
    #12 0x0000000000400646 in sqrt_iter (x=0, guess=1.43492963e-42) at sqrt3.c:22<br />
    #13 0x0000000000400646 in sqrt_iter (x=0, guess=2.86985925e-42) at sqrt3.c:22<br />
    #14 0x0000000000400646 in sqrt_iter (x=0, guess=5.73971851e-42) at sqrt3.c:22<br />
    #15 0x0000000000400646 in sqrt_iter (x=0, guess=1.1479437e-41) at sqrt3.c:22<br />
    #16 0x0000000000400646 in sqrt_iter (x=0, guess=2.2958874e-41) at sqrt3.c:22<br />
    #17 0x0000000000400646 in sqrt_iter (x=0, guess=4.59177481e-41) at sqrt3.c:22</p>
<p>The termination criteria will eventually involve a `0.0/0.0` operation. There is no way out of this other than to explicitly handle that special case. The final program thus reads:</p>
<p>    `sqrt3.c`<br />
    #include <stdlib.h><br />
    #include <stdio.h></p>
<p>    #define EPS 0.000001</p>
<p>    static float fabsf(float x) {<br />
      return x < 0 ? -x : x;<br />
    }</p>
<p>    static int sqrt_good_enough(float x, float guess) {<br />
      return fabsf(x/guess &#8211; guess) < EPS * guess;<br />
    }</p>
<p>    static float sqrt_improve(float guess, float x) {<br />
      return (guess + x/guess)/2;<br />
    }</p>
<p>    static float sqrt_iter(float x, float guess) {<br />
      if (sqrt_good_enough(x, guess))<br />
        return guess;<br />
      else<br />
        return sqrt_iter(x, sqrt_improve(guess, x));<br />
    }</p>
<p>    float sqrt(float x) {<br />
      if (x == 0.0) return 0.0;<br />
      else return sqrt_iter(x, 1.0f);<br />
    }</p>
<p>    int main(int argc, char** argv) {<br />
      float x = atof(argv[1]);<br />
      printf(&#8220;The square root of %.2f is %.2f\n&#8221;, x, sqrt(x));<br />
      return 0;<br />
    }</p>
<p>What&#8217;s the most obscure bug involving floating-point operations you&#8217;ve ever been involved in? I&#8217;d love to hear from it in the comments below.</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://computersandbuildings.com/2012/03/floating-point-woes-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automatic data collection without FTP</title>
		<link>http://computersandbuildings.com/2012/02/automatic-data-collection-without-ftp/</link>
		<comments>http://computersandbuildings.com/2012/02/automatic-data-collection-without-ftp/#comments</comments>
		<pubDate>Tue, 07 Feb 2012 05:07:26 +0000</pubDate>
		<dc:creator>lindelof</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://computersandbuildings.com/?p=581</guid>
		<description><![CDATA[I haven&#8217;t written anything in a while, so I thought I might begin by sharing some ideas on how we collect test site data at Neurobat without using FTP. We have a Dropbox Teams account, which gives us about north of 1 TB of storage. The idea is to install Dropbox on each netbook that [...]
No related posts.]]></description>
			<content:encoded><![CDATA[<p>I haven&#8217;t written anything in a while, so I thought I might begin by<br />
sharing some ideas on how we collect test site data at Neurobat<br />
without using FTP.</p>
<p>We have a <a href="https://www.dropbox.com/teams">Dropbox Teams</a> account,<br />
which gives us about north of 1 TB of storage. The idea is to install<br />
Dropbox on each netbook that monitors a test site, and to have it save<br />
its monitored data to its Dropbox folder. Then when/if that netbook<br />
has internet access, it will automatically upload the data to a shared<br />
folder on our Dropbox account, from which it will be re-distributed to<br />
all interested parties:</p>
<p>        X<br />
       / \<br />
      /   \<br />
     /     \<br />
    /+&#8212;&#8211;+\<br />
     |     |   +&#8212;&#8212;&#8212;+<br />
     |     |&#8230;|netbook-1|&#8230;.<br />
     |     |   +&#8212;&#8212;&#8212;+   .<br />
     +&#8212;&#8211;+                 .<br />
      site 1                 .<br />
                             .<br />
                             .<br />
                             .<br />
        X                    .<br />
       / \                   .<br />
      /   \                 +&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+<br />
     /     \                |  ____                  _                |<br />
    /+&#8212;&#8211;+\               | |  _ \ _ __ ___  _ __ | |__   _____  __ |<br />
     |     |   +&#8212;&#8212;&#8212;+  | | | | | &#8216;__/ _ \| &#8216;_ \| &#8216;_ \ / _ \ \/ / |<br />
     |     |&#8230;|netbook-2|..| | |_| | | | (_) | |_) | |_) | (_) >  <  |.<br />
     |     |   +---------+  | |____/|_|  \___/| .__/|_.__/ \___/_/\_\ |<br />
     +-----+                |                 |_|                     |<br />
      site 2                +-----------------------------------------+<br />
                             .<br />
                             .<br />
                             .<br />
        X                    .<br />
       / \                   .<br />
      /   \                  .<br />
     /     \                 .<br />
    /+-----+\                .<br />
     |     |   +---------+   .<br />
     |     |...|netbook-3|....<br />
     |     |   +---------+<br />
     +-----+<br />
      site 3</p>
<p>For simplicity (and for licencing costs) the same user account is<br />
linked to each netbook. For historic reasons, that account is<br />
`nagios@neurobat.net` (yes, a Nagios server is going to monitor that<br />
data too).</p>
<p>Since we don't want data from, say, site 3 to be copied over to the<br />
local drive of netbook-1, we enable the "Selective Sync" feature on<br />
the netbooks so that each netbook sees only a folder dedicated to that<br />
site. The folder layout thus looks like this:</p>
<p>    Monitoring/<br />
    ├── site 1<br />
    │   └── sensors<br />
    ├── site 2<br />
    │   └── sensors<br />
    └── site 3</p>
<p>The `Monitoring` folder is the globally shared folder, shared by<br />
`nagios@neurobat.net` with all Neurobat users interested in analyzing<br />
the data.</p>
<p>The only downside we have identified with this approach is that<br />
whenever a new site is added, that site's data will by default also be<br />
synchronized with all existing sites. Selective sync will only let you<br />
exclude folders that already exist; as far as I know, you cannot ask<br />
Dropbox to *not* sync new folders in that shared folder. And I am<br />
<a href="https://www.dropbox.com/votebox/5843/selective-sync-should-only-sync-the-folders-i-have-selected-not-new-folders-that-get-added">apparently not the only one to find this annoying</a>.</p>
<p>An alternative might have been to have a separate shared folder for<br />
each site. However, for each new site one would then have to share<br />
that folder with all Neurobat users. Furthermore, since all sites use<br />
the same Dropbox user, you would still end up with that site&#8217;s data<br />
being sync&#8217;ed all over the place.</p>
<p>That being said, we have found the above scheme to work out very well<br />
in practice. The automatic synchronization of Dropbox makes it a<br />
superior alternative to, say, hand-written FTP-calling scripts we<br />
might have used in the past century. And if you have notifications<br />
turned on for your Dropbox account (I personally don&#8217;t) it will be<br />
very reassuring to regularly see your test site data being updated on<br />
your local machine without any human intervention.</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://computersandbuildings.com/2012/02/automatic-data-collection-without-ftp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>homeR: an R package for building physics</title>
		<link>http://computersandbuildings.com/2011/05/homer-an-r-package-for-building-physics/</link>
		<comments>http://computersandbuildings.com/2011/05/homer-an-r-package-for-building-physics/#comments</comments>
		<pubDate>Thu, 26 May 2011 09:54:54 +0000</pubDate>
		<dc:creator>lindelof</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://computersandbuildings.com/?p=569</guid>
		<description><![CDATA[For the past few weeks we&#8217;ve been very busy here at Neurobat with the analysis of field tests results. In the process of doing that, we had to implement several functions in R that relate to building physics. We thought it might be useful for the community to have access to those functions, so we [...]
Related posts:<ol>
<li><a href='http://computersandbuildings.com/2007/05/international-building-physics-toolbox/' rel='bookmark' title='International Building Physics Toolbox'>International Building Physics Toolbox</a></li>
<li><a href='http://computersandbuildings.com/2010/02/event-rate-of-arrival-analysis-with-r/' rel='bookmark' title='Event rate of arrival analysis with R'>Event rate of arrival analysis with R</a></li>
<li><a href='http://computersandbuildings.com/2008/11/article-watch-journal-of-building-physics-vol-32-nr-2/' rel='bookmark' title='Article watch:  Journal of Building Physics vol 32 nr 2'>Article watch:  Journal of Building Physics vol 32 nr 2</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>For the past few weeks we&#8217;ve been very busy here at Neurobat with the analysis of field tests results. In the process of doing that, we had to implement several functions in R that relate to building physics.</p>
<p>We thought it might be useful for the community to have access to those functions, so we decided to begin submitting them to <a href="http://cran.r-project.org/">CRAN</a>. That&#8217;s why we&#8217;re pleased to announce the first release of the <a href="http://cran.r-project.org/web/packages/homeR/index.html">homeR</a> package, which we will fill over time with such functions.</p>
<p>This first release, version 0.1, contains just `pmv`, a function to calculate the so-called <a href="http://en.wikipedia.org/wiki/Thermal_comfort#Research">Predicted Mean Vote</a>, i.e. a measure from -3 (cold) to +3 (hot) of thermal comfort as a function of several variables, including air temperature, clothing and metabolism.</p>
<p>Here I show how with this function one can derive a contour plot showing, for given clothing and metabolism, the optimal indoor temperature (assuming 50% relative humidity). We&#8217;re basically going to solve `pmv(clo, met, temp, sat) = 0` equation for `temp` across a grid of `clo` and `met` values with the `uniroot` function.</p>
<p>    > clo <- seq(0,2,length=21)<br />
    > met <- seq(0.6,3.2,length=21)<br />
    > zero.pmv <- function(clo, met) uniroot(function(temp) pmv(clo,met,temp,50), c(-10,40))$root<br />
    > contourplot((outer(clo,met,Vectorize(zero.pmv))),<br />
                  cuts=20,<br />
                  aspect=&#8221;fill&#8221;,<br />
                  panel=function(&#8230;) {<br />
                    panel.grid(h=-1,v=-1,&#8230;)<br />
                    panel.contourplot(&#8230;)<br />
                  },<br />
                  row.values=clo, column.values=met,<br />
                  xlim=extendrange(clo), ylim=extendrange(met),<br />
                  xlab=&#8221;[Clo]&#8220;, ylab=&#8221;[Met]&#8220;)</p>
<p>And here is the resulting plot:</p>
<div id="attachment_570" class="wp-caption aligncenter" style="width: 310px"><a href="http://computersandbuildings.com/wp-content/uploads/2011/05/pmv.png"><img src="http://computersandbuildings.com/wp-content/uploads/2011/05/pmv-300x300.png" alt="Predicted Mean Vote contour plot" title="Predicted Mean Vote contour plot" width="300" height="300" class="size-medium wp-image-570" /></a><p class="wp-caption-text">Predicted Mean Vote contour plot</p></div>
<p>As you can see, this is pretty similar to that sort of plots one finds in standard textbooks on the subject, such as Claude-Alain Roulet&#8217;s <em>Santé et qualité de l&#8217;environnement intérieur dans les bâtiments</em>:</p>
<div id="attachment_571" class="wp-caption aligncenter" style="width: 310px"><a href="http://computersandbuildings.com/wp-content/uploads/2011/05/photo.jpg"><img src="http://computersandbuildings.com/wp-content/uploads/2011/05/photo-300x225.jpg" alt="PMV contour plot from textbook" title="PMV contour plot from textbook" width="300" height="225" class="size-medium wp-image-571" /></a><p class="wp-caption-text">PMV contour plot from textbook</p></div>
<p>Please give the `homeR` package a try, and give us your feedback. There&#8217;s only the `pmv` function in there at the time of writing but we plan to extend the package in the weeks to come.</p>
<p>Related posts:<ol>
<li><a href='http://computersandbuildings.com/2007/05/international-building-physics-toolbox/' rel='bookmark' title='International Building Physics Toolbox'>International Building Physics Toolbox</a></li>
<li><a href='http://computersandbuildings.com/2010/02/event-rate-of-arrival-analysis-with-r/' rel='bookmark' title='Event rate of arrival analysis with R'>Event rate of arrival analysis with R</a></li>
<li><a href='http://computersandbuildings.com/2008/11/article-watch-journal-of-building-physics-vol-32-nr-2/' rel='bookmark' title='Article watch:  Journal of Building Physics vol 32 nr 2'>Article watch:  Journal of Building Physics vol 32 nr 2</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://computersandbuildings.com/2011/05/homer-an-r-package-for-building-physics/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Saikoro game engine in Lisp</title>
		<link>http://computersandbuildings.com/2011/05/saikoro-game-engine-in-lisp/</link>
		<comments>http://computersandbuildings.com/2011/05/saikoro-game-engine-in-lisp/#comments</comments>
		<pubDate>Fri, 20 May 2011 18:40:29 +0000</pubDate>
		<dc:creator>lindelof</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[game]]></category>
		<category><![CDATA[lisp]]></category>
		<category><![CDATA[saikoro]]></category>

		<guid isPermaLink="false">http://computersandbuildings.com/?p=559</guid>
		<description><![CDATA[Here at Neurobat we consecrate one day per sprint as a *Lab Day*, i.e. a day when, not unlike what Google does, we are free to work on whatever we want. Today was Lab Day and I took the opportunity to brush up my Lisp skills by writing a game, inspiring myself heavily from Conrad [...]
No related posts.]]></description>
			<content:encoded><![CDATA[<p>Here at Neurobat we consecrate one day per sprint as a *Lab Day*, i.e. a day when, not unlike what Google does, we are free to work on whatever we want.</p>
<p>Today was Lab Day and I took the opportunity to brush up my Lisp skills by writing a game, inspiring myself heavily from Conrad Burski&#8217;s wonderful book <a href="http://www.amazon.com/gp/product/1593272812/ref=as_li_ss_tl?ie=UTF8&amp;tag=compandsmarbu-20&amp;linkCode=as2&amp;camp=217145&amp;creative=399349&amp;creativeASIN=1593272812">Land of Lisp</a><img src="http://www.assoc-amazon.com/e/ir?t=&amp;l=as2&amp;o=1&amp;a=1593272812&amp;camp=217145&amp;creative=399349" width="1" height="1" border="0" alt="" style="border:none !important;margin:0px !important" />, which will teach you the necessary Lisp skills for the most important programming gig ever, that is, writing games.</p>
<p>I wrote a game engine for the <a href="http://boardgamegeek.com/boardgame/27813/saikoro">Saikoro</a> boardgame, a game simple enough to be amenable to the kind of AI described in the book. Without doing any major kind of optimization, the computer will play a perfect game on a 4 x 4 board by computing exhaustively a tree of all possible games from a starting position.</p>
<p>Here is what a typical game session looks like:</p>
<pre><code>$ sbcl --load saikoro.lisp
; snip some noise
Current player: A
| A[ 0] 3[ 1] 3[ 2] 2[ 3] |
| 1[ 4] 4[ 5] 2[ 6] 2[ 7] |
| 3[ 8] 4[ 9] 4[10] 2[11] |
| 1[12] 3[13] 4[14] B[15] |
Choose your move:
1. 0 -&gt; 4
2. 0 -&gt; 10
3. 0 -&gt; 1
4. 0 -&gt; 5
2
Current player: B
| 0[ 0] 3[ 1] 3[ 2] 2[ 3] |
| 1[ 4] 4[ 5] 2[ 6] 2[ 7] |
| 3[ 8] 4[ 9] A[10] 2[11] |
| 1[12] 3[13] 4[14] B[15] |
Current player: A
| 0[ 0] 3[ 1] 3[ 2] 2[ 3] |
| 1[ 4] B[ 5] 2[ 6] 2[ 7] |
| 3[ 8] 4[ 9] A[10] 2[11] |
| 1[12] 3[13] 4[14] 0[15] |
Choose your move:
1. 10 -&gt; 1
2. 10 -&gt; 7
2
Current player: B
| 0[ 0] 3[ 1] 3[ 2] 2[ 3] |
| 1[ 4] B[ 5] 2[ 6] A[ 7] |
| 3[ 8] 4[ 9] 0[10] 2[11] |
| 1[12] 3[13] 4[14] 0[15] |
Current player: A
| 0[ 0] 3[ 1] 3[ 2] 2[ 3] |
| B[ 4] 0[ 5] 2[ 6] A[ 7] |
| 3[ 8] 4[ 9] 0[10] 2[11] |
| 1[12] 3[13] 4[14] 0[15] |
Choose your move:
1. 7 -&gt; 1
1
Current player: B
| 0[ 0] A[ 1] 3[ 2] 2[ 3] |
| B[ 4] 0[ 5] 2[ 6] 0[ 7] |
| 3[ 8] 4[ 9] 0[10] 2[11] |
| 1[12] 3[13] 4[14] 0[15] |
Current player: A
| 0[ 0] A[ 1] 3[ 2] 2[ 3] |
| 0[ 4] 0[ 5] 2[ 6] 0[ 7] |
| 3[ 8] 4[ 9] 0[10] 2[11] |
| 1[12] B[13] 4[14] 0[15] |
Choose your move:
1. 1 -&gt; 6
2. 1 -&gt; 3
3. 1 -&gt; 2
3
Current player: B
| 0[ 0] 0[ 1] A[ 2] 2[ 3] |
| 0[ 4] 0[ 5] 2[ 6] 0[ 7] |
| 3[ 8] 4[ 9] 0[10] 2[11] |
| 1[12] B[13] 4[14] 0[15] |
Current player: A
| 0[ 0] 0[ 1] A[ 2] 2[ 3] |
| 0[ 4] 0[ 5] 2[ 6] 0[ 7] |
| 3[ 8] 4[ 9] 0[10] 2[11] |
| B[12] 0[13] 4[14] 0[15] |
B wins!
* (quit)
</code></pre>
<p>As you can see the UI is very rudimentary for the moment but I wanted to concentrate on getting the AI right first. Next I plan to optimize the AI, and make it work with a non-exhaustive game tree so it would work on larger boards.</p>
<p>If you&#8217;re interested in trying it out, feel free to <a href="https://github.com/dlindelof/saikoro">clone my repository</a>.</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://computersandbuildings.com/2011/05/saikoro-game-engine-in-lisp/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Pomodoro + Workrave = Well-being</title>
		<link>http://computersandbuildings.com/2011/04/pomodoro-workrave-well-being/</link>
		<comments>http://computersandbuildings.com/2011/04/pomodoro-workrave-well-being/#comments</comments>
		<pubDate>Mon, 18 Apr 2011 18:30:31 +0000</pubDate>
		<dc:creator>lindelof</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://computersandbuildings.com/?p=554</guid>
		<description><![CDATA[I&#8217;ve been a big fan of the Pomodoro Technique for almost a year now. No, I don&#8217;t go as far as actually having a ticking timer in my office in front of my co-workers, and I don&#8217;t necessarily plan the day in advance, but I do try to break up my work in 25-min iterations [...]
No related posts.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been a big fan of the <a href="http://www.pomodorotechnique.com/">Pomodoro Technique</a> for almost a year now. No, I don&#8217;t go as far as actually having a ticking timer in my office in front of my co-workers, and I don&#8217;t necessarily plan the day in advance, but I do try to break up my work in 25-min iterations punctuated by 5-min breaks.</p>
<p>I used to use Ubuntu&#8217;s Timer applet to alert me to take a break, but a month ago I found what I now believe to be the perfect complement to the Pomodoro Technique: a nice little application called <a href="http://www.workrave.org/">Workrave</a>.</p>
<p>Workrave will let you define work intervals after which it will, shall we say, strongly encourage you to take a break and propose a couple of physical exercises. I&#8217;ve installed Workrave under Ubuntu (I believe it runs also on Windows) and configured it for:</p>
<p>* no micro-breaks<br />
* a 5-min rest break after 25 min of work<br />
* a daily limit of 8 hours (never reached)</p>
<p>Try it out! It&#8217;s completely free and quite nice. I can also recommend the P<a href="http://www.pragprog.com/titles/snfocus/pomodoro-technique-illustrated">omodoro Technique Illustrated book</a> from the Pragmatic Programmers, but you might also want to begin with the free &#8220;official&#8221; <a href="http://www.scribd.com/doc/36672142/">Pomodoro book</a>.</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://computersandbuildings.com/2011/04/pomodoro-workrave-well-being/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Converting Sweave/R plots for inclusion in Word/OpenOffice</title>
		<link>http://computersandbuildings.com/2011/04/converting-sweaver-plots-for-inclusion-in-wordopenoffice/</link>
		<comments>http://computersandbuildings.com/2011/04/converting-sweaver-plots-for-inclusion-in-wordopenoffice/#comments</comments>
		<pubDate>Thu, 14 Apr 2011 13:13:12 +0000</pubDate>
		<dc:creator>lindelof</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://computersandbuildings.com/?p=549</guid>
		<description><![CDATA[Just a quick note to myself: When you use Sweave and produce high-quality plots in both EPS and PDF formats, you sometimes want to include them in Word or OpenOffice documents. You can&#8217;t directly include PDF files, and you can only include EPS files when they have a preview, which Sweave will not do by [...]
Related posts:<ol>
<li><a href='http://computersandbuildings.com/2007/06/latex-to-word-format-conversion-how-to/' rel='bookmark' title='LaTeX to Word format conversion how-to'>LaTeX to Word format conversion how-to</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Just a quick note to myself:</p>
<p>When you use <a href="http://www.stat.uni-muenchen.de/~leisch/Sweave/">Sweave</a> and produce high-quality plots in both EPS and PDF formats, you sometimes want to include them in Word or OpenOffice documents.</p>
<p>You can&#8217;t directly include PDF files, and you can only include EPS files when they have a preview, which Sweave will not do by default. And anyway, the EPS version of the graphs are made for black and white printers and will not be in color.</p>
<p>I&#8217;m using `convert` from the ImageMagick package to convert the PDF plots to PNG files. However, by default `convert` will give low-quality pictures. To have better images, I do:</p>
<p>    convert -density 300 XXX.pdf XXX.png</p>
<p>If you feel geeky enough you can even include this in a Makefile:</p>
<p>    figures: $(patsubst %.pdf, %.png, $(wildcard report-*.pdf))</p>
<p>    report-%.png : report-%.pdf<br />
    	convert -density 300 $&lt; $@</p>
<p>Related posts:<ol>
<li><a href='http://computersandbuildings.com/2007/06/latex-to-word-format-conversion-how-to/' rel='bookmark' title='LaTeX to Word format conversion how-to'>LaTeX to Word format conversion how-to</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://computersandbuildings.com/2011/04/converting-sweaver-plots-for-inclusion-in-wordopenoffice/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Git and Scientific Reproducibility</title>
		<link>http://computersandbuildings.com/2011/01/git-and-scientific-reproducibility/</link>
		<comments>http://computersandbuildings.com/2011/01/git-and-scientific-reproducibility/#comments</comments>
		<pubDate>Mon, 24 Jan 2011 23:00:39 +0000</pubDate>
		<dc:creator>lindelof</dc:creator>
				<category><![CDATA[Research]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[science]]></category>

		<guid isPermaLink="false">http://computersandbuildings.com/?p=510</guid>
		<description><![CDATA[I firmly believe that scientists and engineers&#8212;particularly scientists, by the way&#8212;should learn about, and use, version control systems (VCS) for their work. Here is why. I&#8217;ve been a user of free VCSs for a while now, beginning with my first exposure to CVS at CERN in 2002, through my discovery of Subversion during my doctoral [...]
No related posts.]]></description>
			<content:encoded><![CDATA[<p>I firmly believe that scientists and engineers&#8212;particularly scientists, by the way&#8212;should learn about, and use, version control systems (<a href="http://en.wikipedia.org/wiki/Revision_control">VCS</a>) for their work. Here is why.</p>
<p>I&#8217;ve been a user of free VCSs for a while now, beginning with my first exposure to <a href="http://savannah.nongnu.org/projects/cvs">CVS</a> at CERN in 2002, through my discovery of <a href="http://subversion.apache.org/">Subversion</a> during my doctoral years at EPFL, culminating in my current infatuation with <a href="http://git-scm.com/">Git</a> as a front-end to Subversion. <strong>I&#8217;m now a complete convert to that system</strong> and could not imaging working without it. Every week I discover <strong>new use cases</strong> for this tool that I had not thought about before (and that I suspect the Git developers didn&#8217;t, either).</p>
<p>This week I found such a use case for Git: <strong>enforcing scientific reproducibility</strong>. Let me explain. I&#8217;m currently working on prototype software written in <a href="http://www.mathworks.com/">MATLAB</a> that implements some advanced algorithms for the smart, predictive control of heating in buildings. As part of that work we need to evaluate several competing algorithm designs, and try out different parameters for the algorithms.</p>
<p>The traditional way of doing this is, of course, to set all your parameters right in your code for the first simulation, to run it, then to set the parameters right for the second one, to run it again, and so on. <strong>There are several problems with this approach</strong>.</p>
<p>First, you need a really good naming convention for the data you are going to generate to make sure that you know exactly which parameters you set for each run. And coming up with a good naming scheme for data files is not trivial.</p>
<p>Second, even if your data file naming convention is good enough that you can easily reproduce the experiment, how can you be sure that the settings are exactly right? That you didn&#8217;t, perhaps, tweak just that little extra configuration file just to work around that little bug in the software?</p>
<p>Third, <strong>how will you reproduce those results</strong>? Even assuming that you ran all your simulations based on a given, well-known revision number in your VCS (you do use a VCS, don&#8217;t you?), you will still need to dive in the code and set those configuration parameters yourself. A tedious, error-prone process, even if you manage to keep them all to one source file.</p>
<p>I think a system like Git solves all these problems. Here is how I did it.</p>
<p>I needed to run 7 simulations with different parameters, based on a stable version of our software, say r1409 in our Subversion repository.</p>
<p>I&#8217;m using Git as a front-end to Subversion. I began by creating a local branch (something Git, not Subversion, will let you do):</p>
<pre><code>$ git checkout -b simulations_based_on_r1409</code></pre>
<p>This will create a new branch from the current HEAD. Now the idea is to make a local commit on <em>that local branch</em> for each different set of parameters. Here is how:</p>
<ol>
<li>Edit your source code so that all parameters are set right.</li>
<li>Commit the changes on your local branch:
<pre><code>$ git ci -am "With parameter X set to Y"
[simulations_based_on_r1409 66cea68] With parameter X set to   </code></pre>
</li>
<li>Note the 7 characters (66cea68 above) next to the branch name. These are the first 7 characters of the SHA-1 hash of your entire project, as computed by Git.</li>
<li>Run your simulation. Log the results, along with the short hash.</li>
<li>Repeat the steps above for each different configuration you want to run the experiment with.</li>
</ol>
<p>By the end of this process, you should have in your logbook a list of experimental results <em>along with the short hash of the entire project as it looked during that experiment.</em> It might, for instance, look something like this:</p>
<table border="" width="">
  <TR><br />
    <TH rowspan="" colspan="">Hash</TH><br />
    <TH rowspan="" colspan="">Parameter X</TH><br />
    <TH rowspan="" colspan="">Parameter Y</TH><br />
    <TH rowspan="" colspan="">Result</TH><br />
  </TR><br />
  <TR><br />
    <TD align="" colspan="">66cea68</TD><br />
    <TD align="" colspan="">23</TD><br />
    <TD align="" colspan="">42</TD><br />
    <TD align="" colspan="">1024</TD><br />
  </TR><br />
  <TR><br />
    <TD align="" colspan="">a4f683f</TD><br />
    <TD align="" colspan="">etc</TD><br />
    <TD align="" colspan="">etc</TD><br />
    <TD align="" colspan="">etc</TD><br />
</TR><br />
</table>
<p>As you can see there are at least two reasons why it&#8217;s important to record the short hash:</p>
<ol>
<li>It will let you go back in time and <strong>reproduce an experiment</strong> <strong>exactly</strong> as it was when you ran it first.</li>
<li>It will <strong>force you to commit all changes before running the experiment</strong>, which is a good thing.</li>
</ol>
<p>I&#8217;ve been running a series of simulations using a variation on this process, whereby I actually run several simulations in parallel on my 8-core machine. For this to work you need to <em>clone</em> your entire project, once per simulation. Then for each simulation you checkout the right version of your project, and run the experiment.</p>
<p>Quite seriously, I would <strong>never have been able to do anything remotely like this with a centralized version control system</strong>. The possibility to create local branches and to commit to them is a truly awesome feature of distributed version control systems such as Git. I don&#8217;t suppose the Git developers had scientists and engineers in mind when they developed this system, but hey, here we are.</p>
<p>Are you a scientist or an engineer wishing to dramatically improve your way of working? Then run, do not walk, to read the <a href="http://progit.org/">best book on Git there is.</a></p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://computersandbuildings.com/2011/01/git-and-scientific-reproducibility/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Thou shalt save energy</title>
		<link>http://computersandbuildings.com/2011/01/thou-shalt-save-energy/</link>
		<comments>http://computersandbuildings.com/2011/01/thou-shalt-save-energy/#comments</comments>
		<pubDate>Thu, 06 Jan 2011 23:18:18 +0000</pubDate>
		<dc:creator>lindelof</dc:creator>
				<category><![CDATA[Energy]]></category>

		<guid isPermaLink="false">http://computersandbuildings.com/?p=519</guid>
		<description><![CDATA[I&#8217;m not sure anyone else is saying this, so I will: I think **there is a clear and unambiguous scriptural mandate to reduce our current energy consumption**. Now before you dismiss this post, this author and this blog as just another bible-thumping fanatic, remember that in certain countries, certain political parties profess strict adherence to [...]
No related posts.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m not sure anyone else is saying this, so I will: I think **there is<br />
a clear and unambiguous scriptural mandate to reduce our current<br />
energy consumption**.</p>
<p>Now before you dismiss this post, this author and this blog as just<br />
another bible-thumping fanatic, remember that in certain countries,<br />
certain political parties profess strict adherence to Scripture while<br />
being overtly skeptical about the whole climate warming problem. I<br />
think they are wrong and here&#8217;s why.</p>
<p>Let&#8217;s first review why, from a scriptural point of<br />
view, one could in principle argue that whether we take action or let things run<br />
as they are makes no difference. I&#8217;ve heard some of these arguments from very good<br />
(christian) friends, and I hope I&#8217;m not going to offend anyone by<br />
refuting them later in this post:</p>
<p>* Revelation 21:1 tells us that all of creation will eventually be<br />
   destroyed and replaced by a new one: </p>
<blockquote><p>Then I saw a new heaven and a new earth; for the first heaven and the first earth passed away, and there is no longer any sea.</p></blockquote>
<p>* God is sovereign, so no matter what we do, things will run according<br />
  to His will.</p>
<p>* It is highly arrogant for Man to believe that they can do anything<br />
  about the climate.</p>
<p>The last two arguments are probably the easiest to answer. God is<br />
certainly sovereign, but that doesn&#8217;t remove our responsibility for<br />
doing the right things and making the right choices in life. In fact,<br />
God intends us to be co-creators with Him and to participate, so to<br />
speak, in the creative act. This point has been persuasively argued<br />
for by several authors such as C.S. Lewis and J.I. Packer.</p>
<p>The big problem with the first argument is that, even though the<br />
current creation is indeed doomed in the long run, God asked us from<br />
the beginning to take care of it, cf. Genesis 1:28:</p>
<blockquote><p>God blessed them; and God said to them, “Be fruitful and<br />
multiply, and fill the earth, and subdue it; and rule over the fish of<br />
the sea and over the birds of the sky and over every living thing that<br />
moves on the earth.”</p></blockquote>
<p>See that? Commandment nr 3 in the whole Bible: subdue the Earth and<br />
rule over it. No mention here of letting things run its course simply<br />
because the creation is about (in the biblical perspective) to be<br />
replaced.</p>
<p>Ah but you might argue that this command was given *before* the Fall,<br />
and that everything went downhill since then. You&#8217;re right about the<br />
downhill part, but look at this, Gen 3:23:</p>
<blockquote><p>therefore the Lord God sent him out from the garden of<br />
Eden, to cultivate the ground from which he was taken.</p></blockquote>
<p>Man is kicked out of the Garden of Eden, and what is he to do?<br />
Essentially the same thing, e.g. rule over the Earth and cultivate it<br />
and take care of it. The only difference being, of course, that now<br />
it&#8217;s going to be painful to do so (Gen 3:19).</p>
<p>The mandate to take care of creation is repeated several times, for<br />
instance right after Noah comes out of the Ark after the Flood, Gen<br />
9:1-2:</p>
<blockquote><p>And God blessed Noah and his sons and said to them, “Be<br />
fruitful and multiply, and fill the earth. The fear of you and the<br />
terror of you will be on every beast of the earth and on every bird of<br />
the sky; with everything that creeps on the ground, and all the fish<br />
of the sea, into your hand they are given.&#8221;</p></blockquote>
<p>Or of course Psalm 8:5-6:</p>
<blockquote><p>Yet You have made him a little lower than God,<br />
And You crown him with glory and majesty! You make him to rule over<br />
the works of Your hands; You have put all things under his<br />
feet.</p></blockquote>
<p>God intends us clearly to rule and manage His creation, no matter what<br />
ultimate fate awaits it.</p>
<p>But the real suprise came to me while re-reading the following<br />
(Deut. 22:6-7):</p>
<blockquote><p>“If you happen to come upon a bird’s nest along the way,<br />
in any tree or on the ground, with young ones or eggs, and the mother<br />
sitting on the young or on the eggs, you shall not take the mother<br />
with the young; you shall certainly let the mother go, but the young<br />
you may take for yourself, in order that it may be well with you and<br />
that you may prolong your days.</p></blockquote>
<p>This was one of the many commands given Israel before entering the<br />
promised land. The spirit of this passage, and of others like it, is<br />
unambiguous: God is asking us simply to be **utmostly careful in managing our<br />
natural resources**. We are forbidden to view Earth as just a vast source of<br />
riches to be exploited as quickly and efficiently as possible. We are<br />
explicitly commanded to make sure that Earth can go on being such a<br />
source of riches, indefinitely if needed.</p>
<p>(I&#8217;ve even read somewhere that the number of years Israel spent in<br />
babylonian captivity, 70, corresponds to the number of years the land<br />
should have been allowed to rest since Israel took possession of it,<br />
but didn&#8217;t. Here again, the importance of allowing natural resources<br />
to replenish themselves is evident.)</p>
<p>The concept of &#8220;rest&#8221; is a potent one in Scripture. We are to rest<br />
once a week. The land was to rest once every 7 years. We were supposed<br />
to leave alone the corners of our fields that weren&#8217;t harvested. In<br />
other words, **Scripture is full of passages mandating a careful<br />
management of our natural resources**. Arguing that we can do whatever<br />
we want with Earth simply because it is doomed to the eternal fire<br />
anyway is not only lazy and criminal, it is also doctrinally false.</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://computersandbuildings.com/2011/01/thou-shalt-save-energy/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Neurobat, day one</title>
		<link>http://computersandbuildings.com/2010/09/neurobat-day-one/</link>
		<comments>http://computersandbuildings.com/2010/09/neurobat-day-one/#comments</comments>
		<pubDate>Tue, 14 Sep 2010 21:43:53 +0000</pubDate>
		<dc:creator>lindelof</dc:creator>
				<category><![CDATA[Announcements]]></category>

		<guid isPermaLink="false">http://computersandbuildings.com/?p=500</guid>
		<description><![CDATA[Yesterday marked my first day as Chief Technology Officer at Neurobat AG, a young company formed in Switzerland to industrialize and market advanced building control algorithms, such as the ones commonly researched and developed at my former laboratory, the Solar Energy and Building Physics Laboratory at EPFL. This also marks the end of almost three [...]
No related posts.]]></description>
			<content:encoded><![CDATA[<p>Yesterday marked my first day as Chief Technology Officer at <a href="http://www.neurobat.net/">Neurobat AG</a>, a young company formed in Switzerland to industrialize and market advanced building control algorithms, such as the ones commonly researched and developed at my former laboratory, the <a href="http://lesowww.epfl.ch/">Solar Energy and Building Physics Laboratory at EPFL</a>.</p>
<p>This also marks the end of almost three years spent building enterprise integration systems in Java for a certain coffeeshop. I&#8217;m now moving back to my original topics of interest, namely the intelligent control and simulation of buildings. Indeed, without disclosing too much, the very first project I will be working on is the implementation of certain ideas formulated during the Neurobat research project carried out aeons ago at LESO-PB. Except this time the systems won&#8217;t be running in the quiet and safe environment of an experimental building whose occupants have a history of forgiveness towards enthusiastic graduate students and their ideas&#8212;including myself. No, this time we mean business, that is, embedded systems that must be build rock-solid and run unattended for years, or possibly decades.</p>
<p>One issue that&#8217;s come up more than once was whether we should keep MATLAB as our lingua franca for prototyping and trying out new ideas and concepts before porting them to languages more, shall we say, closer to the machine. Or should we just dump it (including its non-negligible licencing costs, especially for an non-academic organization) and work directly as close to the metal as we dare?</p>
<p>Personally, without wanting to sound overly smug or anything, I think that someone asking this question has obviously never tried multiplying two matrices in C. The implementation contributed by <a href="http://www.nr.com/contrib/">James Trevelyan to the Numerical Recipes in C website</a> runs to about 33 lines:</p>
<p>    void dmmult( double **a, int a_rows, int a_cols,<br />
                 double **b, int b_rows, int b_cols, double **y)<br />
    /* multiply two matrices a, b, result in y. y must not be same as a or b */<br />
    {<br />
       int i, j, k;<br />
       double sum;</p>
<p>       if ( a_cols != b_rows ) {<br />
          fprintf(stderr,&#8221;a_cols  b_rows (%d,%d): dmmult\n&#8221;, a_cols, b_rows);<br />
          exit(1);<br />
       }</p>
<p>    #ifdef V_CHECK<br />
       if ( !valid_dmatrix_b( a ) )<br />
          nrerror(&#8220;Invalid 1st matrix: dmmult\n&#8221;);<br />
       if ( !valid_dmatrix_b( b ) )<br />
          nrerror(&#8220;Invalid 2nd matrix: dmmult\n&#8221;);<br />
       if ( !valid_dmatrix_b( y ) )<br />
          nrerror(&#8220;Invalid result matrix: dmmult\n&#8221;);<br />
    #endif</p>
<p>       /*  getchar();<br />
           dmdump( stdout, &#8220;Matrix a&#8221;, a, a_rows, a_cols, &#8220;%8.2lf&#8221;);<br />
           dmdump( stdout, &#8220;Matrix b&#8221;, b, b_rows, b_cols, &#8220;%8.2lf&#8221;);<br />
           getchar();<br />
       */<br />
       for ( i=1; i&lt;=a_rows; i++ )<br />
          for ( j=1; j&lt;=b_cols; j++ ) {<br />
             sum = 0.0;<br />
             for ( k=1; k&lt;=a_cols; k++ ) sum += a[i][k]*b[k][j];<br />
             y[i][j] = sum;<br />
          }<br />
    }</p>
<p>Give me instead MATLAB&#039;s</p>
<p>    y = a * b</p>
<p>anytime. Now of course I realize the comparison is completely unfair. The C version includes error checking, comments, etc. But still, C is, after all, originally a systems programming language, while MATLAB-the-language is a DSL for doing precisely this sort of stuff. I never wanted to prove that C sucked at doing linear algebra&#8212;I just wanted to show that most trivial operations in MATLAB would have to be&#8212;by us&#8212;re-implemented in C before we can even begin using them. And I don&#039;t think we have that sort of time. Not outside of academia.</p>
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://computersandbuildings.com/2010/09/neurobat-day-one/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

