Friday, September 10, 2010

De Morgan's Laws in Action



Augustus De Morgan

Augustus De Morgan, originally uploaded by Mike Lynch.



Logic: It's a beautiful thing. It's not everyday, however, that I get to implement it so explicitly as I did today.


One of the hallmarks of mathematical logic are some rules set out by Augustus De Morgan called, appropriately, De Morgan's Laws. They go something like this: Take two (or more) statements A and B. These can be things like "The sky is blue" and "We are on Earth." These statements have complements, namely, "The sky is not blue" and "We are not on Earth."


De Morgan gives an equivalence between the relation of these statements' complements and the complement of the relation of these statements. In (better) English, we could say that the complement of A and B is the complement of A or the complement of B. So, in our example, De Morgan tells us that the complement of "The sky is blue AND we are on Earth" is the same thing as saying "The sky is not blue OR we are not on Earth." Confused? Try out the formal statements for a bit of clarification:


where we read "c" as complement,

and


Why would this ever arise in practice, you might ask? In fact, just today I wanted to add a stopping condition to a WHILE loop I had in a program. A WHILE loop runs (loops) for as long as a given statement is true. My loop ran for as long as the variable called FLAG was true. Essentially, I wanted to cheat a little and add a different stopping criterion that would bounce out of the loop if a different variable hadn't been changing for a while.


So in my head, the loop should run while FLAG was true, and it should stop when COUNTER was bigger than 20 and W(COUNTER)==W(COUNTER-20). But, just my luck, you can't really tell a WHILE loop when not to run, you have to tell it when it has to run. But guess, what? These conditions are complements! Enter De Morgan.


My situation was that I want to stop the loop when

is true. Which means that I want to NOT stop (i.e. run) when

is true.


Bonus! We get to use both flavors of De Morgan. First apply the first equation from up top, then apply the second to the B parentheses. After all is said and complemented, I want to run my WHILE loop while FLAG is true AND (COUNTER is less than 20 OR W(COUNTER)~=W(COUNTER-20)). Cool huh?


Stay Logical.

Wednesday, August 18, 2010

Smarter Grids


[For those looking for "How to Peak Around a Corner," give me a couple more days. It's a bit harder than I first thought.]


I literally just got out of a seminar given by Marija Ilic, of Carnegie Mellon, on her work and prognostications for making the delivery of electric power more efficient. I was expecting the typical drab droning that usually confronts me from invited speakers, but I was able to pull several salient and cogent points out of her talk. This is a fairly extemporaneous post, so please forgive my stream-of-consciousness style.


Utility companies, in general, try to provide uninterrupted service at minimal cost to their subscribers. We could go on and on about the scruples of utility companies and their guaranteed monopolies, but that is not really very productive at this point, so let us take their cost-minimization desires as a given. While "minimal cost to subscribers" is a very soft term, I never realized how hard the uninterrupted service constraint really was. Imagine this scenario: Town X has a daily power consumption of no more than 90 MW for 350 days a year. Given this information, constructing a 100 MW power plant to supply Town X seems like a good idea. However, for 15 days per year, Town X demands 120 MW (due to heat waves, cold snaps, etc.). If the utility company really had only constructed a 100 MW power plant, all of the directors would be fired after the first year because they couldn't supply the town sufficiently for 4% of the year. So instead, the utility has to lay out the cash to build more power generation capacity that just sits around for up to 350 days a year.


As Prof. Ilic stated, "cost management is all about the spikes." She was referring to the spikes---hourly, daily, and yearly---in demand that utility companies see. If it weren't for the spikes in demand, the total demand would have far less variance, and less superfluous generation capacity would be necessary.


What can we do about these spikes? This is where the system intelligence comes into play. Prof. Ilic claims that currently, most utility companies have extensive records to estimate their long-term average demand, but they use only something like the past 15 minutes of data to predict upcoming surges. I would really like to see a "look-ahead" filter (or model-predictive controller, as Prof. Ilic calls it) on the power companies' demand estimates. This information should then obviously be distributed out to the consumers, who then are incentivised to decrease demand when faced with surging costs.


Obviously this incentive scheme can only be implemented with some form of "smart meter" at the consumer side. It really baffles me why these haven't gone past pilot programs across America. The basic functionality of a smart meter is that it records the power drawn by a consumer, and logs this information over time. More dynamic implementations could go so far as to incorporate an automatic controller. This would be a household appliance (there's an app for that!) that lets the user list and prioritize power-hungry processes as well as input a desired maximum cost of electricity each day. The meter/controller would then use the predicted power costs to schedule the user's processes to run as time---and money---allow.


