Alexander Saint Croix

May 15, 2008

Majority rule

Reading No Treason by Lysander Spooner. One salient comment:

"The principle that the majority have a right to rule the minority, practically resolves all government into a mere contest between two bodies of men, as to which of them shall be masters, and which of them slaves; a contest, that --- however bloody --- can, in the nature of things, never be finally closed, so long as man refuses to be a slave."

Sage advice, especially given the current rime-locked national discourse. I submit that the "two party" system is actually not two parties, but a binary tree of counterweighted factions.

May 13, 2008

Google Maps doesn't play well with itself embedded.

Please forgive the headline. I just used two embedded google maps on the same page, and the second one overrides the first one. I could pry apart the iframe code and fix it, but I think it nicely documents the error, so I'll leave it as is. If you want to see my actual evening route down Franklin, select the "permalink" at the bottom of that entry.

My evening commute down Franklin

This is my evening commute down Franklin. It's only 3.5 miles, and takes me about 15 minutes after 10PM. The most difficult part is in-between I94 and Franklin, at the Cedar Avenue intersection. That entire intersection is messed up something fierce. I can usually jam down Franklin at traffic speed and make the lights--from the University it isn't a bad route at all, but the reverse course is awful due to extensive road damage on the south side of the street. The shoulder is more like a crater field on the moon's far side. Not a pleasant ride at all, which is part of why I skip it in the morning.


View Larger Map

The "Dunn Bros" Commute

This is my "Dunn Brothers" commute, in which I stop off at the Loring Park Dunns location for a cup of Joe. It's about 4.8 miles, but feels like more because of the heavy traffic on Hennepin. By the time I cross over Nicollet Island I'm usually flush with adrenaline.


View Larger Map

April 26, 2008

Debunking the conspiracy theories behind the price of oil

With recent comments among colleagues and friends and corresponding paranoia on every news show from MPR to the O'Reilly Factor finally going over the brink into outright conspiracy theory, I thought I'd try to explain in simple terms how the market and Federal Reserve policy and not "big oil corporations" are deciding the price of oil.

Over the next three years to six months, oil will be the best investment you can make. Here's why.

An oil producer, "Party A", produces X number of barrels of oil per day, and places this supply on the local market. At this marketplace, buyers from the United States (population 301,139,947) line up beside buyers from China (population 1,321,851,888), India (population 1,129,866,154), Europe (population 490,426,060).

Party A decides to put the X barrels on the market at price P1. Conversely, the buyers from these respective populations place bids for Y barrels of oil at price P2. There can be a large gap between what people are willing to pay for oil, and what producers are willing to sell it for. In this case, no barrels of oil are sold.

However, in non-oil-producing nations, especially industrialized nations, there is no option but to consume oil, or face immediate starvation and collapse. Further, there are far more consumers than producers. In the past, when there were fewer consumers (the U.S. and Europe alone), the buyers had more leverage on the market. When there are only a handful of parties producing a commodity, it is called a production cartel.

In short, we need their oil more than they need our money. And China and India need the oil as well, because their economies are growing at rates that dwarf the economies of the U.S. and Europe.

Further, the U.S. Dollar is worth less every day than the day before. Our rate of monetary supply inflation is about 17% per year. This means that for every 100 dollars that exist in the world in 2007, there are $117 in 2008, $137 in 2009, $160 in 2010, $187 in 2011, and so forth. The Federal Reserve controls all aspects of monetary policy in the United States. It is not answerable to the United States Congress. The President has no control over it, aside from appointing the Fed Chairman.

Further still, in addition to there being more dollars in existence, there is declining supply of oil. There are very few discoveries of new oil fields in the world today. There are few new refineries being built. Because of well-intentioned environmental concerns, many known oil fields such as those off of the coast of Santa Barbara California and Anwar Alaska are being ignored.

Finally, consumers from industrialized nations are using more energy each year. In the United States, this equates to bigger vehicles, more air travel, bigger houses, fewer marriages (which imply the need for more dwellings and more heating requirements), more computers, big screen televisions, etc. One gulp of the atmosphere in Beijing is proof that China is quickly industrializing and using greater amounts of energy each year than the year before. Finally, especially in the United States and Europe, existing nuclear fission plants are being left to rot while no new fissile plants are being built, and there is little to no funding for serious research in advanced fission or groundbreaking (nonradioactive) fusion technologies such as that being conducted by Lawrenceville Plasma and Physics.

