Archive for January, 2008

Datasets and Organization

New for this semester is a course on databases. Of all the work I have done so far, however hard/frustrating/educational it has been, it is worth the price of admission to this class. This is the first ‘hands-on’ class I will take that might establish a skill that will generate income dollars in the future. This is big-boy stuff, even though we are toddlers compared to the professionals.

Tonight I will download and install Microsoft’s SQL Server 2005. If it works, and it didn’t the first time, I will create my very first (and small) database.




First Program of the Semester

So the professor asks us to write a program in Python, after which she will show us the same program written in Java. The program was easy to develop conceptually, and the programming was, for the most part, easy. There were a few looks back into our Python Quick Reference, but not bad after a 4 week layoff. We’ll see what she thinks about the algorithm and the design. I expect the Java version to be way more complex, from a syntax point of view.

Here’s my code…..feel free to comment; it’s already been submitted so your thoughts will not incur an Honor violation.


import math

def ordQty(): # Get order quantity

n = input(“How many bags of coffee do you want to order? “)

while n <= 0: # Makes sure order is larger than 0

print”Invalid quantity. Your order must be at least 1 bag.”

n = input(“how many bags of coffee do you want to order? “)

return n

def discountTable(n, cost): # creates discount based on volume (per assignment parameters)

if n < 25:
discount = cost * 0.0

if n >= 25 and n < 50:
discount = cost * .05

if n >= 50 and n< 100:
discount = cost * .10

if n >= 100 and n< 200:
discount = cost * .15

if n >= 200 and n < 250:
discount = cost * .20

if n >= 250 and n < 300:
discount = cost * .25

if n >= 300:
discount = cost * .30

return discount

def boxTable(n): # calculates number of boxes required for order

A = n / 20 # A is the variable for large boxes. Returns an integer value

remA = n % 20 # remA calculates the remainder value for the A box divisor

B = remA / 10 # B is the variable for the medium boxes. Returns an integer value

remB = remA % 10 # remB calculates the remainder value for the B box divisor

C = remB / 5.0 # C is the variable for the small boxes. Returns a float value

Last = math.ceil(C) # Use ‘ceil’ function to determine next highest integer

costA = A * 2.0 # costA is the box charge for large boxes

costB = B * 1.0 # costB is the box charge for medium boxes

costLast = Last * .50 # costLast is the box charge for small boxes

boxCharge = (costA + costB + costLast) # Calculate total box cost for return

return boxCharge

def main():

n = ordQty()

cost = n * 5.50 # calculate cost of coffee before any discount

print “You have ordered”,n,”bags of coffee. The price is $%0.2f” % (cost)

discount = discountTable(n, cost) # create discount function, return discount amount

print “Your quantity discount is $%0.2f” % (discount)

boxCharge = boxTable(n) # calculate number of boxes required and cost

print”The box charge is $%0.2f” % (boxCharge)

totalCost = cost – discount + boxCharge # calculate order total

print “The total cost of your order is $%0.2f” % (totalCost)



The output of a test run:


How many bags of coffee do you want to order? 999
You have ordered 999 bags of coffee. The price is $5494.50
Your quantity discount is $1648.35
The box charge is $100.00
The total cost of your order is $3946.15


We Love Python


Starting My Engine


Tomorrow’s the big day……the start of the spring semester. Books bought, parking paid, pencils sharpened, and as much preparatory studying under my belt as my wife and friends would countenance. Truth is, I’ve been ready for tomorrow for a month of yesterdays. Walking the campus yesterday, it was good to see former classmates, former professors, and a few future professors also readying for the journey.

Ready, set Go!!!!!!!

Evolution Through Genetic Algorithms

Genetic algorithms are a subject somewhat beyond my ken. But it doesn’t take a geneticist or a computer scientist to comprehend the implications of the process. The possibilities are explosively revolutionary.

From our fellow bloggers at Q and O, a glimpse of what the future might portend. A slice to entice:

One of the consequences of growing computing power is the feasibility of generating improvements through what you might think of as a massive trial-and-error approach. Random variations are introduced into designs, and the results are measured against some metric to see which ones do best. Those best variations are then “cross-bred” with other good variations to see what comes out.

The result can sometimes be dramatic improvement over anything a human designer can come up with. For example:

At the University of Sydney, in Australia, Steve Manos used an evolutionary algorithm to come up with novel patterns in a type of optical fibre that has air holes shot through its length. Normally, these holes are arranged in a hexagonal pattern, but the algorithm generated a bizarre flower-like pattern of holes that no human would have thought of trying. It doubled the fibre’s bandwidth.

When I think about the application of this technology, plus the real genetic manipulation going on in biology, and the availability of information on all kinds of innovative ideas from search engines, I think there’s a lot of possible cross-reinforcement. Innovation has been accelerating throughout my entire lifetime, and it shows no signs of stopping that acceleration. The very pace of innovation picks up every year…

What if someone uses genetic algorithms to improve the genetic algorithms themselves? Will genetic algorigthms thus become more efficient and flexible? Will our lives someday be managed by a device that uses genetic algorithms to find the best way to satisfy our desires?

Read the whole thing, and follow the links. Amazing stuff.

Cross posted at Agricola.


It’s time for this faineant to get his studyin’ butt in gear.

Via the wonderful Word of the Day.

“Life’s hard, son. It’s harder when you’re stupid.” — The Duke.

Education is a companion which no misfortune can depress, no crime can destroy, no enemy can alienate,no despotism can enslave. At home, a friend, abroad, an introduction, in solitude a solace and in society an ornament.It chastens vice, it guides virtue, it gives at once grace and government to genius. Without it, what is man? A splendid slave, a reasoning savage. - Joseph Addison
The term informavore (also spelled informivore) characterizes an organism that consumes information. It is meant to be a description of human behavior in modern information society, in comparison to omnivore, as a description of humans consuming food. George A. Miller [1] coined the term in 1983 as an analogy to how organisms survive by consuming negative entropy (as suggested by Erwin Schrödinger [2]). Miller states, "Just as the body survives by ingesting negative entropy, so the mind survives by ingesting information. In a very general sense, all higher organisms are informavores." - Wikipedia

Blog Stats

  • 30,792 hits