Smart Meter

Smart Meter, originally uploaded by tmvissers.


The funny thing is: This "scheduling" of "processes" already happens in every office and nearly every home in the country. Computers and servers operate on the very principle that some processes have higher priorities than others, and that they will all (hopefully) get done in due time. Except that computers decide between processes thousands of times every second. Should it really be that hard to decide to run your laundry dryer at 1:00 AM and your dishwasher at 3:00 AM?


This pseudo-rant so far has only touched on the "one-way" current model of the power grid. The sexiest topic in smart grid research is how to (best) incorporate distributed power generators. On the one hand, the concept is quite simple: Whereas before a utility user could be viewed solely as a power sink, now there is the possibility of seeing a negative sink (commonly referred to as a source). However, as Prof. Ilic is quick to explain, things are not quite so simple.



All electric power these days travels into our homes on endless sine waves of current. In the US, if you were to stand at one point on the transmission wire, the peaks of these waves would pass you 60 times every second. This standard has allowed for the universal (well...almost) wall plug that all your household devices use. Correspondingly, the power companies transmit and transform the power so that this is exactly what you get at the "tap." When people start generating their own power, there is currently (haha...get it?) no way of knowing that the phase of the user-generated signal will match the phase of the utility-generated one. This phase-matching problem is fairly serious and expensive to control.


The alternative, it has been postulated, is to discourage end users to feed back into the grid. Rather, users should endeavor to store as much of their locally generated power as possible. Now people are thinking inter-disciplinary. Now if you have a plug-in hybrid vehicle, you instantly have a massive battery in which to store your excess power. It's like a two-for-one! The problem is that without dynamic smart meters, everyone comes home from work and at 6:00 PM, plugs in their hybrid and create one of those damned spikes. Now you see how all of these problems are interconnected.


I'll wrap things up with a little utopian vision. My dream house will have several acres of woodland (and be under an hour on public transportation to a major airport) on which I can erect a wind turbine or two. These will provide power to my house as allocated by my self-designed power controller. On windy days, I'll have so much electricity that I'll be able to pump water out of a little stream into a tank uphill from my house. Then, when I need hot water for my bath, I'll suck it out of this tank, through a parabolic reflector and then through a generator, into my tub and use the electricity to run my reading light. Too easy.


Stay smart,

Clay

Thursday, July 29, 2010

How to Peek Around a Corner - Part 1


around the corner,, originally uploaded by ~Faiz.

Occasionally in my reading, I come across a particularly well-posed question that I feel is not only accessible to "lay" readers but also interesting to them. The problem of how to best look (or "peek") around a corner is just one of these questions.

As a warning, I will pose the question in this post and then solicit ideas and answers from the readers. Then next week I'll post a solution and hopefully an example.



First, the setting: You are Bruce Willis in Die Hard. You are pursuing and being pursued by bloodthirsty terrorists in a strange office building. You find yourself walking in a smoky room with your hand against a wall in order to not get lost. All of a sudden, you notice that your wall comes to an end exactly one meter in front of you. You pause and analyze how to best approach this corner in the wall in order to be able to see down the adjoining wall.