Wind and solar power do not have enough energy flux density to perform the heavy labor needed in the real world. Here are several examples:

  1. Solar powered airplanes do not and will never exist.
  2. Wind powered airplanes do not and will never exist.
  3. Solar powered cars and trains are not viable technologies.
  4. Solar power cells produce no energy at night.
  5. Wind power doesn't work when there is no wind.
  6. You cannot melt large quantities of steel with the electricity generated from solar panels.

How long does it take for a wind-power generator to generate the energy needed to replace the energy needed to mine the iron ore and cobalt needed to make the steel its made out of? How about the energy needed to smelt that ore, process it, shape it, and the sum combined energy needed to move the ore and the finished products to the generation site? Consider the same question for solar cells. Solar and wind power are net loss technologies.

Hydrogen fuel cells suffer from a related problem. Fuel cells are batteries. They do not produce power, but only store it in a chemical reaction. So, fuel cells are not the answer to the world's energy needs.

In other words, all forms of "clean energy" are actually just as filthy as burning oil and coal and using nuclear fission, because they all, without exception exist as derivatives of the real energy market. So, solar power isn't self supportive. Neither is wind power. They're nice ways to light up a home and provide widespread lightweight offsets to energy consumption, but they don't offset their requisite manufacturing cost. Industrial society is not currently possible without oil, coal and nuclear power. That's reality. The oil is running out, and every new dollar makes it more expensive. Every new mouth to feed in the world increases its price.

So, let's review.

  1. The price in dollars of oil is a function of:
    • international supply of oil
    • international demand for oil
    • the supply of dollars available with which to purchase the oil
    • the supply of other currencies available to purchase the oil
    • the availability of other forms of usable energy
  2. The United States congress does not control the price of oil.
  3. Hillary Clinton, Barack Obama and John McCain do not control the price of oil.
  4. There is no conspiracy to hike up the price of oil.
  5. In order to halt US Dollar price increases in energy in the U.S., we would need to either increase our own production of industrially usable energy by 17% per year, or reduce the rate of dollar inflation. In addition to this, we'd need to be 100% self-sufficient in energy AND either eliminate world economic growth, OR forbid energy exports.

What the United States as a technologically advanced society and a leader of the world should do is heavily invest in clean (non-radioactive) fusion technologies to replace aging nuclear fusion technologies such as the dense boron-hydrogen plasma fusion reactor, and move aggressively to render oil and fissile energy production obsolete. In the meantime, we should alter our weak dollar policy, make effective use of our native coal and oil resources, and probably invest in intermediary clean fission plants. We should build more railroads, get trucks off of the freeways, and live closer to where we work. More people should ride bicycles for jaunts around town. And we're going to have to do all of these things in concert in order to survive the energy reality of the 21st century. The 20th century is over, and we can't pretend otherwise or legislate our way out of our problem.

The parties most capable of making many of these needed advancements are "Big Oil" and "Big Corporations". Punishing these parties for helping keep us alive is suicidal. Solar and wind power are only a small part of the solution. We should get out of the way of U.S. energy companies and do what we can to help them move the ball forward. Foreign producers have the most to lose from a new energy revolution in the United States, and that would be sweet justice, wouldn't it?

April 24, 2008

Mint Properties LLC

About 6 months ago, my apartment building in Minneapolis, which was previously owned by Stevens Court LLC was sold to Edina-based Mint Properties LLC. At first I was surprised, then disappointed that I'd no longer be able to continue the successful working relationship I'd already developed with the staff at Stevens Court. With all of the trouble we went through last winter, I was particularly concerned that there was no local office, but that our new ownership was located out of town.

So, I decided to wait and see. I have not been disappointed.

First of all, the improvements made last year to the building have been effective in reducing crime and improving quality of life for this resident, and I imagine others. I am filled with gratitude for the work of Jenny Carrier and her crew. There was not an abundance of obvious criminal activity this winter, no transients sleeping in the hallways, or any of that nonsense. Instead, we have a distinct and firm new ownership whose mettle I unfortunately had to test this winter.

