Friday, February 27, 2009

Perhaps I Need to Change What I Say

So, Jeff came up with a fun game with Vinny, in which they sing,

Oh, I'd like to be (a/an) ____
Oh, I'd really like to be (a/an) ____
Because (a/an) ____ (does/has/goes) ____
For example, "I'd like to be a cow, because a cow goes moo" or "I'd like to be a tree, because a tree has branches." Generally Vinny decides the subject of the verse, comes up with the action of said subject, and then they act it out.

Yesterday, they sang
Oh, I'd like to be Mama,
Oh, I'd really like to be Mama,
Because Mama goes "No, sir!", "Stop right there!", and "I missed you all day long!"
(At least one of the three is positive!)

Tuesday, February 24, 2009

Mystery Meanings

There are a few phrases that Vinny has picked up, but which he does not seem to actually understand.

For example, he says "any more" when he actually means "right now." As in, "I like some milk any more."

But one that baffles me is "I promise." He seems to say it at the most bizarre times. I can't even give an example because it is so baffling.

Sunday, February 22, 2009

Adventures in Linear Programming

One of my fearless readers (okay, my brother-in-law!) lamented the recent lack of mathematical content in this blog. I'm sure that he's not the only person who reads this blog just for the math. So, without further ado, I present a topic I've been working on lately: linear programming.

Suppose that you're wanting to get back into shape, and want to develop a good, healthy diet to go along with your exercise regimen. You know that you need to eat 2000 calories (for example), less than 300 g carbohydrates, at least 25 but less than 75 g fat, and 90-120 g protein.*

Perhaps we want to minimize the cost of this new diet. Then if we knew the cost and nutritional content of all foods, we could set up the following optimization problem:

minimize diet ∈ foods Cost(diet) subject to
Calories(diet) = 2000
Carbohydrates(diet) ≤ 300
25 ≤ Fat(diet) ≤ 75
90 ≤ Protein(diet) ≤ 120.

This is what's known as a linear programming problem. It's linear because the equations we're trying to solve or use as constraints are all linear -- x grams of potatoes has twice as many calories as x/2 grams. The term programming is historical and does not have anything to do with computers -- think programming as in scheduling.

As the name implies, linear programming problems often arise in the logistics and economics fields. For example, you own a chocolate factory and want to make the maximum profit, subject to constraints on demand, supplies, and labor. Or more generally, many commodity markets (e.g., soybeans, wheat, etc.) can be modeled with a linear program.

An Alabama sheriff who was recently convicted of starving his prisoners could have benefited from using linear programming. Alabama sheriffs are allotted $1.75 per prisoner per day for food, and get to keep the extra cash they don't end up spending. Instead of computing the optimal diet for his prisoners (for which he could have pocketed $0.79 per prisoner per day), he chose to skimp on their diets instead.