If you knew the angle that the adjoining wall intersected your wall (and this angle was acute), the quickest path would be one that departed the wall you were following at an angle of
90-\phi
and traveled in a straight line for \sin\phi meters. This would take you directly to the "extension" of the line of the adjoining wall and would afford you an unobstructed view down that wall. Conversely, if the angle is obtuse, it would be quickest to just go directly along the wall to the corner. This concept is illustrated in the figure below (courtesy R. Dorrigiv and A. Lopez-Ortiz):




The tension between these two approaches (curl out into the room versus proceed directly to the corner) represent the crux of this path-planning problem.

Let me finally pose the question: Starting from one unit "south" of a corner with unknown acute angle (between 0 and 90 degrees, inclusive), what is the best approach path, and what does "best" mean to you?

A solution---and my take on it---coming soon.

Monday, May 24, 2010

2010 ARCS-Honolulu Kresser Award in Engineering

Every year, the Honolulu chapter of the ARCS Foundation (Achievement Rewards for College Scientists) presents scholarships to a select number of graduate students working on research in the various sciences at UH Manoa.

This year, there were 12 awards given to students ranging from the physical and natural sciences to health sciences and engineering. I was one of two students (both from Electrical Engineering) to receive an award from the College of Engineering.

In exchange for the award, the ARCS Foundation asks the students to prepare short semi-technical talks and posters to share their research with the donors and coordinators. I took this as a great opportunity to hone my (slightly rusty) public speaking skills, and prepared the slideshow below to augment my ten minute talk.



(edit: It looks like the video player has cut off the title slide. You're not missing much, but the whole thing is available via the links below)
The slides and poster are both also available as PDF's.

In addition to practicing my speaking skills, the presentation session was enjoyable because it shed some light on the interesting research being done by 11 other bright scientists around the campus. Some particularly interesting work is being done by Jim Baker (EE) in compact high-frequency radio antenna design, Brendan Bowler (Astro) in the search for extra-solar planets, and Tiffany Anderson (Oceanography) in shoreline erosion due to storms.

Tuesday, May 18, 2010

New Site, v2.0!

That's right, after about a one month hiatus, my website for all things academic is back in action. I really would appreciate any comments and criticism you have about it. I am an utter n00b at most of this.

Wondering what motivated the revamp? To be honest, I was quite happy with the old version that I built with iWeb. It turns out that iWeb was not as happy with it. After adding a blog entry in the native iWeb interface, the application crashed and would continue to do so after any further modifications to the blog pages. Since I don't really foresee this type of website changing very often (aside from the blog section), it didn't make much sense to me to continue along that path.

I made the effort of actually taking my computer in to an Apple store to see if their employees (I find it pretentious to refer to them as geniuses) could offer any suggestions. The technical support rep was congenial and sympathetic to my plight, but in the end, entirely unhelpful in resolving issues with a corrupted iWeb site.

At this time, I sought the advice of the foremost computer guru I know: Ben, one of my best friends for over 10 years now. His advice on which GUI-based website builder to use: None. Every site he's written has come from the vast white wasteland of a plain text editor (he recommended gedit, by the way). I can't really blame him; nothing teaches you how something works like building it from the ground up.

So, I pulled all of the site's files down from the University of Hawaii server and set out to write my second website (the first being the v0.0 of this same website, but its layout was worthy of Geocities, and I don't really like to talk about it).

In this process, I've become much more familiar with HTML elements (and the fact that there are only about 20 or so relevant tags), cascading style sheets (CSS) to format the content, and browser versus server functionality. None of these would have come out of simply recopying the iWeb site. Throughout the process, the website HTML Dog proved an invaluable resource for me to constantly look up (and re-look up) the proper terminology for the effect I wanted to create.

As of today, the site is up and fully operational. Features I am particularly fond of are the Post-it "contact" info, and the embedding of this blog in the "News" page. If you'd like, go ahead and unsubscribe from the old blog's feed and add this one. Also, yay for comments.

Stay < marked up />
Clay