In January, I noticed the distinct sound of a rodent in my ceiling. I figured it was a squirrel, based on the abundance of them in the neighborhood and their repeatedly proven ability to climb up the exterior walls. I did not, however, begin to panic, until I found an 8-inch mound of ceiling-stuff atop my refrigerator, and a clearly chewed hole in the ceiling.

I made several calls to the repair technicians, who over the course of about four weeks attempted to poison the squirrel, then decided to battle cold and icy conditions and effect repairs to the exterior of the building and to eventually patch and repaint my ceiling. Throughout the whole process the repair technicians (notably Kyler) and also the telephone operators at Mint Properties have been the modicum of professionalism and respect. In both cases that I needed to call the repair technician was on site within 30 minutes, which greatly eased my fears of having a remote management office. They've even gone so far as to call me at work in order to keep me appraised of the progress.

So, following my New Year's pledge to write about things I appreciate, here's my hat off to Mint Properties. Welcome to the neighborhood.

April 19, 2008

The tense relationship between JPA, enums, and generics

In the last two months, I've come to understand in excruciating detail the various tradeoffs between using generics and enums in my JPA-ready entity library. Most recently, I've been inspired to write down some of my notes, to save myself and others some headache in the future.

First of all, as always, a pattern is necessary to illustrate the problems I've seen. Consider the task of persisting a unit definition. Here are some examples of instances of a Unit object: kilogram, second, meter, candela.

Clearly these objects all would benefit from having a name, description and ID field. But consider these as well: joule, watt, newton. Now, the first three units were SI base units. The second three can be defined in terms of the first three. For example, a newton is equal to m∙kg∙s−2. So it becomes clear that units need to be able to be defined according to an underlying terminology.

So, let's say we have a Term class, with a coefficient, a radix and an exponent. The newton Unit instance would now contain a List of three Term instances. The first term has a coefficient of 1, a radix of the "meter" instance, and an exponent of 1. The second term is much like the first, save for the fact that its radix is equal to the "kilogram" instance of the Unit class. The third follows a similar pattern, but in addition to referencing the "second" Unit instance, it also has an exponent of -2.

Now, for consistency and convenience, we'll define base units in terms of themselves. So, a "meter" instance contains a list of one Term, with a coefficient of 1, a radix of the "meter" instance, and an exponent of 1.

Finally, we can also give the Unit class a boolean field, in order to distinguish between base units and derived units. This very basic definition of units and terms will suffice for what I'm trying to explain.

Now, so far, we have two entities, Unit and Term, and a very simple Many-to-Many relationship between them. But here's where the trouble starts.

Part of the purpose of capturing the concept of a Unit in an object-oriented manner is so that we can use them to create constraints on logical behavior that are more rich and efficient than we'd be able to accomplish were they mere text fields. We also want to capture, in some way, the relationships between different units.

To illustrate the first point, consider that you're writing an application where you want to add together a collection of units to determine their sum total. Now, imagine your assumption is that you're trying to get a combined measurement of mass. If you have an object that represents "3 kilograms" and another that represents "5 kilograms" you can easily accomplish this. But what if in addition to these, someone slipped in an object representing "4 seconds"? What is 3kg + 5kg + 4s?

Now we're dealing with dimensional analysis. There are rules that stipulate, you cannot add these together. It'll break your logic. So, what you want to do--what you need to do, is to somehow capture the idea that your "kilogram" units are tied to the concept of "mass", that your "second" objects are tied to the concept of "time", that your "tesla" objects are tied to the concept of "magnetic flux density", and so forth.

But what are these concepts "time", "mass", "magnetic flux density", "photoelastic work", "molar entropy", and so forth? Well, it turns out there is some fog in the answer to that question. Depending on which poorly written wikipedia article you find, these concepts are collectively called "quantities", "dimensions", "magnitudes" or even "quantitative properties of particles". It turns out there is no highly rigorous name for them, but since Object-Oriented programming is nothing if not nominalist and aristotelian in nature, they needed to be named. In order not to limit my future use of the above terms, I decided against adopting any of them and named these objects according to their relationship to the Unit. Since these concepts serve to limit the scope of what the unit can be used to quantify, I refer to them as the Quantitative Scopes of a unit. Please, if you're a physicist studying dimensional analysis, don't be upset.