(Of course, the optimal diet is kind of disgusting, consisting of carrots, peanut butter, air-popped popcorn, baked potatoes, and skim milk. It may be optimal for cost but it's decidedly sub-optimal in terms of taste! Construct your own diet here.)

Suppose you want to make the maximum amount of profit from making widgets at your factory. You have labor, material, and shipping costs, which can be represented by linear functions of the number of widgets. The problem is, you can't make 5247.68 widgets: you have to make an integer number of them.

Problems that contain both integer and continuous variables are known as mixed-integer programs. Our diet example might be better posed as a mixed-integer linear program -- it would make more sense to eat an integer number of bananas than to eat 128.6 grams of banana (for example).

Mixed-integer linear programs are hard to solve -- they have been shown to be NP-hard. But for many of these problems, you can use a relaxation into a linear program (relax the requirement that the integer variables must be integer) as a lower bound, and find the solution using a branch-and-bound, branch-and-cut, or branch-and-price method.

Branching has to do with dividing the problem domain into pieces. If we have an integer variable constrained to be between 1 and 10, for example, we could branch it into two pieces, one containing the domain 1 through 5, and the other containing 6 through 10. If we know that the global bound from the linear program is bigger than the solution for any of the integer solutions in a given branch, we can remove that branch from consideration. We would then further subdivide the active branch until we are able to find a unique solution.

This type of branching algorithm is inherently parallelizable. First, we would solve the relaxation of the mixed-integer problem and broadcast it to all processes. Then, we would assign branches to processes, which would then eliminate or further subdivide branches as appropriate. If done naively, we would end up with all the work being done by the one process that originally owned the branch containing the solution, while all the rest of the processes are idle. Instead, good parallel implementations of branching algorithms adaptively reassign new sub-branches to idle processes.

I am working on solving a big mixed-integer linear program that represents the biofuel supply chain infrastructure. I know next to nothing about biofuel production, but my other collaborators do. My expertise lies in solving the problem in parallel on leadership supercomputing resources. I'm really excited about solving these complicated problems at this large scale!

* Note that I totally made up these numbers and if you're actually wanting to get back into shape you should consult your physician, not an applied mathematician.

Friday, February 20, 2009

Supercomputing Course: OpenMP Directives

Last time, we talked about OpenMP syntax and some directives. Next we'll talk about a few more.

The sections directive is useful if you have a few separate parallelizeable tasks that you want different threads to run. For maximum portability and efficiency, I don't recommend this directive, for reasons that you will see. But if you have a couple of different tasks to parallelize, here's the syntax you would use:

#pragma omp sections
    #pragma omp section
    /* first section */
    #pragma omp section
    /* second section */
As you can see, in the example above, if you had more than two threads, only two of them would be used, and the rest would be idle. If this is the only way you can parallelize the work, then it's better than nothing, but if there's another angle to attack the problem, then I'd try that.

In certain algorithms, you may need thread synchronization. It could be that you have a task that depends on a previous task being completed, so you need to make all the threads wait until the first task completes before going on to the second. Or, you may have a task that's not thread safe, so you need to have only one thread at a time perform that task. Or you may have a task that only one thread can perform. If so, you are in luck, because there are synchronization directives just for these purposes!

The barrier directive creates a stopping point which a thread reaches and cannot proceed past until all the threads have reached the barrier. The threads don't all have to reach the exact same barrier call in order for them to stop there, but they do have to encounter the same sequence of work-sharing and barrier regions. The syntax is wonderfully simple:

#pragma omp barrier

The critical directive specifies a section of code which must be executed by only one thread at a time. Give each critical section its own unique name; otherwise all identically named critical sections considered the same critical section.

#pragma omp critical [name]
// code

A single section is useful for parts of the code that must be executed by only one thread, e.g., writing out to a file.

#pragma omp single
// code

There are many other directives, but I'll just cover one last one: reduce. The reduce directive is used to reduce a list of variables into one, using an operator such as sum, product, etc. In C, valid operators are +, -, *, &, ^, |, &&, or || . Here is an example:

#pragma parallel for reduction(+:n_eq)
for (i = 0; i < N; i++) {
   if (a[i] == b[i]) {
     n_eq = n_eq+1;

Next installment: Variable scope

In Which My Cellphone Causes Me Havoc

Yesterday, while I was in a seminar, my cellphone rang. I was really embarrassed, because I'm usually good about turning it off during a seminar -- and besides, I never get any calls anyhow. In my flustered state, I couldn't figure out how to stop the ringing. So I decided to rush out of the room with my ringing phone. In my haste, I managed to twist my left ankle. And of course, by the time I got out of the room, the phone stopped ringing!

I hoped I could just walk it off, but I'd sprained it pretty well. So I had to go to the medical center at work, even though I knew would lead to a pile of paperwork. They gave me some ibuprofen horse pills to take and a coldpack, and fitted me with a figure-eight brace on my ankle. The nurse was also kind enough to fill out my paperwork for me, and then I had to give a copy of it to my boss and confess to what I'd done.

He was very kind about it and didn't make fun of me too much, even though my accident at work meant more paperwork for him. But he did have to get his boss to sign some of the paperwork, so then when I saw him in the hallway, he said, "Hey Rebecca, I heard you twisted your ankle!" Just what I wanted: to be remembered by my boss's boss for my lack of coordination.

As for the ankle, it's still pretty sore. They told me not to run for at least 5 days, which puts a damper on my training. Also, driving my manual transmission car was somewhat challenging, so I switched cars and drove the automatic today. My running friend teased me about the lengths I go to in order to get out of running! In reality, I'm pretty embarrassed by my missteps and hopefully my ankle will heal quickly.

Wednesday, February 18, 2009

Understanding Motivations

I believe it was Vice President (then Senator) Joe Biden who said in a debate that he interacts with people under the assumption that they are motivated by good intentions. I tend to agree with him, that most of the time, people are trying to do something good, even if their actions actually turn out to be harmful.

Even the 9/11 hijackers were trying, in their own sick way, to do something good.  They were convinced that the United States was the Great Satan, so taking us down a notch would be an improvement (from their point of view).  Unfortunately, they were so brainwashed and consumed by hate that they were unable to do something constructive that would strengthen the position of the oppressed people with whom they felt kinship.  And in fact, thanks to their act of terrorism, Muslims are now more reviled and abused by Americans than ever before.

Other behaviors with a much lower magnitude of destructiveness are similarly performed with the best of intentions.  A woman who remains in an abusive relationship is doing so because there is some way in which the relationship benefits her -- perhaps she doesn't believe she can survive on her own, and being with an abuser is better than being alone.  Or a person who gets caught up in religious fanaticism -- there might be a void in that person's life that is filled by ascribing to this oppressive and rigid world view.

Like I was saying in an earlier post, thinking about others with compassion can help keep you from getting angry when people treat you poorly, but there's more to it than that.  Understanding (which does not mean agreeing with) others' points of view can help you to figure out how best to relate to others.

Tuesday, February 17, 2009

I Would Laugh if It Weren't So Sad

Four super-genius Republicans in the Tennessee legislature, hell-bent on making our state look even stupider than it is, have joined in a lawsuit put forth by a Russian immigrant, demanding that President Barack Obama show his birth certificate and prove that he is a United States citizen.

Never mind that he already did that.  But even if he hadn't, and even if he was born in Kenya, he's still a natural-born U.S. Citizen under the law.  It's also a problematic move on their parts, because without any evidence to support their claims as plaintiffs, our legislature's best and brightest aren't going to get real far.  So glad we have smart men like these, with such a deep understanding of legal procedures, involved in the creation of laws in this state.

Sunday, February 15, 2009

Staying Happy in the Face of Anger

Something I have learned over the years is that the cause or trigger of other people's negative behaviors is often something I would not have guessed, and 99.999% of the time it is completely unrelated to me, no matter how personal it may seem.*

This point was really underscored one day when I was trying to get home to Urbana from Chicago-O'Hare airport. (Or, should I say, one night.) I missed the final flight home for the evening and managed to convince the airline to comp me for a shuttle, which I knew left every three hours. At midnight, the shuttle arrived, with three people waiting for it and only one space left. One of the contenders for the seat said that he really needed to be the person to go on the shuttle, because he had to be at work for his shift at 6 a.m. I didn't have any committments that I couldn't rearrange, so as far as I was concerned, he could have the seat. While the other woman waiting for the shuttle didn't have those constraints either, she was really angry about being deprived of the seat. But since two of us had agreed that he should go, there wasn't much she could do about it. The driver recommended that the two of us remaining call and reserve seats for the 3 a.m. shuttle.

The angry woman then called the reservation line on her cell phone before I was able to call myself. She then proceeded to chew out the reservationist for at least ten minutes. There was so much shouting, berating, and rudeness being emitted from her that I had to leave the vicinity. I stood inside where I couldn't hear her, but could still see her through the window.

Finally, when I saw her hang up, I called the reservation line. The reservationist was extremely defensive, and quite frankly, a bit rude to me. But I let her vent, because I knew what she had just been through, and it did not upset me at all. I thanked her for her help, hung up, and waited for the shuttle.

I don't know what had made the original angry woman so angry. I will never know that. But I did know what made the reservationist so angry! And because I had that knowledge, the reservationist's angry words had no adverse emotional effect on me, and in fact I was able to help her get over her negative feelings.

Had I just randomly called for tickets at that particular moment, however, I would not have possessed that knowledge. I might have been confused, angry, or offended by her rudeness. Or, if I thought about it, I might have drawn the conclusion that something else is bothering her, and I'm just in the wrong place at the wrong time.

In no way am I trying to excuse the behavior. As a professional customer service representative, she really should have found a way to either protect her emotional state when talking to an angry customer (although this had to be one of the angriest customers ever, so I can understand why that didn't work), or to cool off between calls.

And in fact, there are people who are chronically grumpy and rude (talking to her as we waited for the next shuttle, the angry woman struck me as overly negative and unreasonably demanding), and their behavior needs to be corrected (by a professional, not by me). But understanding that it's nothing personal can really make a difference between getting your buttons pushed and remaining happy in the face of negativity.

* By "other people" I mean a person whom you encounter but do not actually know. Your actions may cause your spouse or other intimates to get angry, although even then, sometimes it has nothing to do with you.

Friday, February 13, 2009

The Hackers Who Cried Wolf

The only problem with hacking the road signs to warn of zombies is that in the event of an actual zombie attack, no one will believe the warnings.

Wednesday, February 11, 2009

Running Equipment

For running, they say that first and foremost, you need good running shoes.  "They" must be male, or maybe a woman with a small endowment, because for me I think that the first and foremost need is a good sports bra.

When I went to buy one, I went to a running store, where a similarly well-endowed woman working there recommended a particular model -- the Moving Comfort Fiona.  She said it was the kind that she wore while running.  Her testimonial was a golden recommendation, so I tried that one on for size, and bought it.

And she was right.  I no longer reach the resonant frequency of my chest with my stride or even jiggle.  It's like being twelve -- only without having to go through the misery of puberty or junior high again.  I loved this bra so much that I bought two more off the internet on sale (2 for less than I paid for the first one).  If I had my way, I'd wear them all the time!  Unfortunately, they're not exactly suitable for all occasions.

Tuesday, February 10, 2009

Running Update

I'm still running with my friend at work on Mondays, Wednesdays, and Fridays.  I'm getting a lot better at it.  The first time I ran, it was a mile distance (alternating running and walking) and it took me quite some time for my heart rate and breathing to get back to normal.  Then, running the same distance the next time, I didn't get quite as exhausted.  Now, I'm going nearly two miles (not yet running all the way) and feeling less exhausted than I did the first time I ran.

So I'm feeling pretty good about running and at this rate, I should be able to run a 5K by the end of next month as planned.

Sunday, February 08, 2009

Hair Tales

One of my favorite personal physical attributes is my hair. It's on the dark side of the brown spectrum, with a few lighter streaks created by sun exposure. It's mostly straight but there is a bit of wave to it. I usually keep it at shoulder length or longer -- I prefer it a length that's long enough to do fun things with.

I have a lot of hair: Not only do I have a lot of individual hairs, but each one is thick. But this means that my hair is virtually indestructible, which is a good thing. I do take pretty good care of it, but I don't go to the lengths that some people do. I wash and condition it with the same shampoo and conditioner that I've been using for more than a decade -- Head & Shoulders for Dry Scalp shampoo, and Pantene Pro V conditioner. I remember a hair stylist being horrified at my choice of hair products and trying to sell me something else (much more expensive), but I didn't budge. Any time I change shampoos, I am faced with massive dandruff problems; and other conditioners aren't strong enough to keep my hair from entangling itself.

When I was a child, I was not so keen on my hair. I liked having long hair because I liked pony tails and braids, but the upkeep was a pain (literally!). I don't know if conditioners didn't exist then, or if my mom just didn't know about them, but if I had used a conditioner as a child, my mornings would have been much less painful.

As an undergrad, I discovered the wonders of conditioner and from then on I could work with and manage my hair. I began experimenting with braiding my own hair. I got really good at French braiding my own hair -- I can still do it, without the need for a mirror. The French braid became my regular hairstyle.

In graduate school, I continued to keep my hair long and French braid it every day. At one point I did get it cut because it was getting too long to braid myself. I also cut ten inches or more twice while I was in graduate school, and donated it to Locks of Love.

Before I began interviewing for jobs, I got an expensive haircut so that I would look more polished and professional. It was a nice haircut and I liked the way it looked, but I did miss braiding my hair. During the first part of my postdoc, I just let it grow back out. And during my pregnancy, those prenatal vitamins helped it to grow even faster. Nearly two years ago, I again cut it off and donated to Locks of Love.

Since then I've let my hair grow out again. Right now, it is maybe 4 inches longer than shoulder length, and just perfect for making French braids (although most of the time I'm in such a hurry that I just pull it back into a ponytail and run). I don't know what I'll do with it next.

Saturday, February 07, 2009

Sunny Saturday Afternoon

Today was so beautiful that we had to get out and do something. After a week of below-freezing temperatures, today was sunny and warm and there was no excuse not to spend some time outdoors. So we went to the Museum of Appalachia, a 60-acre living history museum about the history of Appalachia.

They have a large collection of historical buildings brought in from across the region, and historical artifacts from the era. They also have a lot of animals, including sheep, turkeys, chickens, and peacocks. Vinny enjoyed running around and looking at the animals and buildings. Unfortunately there were a lot of really interesting objects everywhere that he was not allowed to touch, which detracted from the experience for him somewhat.

But it was a lot of fun to get out and enjoy family time in the sunshine on a leisurely Saturday afternoon.

Friday, February 06, 2009

Black History Month, Take II

My trusty violin and I have once again joined the Black History Month choir.  This year, however, I got the bright idea to perform something by an African-American composer of classical music.  I knew I had a friend/colleague who played the piano, and the other violinist from last year was interested in playing too.  

So I recruited my piano-playing friend/colleague* to join me and the other violinist in playing some works of music by William Grant Still.  We're playing selections from his "Minatures," which were written for flute, oboe, and piano.  Obviously we're substituting violin for flute and oboe, which mostly works because they have approximately the same range.  But we did make some changes so that I didn't have to spend the whole flute part slicing my fingers on my violin's E-string.

I really like these pieces -- they are settings of American (not U.S. -- the continent) folk songs but they are not just simple and straightforward.  He's got some clever twists and turns in there.

I must admit I'd never heard of William Grant Still until I started looking for music to play, but he was quite a remarkable person -- just read his Wikipedia biography referenced above.  I like his music enough to try listening to one of his symphonies or something.

* This is a danger that friends of mine who also play musical instruments often find themselves in -- this is not the first time I've recruited someone to join a weird musical ensemble.

Wednesday, February 04, 2009

Not Quite Right

I recently discovered that you can plan walking routes using Google Maps. So of course I had to try out my dream walk: Land's End to John O'Groats. But something is a little bit wrong (click to enlarge):

A close-up of the part in question:

Perhaps these directions are for the Son of God rather than mere mortals such as myself.

To be fair, they do recommend that you take the ferry for the parts that go over the water. But still, a rather unusual route...

Tuesday, February 03, 2009

Proud Moments in Motherhood

It is kind of sad how proud one can be about one's offspring's elimination habits. But I must say that I am incredibly proud of the progress my dearest child is making in the potty training arena. Skip this entry if you don't care.

He has now pee-peed in the potty twice. But more importantly, he's starting to recognize the signals from his body. Last week, during an evening bath, he told me he needed to pee, so I took him out of the bath to sit on the potty. Unfortunately, I didn't leave him on the toilet long enough, because he peed right after I put him back in the bath, but I was pleased that he seemed to know that he needed to pee. Similarly, on Saturday night he said he needed to go poo-poo, so I set him on the potty and a little tiny something came out. I was really proud of him for that.

Monday, February 02, 2009

Spring Is on Its Way

Yesterday was just a beautiful day -- warm and sunny.

Vinny and I spent much of the afternoon on our deck. We chased each other around the deck, lay on our backs and looked at the clouds, and basked in the sunshine. I saw the tips of daffodils peeking out of the ground in our front yard. And for dinner, Jeff grilled us some salmon and corn on the cob.

It may have snowed today, but I know that Spring is on its way!

Sunday, February 01, 2009

Back from the Funeral

Thanks for all your thoughts and prayers. We got back home yesterday evening. It was a whirlwind visit but overall a positive experience.

We had been worried about the weather, because earlier in the week, a huge ice storm had dumped all over Western Tennessee, Kentucky, and Indiana. We got only rain from that storm, and while Nashville had some ice, it was all gone by the time we drove through. But as we proceeded north, things really changed. At first, it was just some ice on the treetops. Then, we saw some snow on the ground too. Then, it was ice all over the trees, with a little snow, followed by ice and more and more snow. By the time we got to Evansville, there was ice and at least a foot of snow.

The roads were scary in places. We could see lots of severely damaged guard rails by the sides of the roads, and tire tracks that led down into ditches. At one point, we even saw a truck trailer that looked like it had been cracked in two, like an egg. And a person a couple of minutes ahead of us took an icy section of road too quickly and rolled before coming to a stop, as evidenced by the vehicle's crushed side mirrors. They were just getting hooked up to a tow truck as we passed.

The storm had knocked out power throughout the region. There were towns in Western Kentucky that were completely dark. The gas stations that had electricity had long lines of cars waiting at them, while the ones without power looked like ghost towns. The hotel where we had originally planned to stay in Evansville was without power, so my dad scrambled around and found us all a new place to stay. It was hard to find a place with any rooms, because many Evansville residents were staying in hotels while their power was out. My Evansville-resident family were also without power, but they were able to stay at home or with other relatives (from the other side of their family).

After some white-knuckle driving, successfully performed by my highly skilled better half, we arrived Thursday evening in time for the visitation. It was really amazing to see all the family members who were there. Out of all my generation, only two blood relatives were missing (out of 20 or so). They came in from as far away as the west coast and Europe. It was heartwarming to see them all.

During the funeral service on Friday, we all got a chance to speak about my grandmother. The minister characterized her as "slow but determined" and "small but mighty." Everyone agreed that she was a very loving and generous person, known for her love of family and works of charity.

My sister Rachel wrote the most lyrical poem in Grandma's honor. I managed to remain pretty straight-faced during the whole funeral (having done most of my mourning the previous weekend), but her poem really hit home and brought tears to my eyes. I could never do it justice, but suffice it to say that every word in the sonnet she wrote was carefully crafted and perfectly chosen. She was able to express in those fourteen lines what I would have wanted to say but could never have expressed in a million. They are going to make a plaque of the poem and put it in a special garden dedicated to the memory of my grandmother, in the family arboretum.

We spent the rest of the afternoon and evening with the family in the fellowship hall of the church, sharing pizza and catching up with each other. There is really no substitute for family at a sad time like this.

Friday evening, I persuaded my dad to borrow some swim trunks from one of his brothers and help me take Vinny on his first swim, in the hotel swimming pool. At first, Vinny didn't quite know what to make of the swimming pool, so we just sat him on the side and let him kick and splash. But after he saw Grandpa get in the water, he decided to try it too. Mostly, Dad and I just held him and jumped up and down in the water. We also let him "swim" between us by passing him from person to person. He had the greatest time, and cried a lot when it was time to go. The next morning, he was asking to go swimming again. This tells me that I need to sign him and myself up for baby/parent swimming lessons.

Coming home yesterday, the roads were not nearly as treacherous as they were on Thursday. It was really good to be home and to sleep in my own bed again last night.