Because, whatever these are called, we are now straying into trouble with Java. Case in point, how does one best represent a quantitative scope?

Well, generics give us one tantalizing option. I'd like to be able to create a new Unit<Mass>(), and keep it in a Set<Unit<Mass>>. I think this would afford me with the best and easiest way to constrain the use of these units. However, that leaves us with the difficult problem of how "Mass" is represented.

We have only two options here. Class or Interface. Class is problematic, because every instance of "Mass" would be identical to every other. So, it makes more sense to use Interfaces. Ah, but herein lies the rub, because our original goal was to make these objects persistent. And Interfaces, bless their bytecode, certainly do not fit this bill.

So, it seems objects are the only option. But this, once again, leaves us with the problem of instance control. I could rattle off 126 examples of a QuantitativeScope object, each differing from the other only in name. But if we define each as a class, then presumably we'd have 126 database tables filled with carbon copied records, which is just not going to happen. Thus, the quandary. Interfaces cannot be made persistent, but classes are the wrong instrument to accomplish the goal.

Well, what about enums? It's an idea--an enum would nicely solve the persistence problem, but it doesn't save us on the application layer because enum-valued objects cannot be used in generic fields. Furthermore, enum-valud objects cannot be given generic fields themselves. This makes sense, given what enums are for, but it leads us back to the same problem. How, given all three of these tools, are we to accomplish the goal of being able to discriminate easily between units of different quantitative scope while not abandoning the ability to persist the objects?

I came up with an ugly hack to solve this problem. The good news is that it makes the best use of the available technology that I'm able to determine. The bad news is that it's an ugly hack and it fills me with doubt about Java and JPA. But I'm invested in making this work, so here goes:

First, I created a "Scope" enum, with 126 different values in it. Scope.Mass, Scope.Time, etc. Then, I made 126 corresponding interfaces, "Mass", "Time", etc., that extend a base "QuantitativeScope" interface. Third, I made a generified "Graft" class that serves to bind one of these interfaces "Q extends QuantitativeScope" to one of these enum-valued objects. Finally, I defined a library class containing 126 public abstract final instances of this "Graft" class, each mapped to the appropriate "Scope" enum-valued object. With these graft instances, I was set.

Now, when defining a Unit, I can pass one of these "Graft" objects to the UnitFactory. It can get both the generic type from this Graft object, and assign the Graft.getScope() enum-valued object to a "scope" field in the Unit class. When I persist the Unit into JPA, the "scope" field, which is defined as @Enumerated(EnumType.STRING), goes into the database. When I get a collection of Unit objects back out of the database, I can run them through a seive and inspect each of their Unit.getScope() values in a switch statement, then place them into appropriately generified Set objects. This piece works sort of like a coin sorter, but when I'm done I can ask for the Set<Unit<Mass>> and know that my results are reliable.

The main problem with this workaround is that I had to duplicate a lot of data and encase it into interfaces, a large enum, and a graft object library in order to make it function. There are other lingering problems with this approach as well, and I'm sure that I'll uncover more and more of them as I continue.

What this has taught me is that enums and generics are exceedingly tricky to use. Although with generics, Types can now be used as compile-time constraints on behavior, they don't help you at runtime, and are therefore tough to work into a persistence application. This worsens the intrinsic impedence mismatch between the application layer and the persistence layer in application design. Further, enums in Java behave like pseudotypes, somewhere between Interfaces and Classes, but because they cannot be used as Generic Types, they even further aggravate the impedence mismatch when worked into a persistent application design. If I could have used the enum valued objects in the generic fields, this would be a non-problem.

Finally, the best solution for my particular problem might have nothing to do with enums or generics after all. What I'm trying to replicate through this design is actually Invariants, Preconditions and Postconditions on method behavior, class definitions, and collection compositions. There are languages such as VDM-SL and Eiffel that wonderfully exemplify this sort of language feature, and old tools such as iContract that might make it useful in Java, but it's a shame that these useful tools are not built into the language itself.

The views and opinions expressed in this page are strictly those of the page author. The contents of this page have not been reviewed or approved by the University of Minnesota.