# Fundamentals of Transportation/Pricing

**Pricing**

## Rationales for Pricing

Roadway congestion, air pollution from cars, and the lack of resources
to finance new surface transportation options present challenges.  Road
pricing, charging users a monetary toll in addition to the amount of
time spent traveling, has been suggested as a solution to these
problems.  While tolls are common for certain expensive facilities such
as tunnels and bridges, they are less common on streets and highways.  A
 new generation of private toll roads are being deployed in the United
States and elsewhere.  There have been a few trials of areawide pricing
schemes, such as in Singapore, London, and Stockholm, and many others
proposed but not implemented.

In short pricing can accomplish several objectives

-   Revenue
-   Congestion management - Traffic congestion is very common in large
    cities and on major highways. It is time consuming and imposes a
    significant amount of uncertainty and aggravation on passengers and
    freight transportation. Most of the cost of traffic congestion
    caused by travelers\' selfish behaviors (see discussion of Route
    Choice),
    because they impose delays on others and do not pay the full
    marginal cost of their trips. In economic terms, a negative
    externality is created. In order to solve this problem some
    economist proposed that there should be a tax on congestion. In the
    first edition of his textbook, *The Economics of Welfare*,
    Pigou (1920) argued for a tax on congestion and thereby launched the
    literature on congestion pricing. Most economists support congestion
    pricing as a good way to relieve the dilemma, while many have been
    concerned about the details of implementation. Congestion charges
    allocate scarce road capacity in congested areas and peak times.
    Electronic Toll Collection (ETC) and Automated Vehicle
    Identification (AVI) technologies allow this to be done without
    delaying travelers.
-   Pavement management - Pavement damage depends on vehicle weight per
    axle, not total vehicle weight - the damage power rises
    exponentially to the third power with the load per axle (e.g., a
    rear axle of a typical 13-ton van causes over 1000 times as much
    damages that of a car). In order to reflect the pavement damage
    costs more accurately, Small and Winston (1989) propose a
    \"graduated per-mile tax based on axle weight\". This would give
    truckers (truck manufactuers) an incentive to reduce axle weights by
    shifting to trucks with more axles, extending pavement life and
    reducing highway maintenance. The fuel tax currently in place
    provides truckers with the opposite incentives: the tax rises with a
    vehicle\'s axles, since trucks with more axles require larger
    engines and get lower fuel economy. They pointed out that the
    pavement thickness guidelines of the American Association of State
    Highway and Transportation Officials (AASHTO) fails to incorporate
    economic optimization into the design procedure. For example, by
    increasing rigid concrete pavement thickness only by 2.6 inches from
    currently 11.2 inches to 13.8 inches would more than double the life
    of the pavement.
-   Off-loading costs or reallocating costs (changing who bears
    burden) - Highway cost allocation studies periodically attempt to
    update the amount of burden for roads borne by cars and various
    classes of trucks, but they only have two policy tools (gasoline and
    diesel fuel taxes) to do the job. A more robust pricing strategy
    could make charges far more directly proportional to source.
-   Changing energy supply indicates declining gas tax revenue
-   Encourage alternatives to driving

There are reasons that road pricing is not more widespread. Until
recently, technical issues were dominant, toll collection added
considerable delay and greatly reduced net revenue with the need for
humans sitting in toll booths. However, advances in automatic vehicle
identification and tolling have enabled toll collection, without human
operators, at full speed. Other issues are fundamentally political:
concerns over privacy, equity, and the perception of double taxation.
Privacy concerns, though political, may have a technical solution, with
the use of electronic money, which is not identified with its owner,
rather than credit or debit cards or automatic identification and
billing of vehicles. Equity issues, the belief that there will be
winners and losers from the new system, may not be entirely resolvable.
Though it can be shown that under certain circumstances road pricing has
a net benefit for society as a whole, unless a mechanism exists for
making a sufficient majority of road users and voters benefit, or
perceive benefit, this concern is a roadblock to implementation.
Similarly, people may believe that they have paid for roads already
through gas taxes and general revenue, and that charging for them is
akin to double taxation. Unless users can be convinced that the revenue
raised is for maintenance and expansion, or another convincing public
purpose, the political sell will be difficult. Widespread road pricing
may require changes in the general transportation financing structure
and a clear accounting of the benefits will need to be provided.

## Theory of Congestion Pricing

!Caption: Congestion Pricing Brings About Efficient
Equilibrium.{width="400"}

Whenever a scarce and valued good such as road use is free or under
priced, demand will outstrip supply. An illustration pertaining to road
use is evident by the queues and traffic jams that occur when the number
of motorists attempting to use a section of roadway at the same time
exceeds the road's capacity. Expanding capacity to meet peak demand
results in wasteful excess capacity during non-peak periods unless the
peak users are charged the full cost of the expansion. If we look at
long-distance telephone service, allocation is determined with a market
mechanism by charging a premium for a call during peak periods and by
offering a discount during off peak periods. Consumers appear to accept
a market-based system for allocating demand in long-distance telephone
service and the system suggests this policy works.

In the case of roads, demand is allocated by congestion. The excess
demand for road use during peak periods causes congestion. Economists
believe that travel behavior is directed by the out-of-pocket expense of
a trip plus the value of time that is required. Some motorists do shift
their time of travel when congestion gets bad enough, but not enough
motorists shift to entirely alleviate the congestion. The number of
motorists that do shift their time of travel will never be sufficient to
reduce congestion because -without some sort of pricing or rationing of
road use- motorists using the road during peak periods do not have to
pay for the delays they cause each other.

Making motorists pay for the delays they caused others by making their
trips rather than just their personal costs would lead some to make
other choices. Motorists may decide to change their time of travel,
carpool, or use public transportation. Congestion pricing would allow
motorists to make peak-period trips under less congested conditions, but
only if they are willing to pay for the delays they impose on each
other. The price would be set at a level that reduces congestion to its
most efficient level, which can be shown to be the full monetary and
time cost for using a segment of road capacity during the peak period.

Decisions made by road users about where and when to use their vehicles
are made by comparing the benefits they will receive from using the road
with the costs to themselves. These costs do not include the costs they
impose on other travelers or on society as a whole, such as congestion
and environmental damage. The results from this type of behavior are
trips being made in which benefits to the motorist are less than the
costs to society. There is more traffic than can be justified and is not
efficiently located in time and capacity. If people are charged for the
costs they impose on others because of their travel decisions, then that
pattern of travel which results in optimal efficiently will occur.

## Alternative Revenue Mechanisms

Road user charging may be more or less direct. Generally, indirect
methods of road charges are related to vehicle ownership and usage.
Examples would be fixed charges for owning a car -purchase tax for
buying a new vehicle and annual licensing renewals- and variable charges
on car usage -taxes on tires oil and fuel.

Indirect methods of road charging, such as fuel taxes, are the most
commonly used in today's society because of the high volume of usage and
ease of collection. However, revenue methods like fuel taxes rarely
channel funds directly into a road or transportation fund that is
specifically for highway maintenance or development. Where there is
congestion caused by multiple road users, drivers impose a marginal
social cost in terms of delay and higher operating costs on other uses,
for which they are not being charged.

Direct charging involves monitoring the actual time or distance of
vehicle travel and charging appropriately. There are many ways in which
to carry out direct charging. With the development of electronic
technology, both off-vehicle and now in-vehicle charging mechanisms can
be implemented. Off-vehicle mechanisms are devices like manual toll
collection booths, coin operated machines, and road side auto-scanners.
In-vehicle mechanisms are magnetic cards, smart cards, and transponders.

Congestion pricing could take several forms. The most straightforward
example would be to add an extra fee to an existing toll, or to add a
peak fee on an untolled route or bridge. The charge could be a simple
peak premium price or off-peak discount received, or the charge could
vary according to the demand imposed on a facility at a specific time.

In practice, congestion pricing could take six forms:

-   Point pricing, In which a highway user passing a point at a specific
    time is charged a fee for passing that point regardless of the
    distance traveled on a specified route;
-   Cordon pricing, in which users wishing to enter a congested area are
    charged fees at each entry point;
-   Zone pricing, in which users traveling within a cordoned area also
    pay a fee;
-   Higher charges for parking in congested areas, with particular
    emphasis on parking during the most congested period;
-   Congestion-specific charges, in which users would be charged for
    both the amount of time spent and distance traveled.

The policies have different implications for demand. General taxes
cannot be expected to reduce demand for travel in particular.
Transportation specific taxes should reduce demand to a limited extent,
but will not reduce demand on targeted road links, such as congested
facilities. A cordon toll will reduce demand crossing the cordon, but by
its nature is less targeted than "perfect tolls". While different
finance mechanisms have different implications for how they affect
demand, they also have different costs of collection. It has
historically been true that the more targeted the mechanism, the more
costly. However, with the advent of wider use of electronic toll
collection, those historical truisms may be altered. Varying the level
of jurisdiction administering the policy changes the perception of
welfare. Local governments are responsible to local citizens - their
constituents, and tend not to concern themselves with the welfare of
non-local residents. Therefore the incentive structure facing different
layers of government needs to be distinguished. The welfare resulting
from implementation when roads are owned and operated by a state may
differ from the welfare if the same financing mechanism were implemented
by a regional metropolitan planning organization that owned and operated
the roads and could retain toll revenue. Similarly, the metropolitan
planning organization differs from the county. The key reasons for these
differences relate to who pays the tolls, and whether or not the (or to
what extent) toll-payers reside within the boundaries of the local
governmental agency. A county's concern for the economic welfare of
non-county residents is minimal, as is a metropolitan regions concern
for residents of other areas. Decentralization of decision making can
thus influence the chosen policy.

## Effects of Congestion Pricing

The evidence from past changes in bridge and turnpike tolls demonstrates
that motorists do respond to changes in price. In referring to the price
elasticity of individual demand for transportation, analyses suggest an
elasticity of approximately -0.10 to -0.15 as a lower limit and -0.3 to
-0.4 as an upper limit depending on the charge, the current costs of
travel, and the capacity of alternative roads and transit systems. There
will be a decline in demand following a price increase, but consumer
demand for road use is strong enough that the percentage decline in
demand will not be as large as the percentage increase in price.

There are many possible changes in travel choice, including:

-   Route, changing from tolled to untolled routes or to faster tolled
    routes.
-   Time, changing to earlier or later departures to avoid tolls or
    tolled periods.
-   Mode, changing to or away from carpools, transit, or other modes.
-   Destination, changing to a closer location for non-work activities.
-   Location, moving home or workplace to reduce the commute.
-   Sequence, linking trips by combining multiple errands on a single
    trip.
-   Frequency, reducing the number of less important trips
-   Presence, conducting activities by telecommuting to decrease work
    related trips.
-   Ownership, Motorists may also forgo ownership of automobiles to
    bypass toll charges.

Congestion pricing on highways would have broad effects on the entire
transportation system by shifting the demand for transportation services
away from peak period highway use by solo drivers. A reduction in the
incentives to drive during peak periods would shift some traffic to the
off-peak, which would increase the efficiency of the road system -
therefore, reduce the demand for additional capacity. Some motorists
would continue to drive during the peak but would elect to share rides
with others or change the destinations of their trips. Sharing rides
with others would also increase the efficiency in which the system is
used by increasing the number of people per vehicle during peak periods.

Some motorists would shift to transit. The improvement in traffic flows
that would result from congestion pricing would improve service
reliability and speed, therefore, making transit more attractive than
the automobile. The increase in use of transit would increase revenues.
These revenues could be put towards increasing service frequency or
route coverage. Congestion pricing would also reduce demand for new
highway development. This would decrease the demand for capital
expenditure on road development in response to growing population and
travel demand.

## Unpacking

![](TE-Pricing-EquilbriumUnpacked.png "TE-Pricing-EquilbriumUnpacked.png"){width="400"}

The top part of Figure 2 shows schematically the travel time to a driver
(short run average cost) at a bottleneck or on a capacitated link
resulting from various levels of approach flow. The travel time function
relates travel time (or delay) and approach traffic flow. The greater
the approach flow, the higher the travel time. At flows below capacity
(level of service A (SA) or B (SB)), traffic flows smoothly, while at
high approach flows, those above capacity, traffic is stop and start and
is classified as level of service E (SE) or F (SF).

The bottom part of Figure 2 shows schematically the implicit demand for
travel on a link as a function of the travel time. All else equal (for
instance the price charged to users), demand to travel on a link at
level of service A (DA) is higher than demand at level of service F
(DF). However the demand and the travel time on a link are not
independent, as shown in Figure 2(A).

So the implicit demand and revealed demand are not identical, rather the
revealed demand is formed by projecting the travel time at a given flow
onto the implicit demand curves. So for instance, when the price charged
users is high, the revealed demand coincides with the implicit demand at
level of service A (DA). As the prices are lowered, the revealed demand
crosses the implicit demand curve at level of service B (DB), then DC,
DD, DE and finally at a zero money price it crosses DF. While the actual
prices that generate specific demand levels vary from place to place
with local circumstances, demand preferences, and market conditions, the
general trend (higher prices gives lower approach flow gives better
level of service) is simply an application of the law of demand from
economics along with traffic flow theory.

In other words, the change in welfare with congestion pricing depends
not only on both the change in price and quantity, but also on the
change in reservation price. The reservation price is the amount
travelers would be willing to pay at a given level of service. And at
better levels of service, travelers (and potential travelers) have a
higher reservation price.

## Welfare Analysis

!
right\|thumb\|400px

The movement along the revealed demand curve follows the shape of the
curve shown above because of the relationship between traffic flow
(quantity demanded) and travel time. Assume for instance that each level
of service category represents a one-minute increase in travel time from
the immediately better travel time. So in the graph, let the level of
service for a one minute trip be denoted SA , and for a six minute trip,
SF. The amount of traffic necessary to move from 1 minute to 2 minutes
exceeds the amount to move from 2 to 3 minutes. In other words, there is
a rising average (and thus marginal) cost in terms of time.

The concepts in Figure 2 can be used to develop the welfare analysis
shown in Figure 3. There are several areas of interest in Figure 3. The
first is defined by the lower left triangle (the blue + green) (triangle
VOZ) which is the consumer surplus when the road is unpriced. The second
is the producer surplus (profit) to the road authority when the road is
priced, illustrated by the rectangle formed in the lower left (yellow +
green) (rectangle OVWY). The third is the consumer surplus when the road
is priced, shown in gray (triangle UVW). This consumer surplus
represents a higher reservation price than the other because the level
of service is better when flow is lower.

That first area needs to be compared to the sum of the second and third
areas. If the sum of the second and third areas (OUWY) is larger than
the first (OVZ), then pricing has higher welfare than remaining
unpriced. Similarly, two price levels can be compared. In other words,
the welfare gain from pricing is equal to the yellow + gray area (VUWX)
minus the blue area (XYZ). In this particular figure, consumer's surplus
is maximized when the good is free, but overall welfare (including
producer's surplus) is not. Whether consumer's surplus is in fact higher
in a given situation depends on the slopes of the various demand curves.

The greatest welfare is achieved by maximizing the sum of the producer's
surplus rectangle and the consumer's surplus "triangle" (it may not be a
true triangle). This must recognize that the consumers surplus
triangle's hypotenuse must follow an underlying demand curve, not the
revealed demand curve. Differentiating the level of service (for
instance, providing two different levels of service at two different
prices) may result in higher overall welfare (though not necessarily
higher welfare for each individual).

## Use of the Revenue

How welfare is measured and how it is perceived are two different
things. If the producer's surplus is not returned to the users of the
system somehow the users will perceive an overall welfare gain as a
personal loss because it would be acting as an additional tax. The money
can be returned through rebates of other taxes or reinvestment in
transportation. It should be noted that the entire argument can be made
in reverse, where consumer and producers surplus are measured in time
rather than money, and the level of service is the monetary cost of
travel. This however has less practical application.

## Pricing and Cost Recovery

In low volume situations, those that are uncongested, it is unlikely
that the revenue from marginal cost congestion pricing will recover long
term fixed costs. This is because the marginal impacts of an additional
car when volume is low is almost zero, so that additional revenue which
can be raised with marginal cost pricing is also zero. Imagine a road
with one car - the car's marginal impact is zero, a marginal cost price
would also be zero, its revenue would thus be zero, which is less than
the fixed costs.

Add a second car, and marginal impacts are still nearly zero - a
phenomenon which remains true until capacity is approached.

## Vickery's Types of Congestion

-   Simple interaction - light traffic, one car blocked by another,
    delay is proportional to Q\^2
-   Multiple interaction - 0.5 \< V/C \< 0.9

$Z = t - t_{o} = 1/s - 1/s_{o} = ax^k$

t actual time, to freeflow time, K \~ 3-5

-   Bottleneck see below
-   Triggerneck - overflow affects other traffic
-   Network and Control - Traffic control devices transfer delay
-   General Density - high traffic level in general

## Marginal Cost Pricing

Transportation is a broad field, attracting individuals with backgrounds
in engineering, economics, and planning, among others who don't share a
common model or worldview about traffic congestion. Economists look for
received technological functions that can be analyzed, but risk
misinterpreting them. Engineers seek basic economic concepts to manage
traffic, which they view as their own purview. These two fields
intersect in the domain of congestion pricing. However many engineers
view pricing with suspicion, believing that many economists are
overstating its efficacy, while the economists are frustrated with
engineering intransigence, and consider engineers as lacking
understanding of basic market principles.

This section applies the microscopic model of traffic congestion that to
congestion pricing, and allows us to critique the plausibility of
several economic models of congestion that have appeared in the
literature.

This section uses the idea of queueing and bottlenecks to explain
congestion. If there were no bottlenecks (which can be physical and
permanent such as lane drops or steep grades, or variable such as a
traffic control device, or temporary due to a crash), there would be
very little congestion. Vehicles interacting on an uncongested road lead
to relatively minimal delays and are not further considered (Vickery
1969, Daganzo 1995) . We define congestion, or the congested period, to
be the time when there is queueing. This exceeds the time when arrivals
exceed departures, as every vehicle has to wait for all previous
vehicles to depart the front of the queue before it can.

A previous
section
developed the queueing model of congestion.

!Input output diagram at level of individual
vehicle{width="400"}
!Marginal delay at level of individual
vehicle{width="400"}

What is the implication of our queueing models for marginal cost
pricing?

First, the use of hourly average time vs. flow functions such as the
Bureau of Public Roads function, (which we introduced in the discussion
of route
choice (which
approximates the hourly average delay from a queueing model) ignores
that different vehicles within that hour have different travel times.
They are at best useful for coarse macroscopic analyses, but should
never be applied to the level of individual vehicles.

Second, travel time for a vehicle through a bottleneck depends on the
number of vehicles that have come before, but not on the number of
vehicles coming after. Similarly, the marginal delay that a vehicle
imposes is only imposed on vehicles that come after. This implies that
the first vehicle in the queue imposes the highest marginal delay, and
the last vehicles in the queue have the lowest marginal delay. A
marginal delay function that looks like figure on the right (bottom) is
generated from the typical input-output diagram shown on the figure on
the right (top). If marginal cost were equal to the marginal delay, then
our pricing function would be unusual, and perhaps unstable. The
instability might be tempered by making demand respond to price, rather
than assuming it fixed (Rafferty and Levinson 2003), and by recognizing
the stochastic nature of arrival and departure patterns, which would
flatten the arrival curve to more closely resemble the departure curve,
and thereby flatten the marginal delay curve.

However, the idea that the first vehicle \"causes\" the delay is a
controversial point. Economists will sometimes argue Coase's position
(1992) -- that it takes two to have a negative externality, that there
would be no congestion externality but for the arrival of the following
vehicles. Coase is, of course, correct. Moreover, they would note that
charging a toll to the following vehicle will discourage that vehicle
from coming and might also eliminate the congestion externality. This
may also be true. This would however be charging the sufferer of
congestion twice (once in terms of time, a second in terms of toll),
while the person with the faster trip (earlier in the queue) wouldn't
pay at all. Further, it is the followers who have already internalized
the congestion externality in their decision making, so tolling them is
charging them twice, in contrast to charging the leaders. Given that
charging either party could eliminate the externality, it would be more
reasonable to charge the delayer than the delayed, which is much like
the "polluter pays principle" advocated by environmentalists. It would
also be more equitable, in that total costs (congestion delay + toll)
would now be equalized across travelers. The disadvantage of this is
that the amount of the delay caused is unknown at the time that the
first traveler passes; at best it can be approximated.

Implicitly, this privileges the "right to uncongested travel" over the
"right to unpriced travel". That is a philosophical question, but given
that there is to be some mechanism to finance highways, we can eliminate
the notion of unpriced travel altogether, the remaining issue is how to
implement financing: with insensitive prices like gas taxes or flat
tolls or with time-dependent (or flow-dependent) congestion prices.

The marginal cost equals marginal delay formulation does ignore the
question of schedule delay. There are practical reasons for not
including schedule delay in a marginal cost price. Unlike delay,
schedule delay is not easily measured. While a road administrator can
tell you from traffic counts how much delay a traveler caused, the
administrator has no clue as to how much schedule delay was caused.
Second, if the late (early) penalty is large, then it dominates
scheduling. Travelers can decide whether they would rather endure
arriving early (without delay) or arriving on time, with some delay (or
some combination of the two), presumably minimizing their associated
costs. If they choose the delay, it is the lower cost alternative. That
lower cost is the one they suffer, and thus that serves as a lower bound
on the marginal cost to attribute to other travelers. If they choose
schedule delay (which then becomes the cost they face) and avoid the
delay, they are affected as well by other travelers, but in a way that
is unknown to pricing authorities. They are "priced out of the market",
which happens all the time. In short, endogenizing schedule delay would
be nice, but requires more information than is actually available.

## Profit Maximizing Pricing

A realistic network of highway links is not, in the economists\'
terminology, perfectly competitive.  Because a link uniquely occupies
space, it attains some semblance of monopoly power. While in most cases
users can switch to alternative links and routes, those alternatives
will be more costly to the user in terms of travel time. Theory suggests
that excess profits will attract new entrants into a market, but the
cost of building a new link is high, indicating barriers to entry not
easily overcome.

Although roads are generally treated as public goods, they are both
rivalrous when congested and in many cases excludable.  This indicates
that it is feasible to consider them for privatization.  The advantages
often associated with privatization are several: increasing the
efficiency of the transportation system through road pricing, providing
incentives for the facility operator to improve service through
innovation and entrepreneurship, and reducing the time and cost of
building and expanding infrastructure.

An issue little addressed is implementation. Most trials of road pricing
suppose either tolls on a single facility, or area-wide control.
Theoretical studies often assume marginal cost pricing on links, and
don\'t discuss ownership structure. However, in other sectors of the
economy, central control of pricing either through government ownership
or regulation has proven itself less effective than decentralized
control for serving customer demands in rapidly changing environments.
Single prices system-wide don't provide as much information as
link-specific prices. Links which are priced only at marginal cost, the
optimal solution in a first-best, perfectly competitive environment,
constrain profit. While in the short-term, excess profit is not socially
optimal, over the longer term, it attracts capital and entrepreneurs to
that sector of the economy. New capital will both invest more in
existing technology to further deploy it and enter the sector as
competitors trying to gain from a spatial monopoly or oligopoly.
Furthermore, new capitalists may also innovate, and thereby change the
supply (and demand) curves in the industry.

By examining road pricing and privatization from a decentralized point
of view, the issues associated with a marketplace of roads can be more
fully explored, including short and long term distributional
consequences and overall social welfare. The main contribution of this
research will be to approach the problem from a theoretical and
conceptual level and through the conduct of simulation experiments. This
analysis will identify salient empirical factors and critical parameters
that determine system performance. To the extent that available data
from recent road pricing experiments becomes available, it may be used
to compare with the results of the model.

### Case 1. Simple Monopoly

`   The simplest example is that of a monopoly link, `$I-J$

The link has elastic demand $Q_d$:

$Q_d =f (P)$

here given by a linear equation:

$Q_d = \beta_0 - \beta_1 P$ for all $\beta_0$ and $\beta_1 > 0$

The objective of the link is to maximize profit $\pi= P Q_d(P)$.  Here
we assume no congestion effects.  Profit is maximized when the first
derivative is set to zero and the second derivative is negative.
$\pi= P Q_d(P) = P (\beta_0 - \beta_1P) = \beta_0P - \beta_1P^2$ Giving
the following first order conditions (f.o.c.):
$\delta\pi/dP = \beta_0 - 2 \beta_1P = 0$

$P = \beta_0 / 2 \beta_1$

Checking second order conditions (s.o.c.), we find them to be less than
zero, as required for a maximum.

$\delta^2 \pi / \delta P^2 = - 2 \beta_1  < 0$

`   For this example, if `$\beta_0 = 1000$` and `$\beta_1 = 1$`, `$P = 500$` gives `$Q_d(P)=500$`, and `$profit = 250,000$`.  This situation clearly does not maximize social welfare, defined as the sum of profit and consumer surplus.  Consumer surplus at `$P=500$` for this demand curve is 125,000, giving a social welfare (SW) of 375,000.  Potential social welfare, maximized at `$P=0$` (when links are costless), would be `$500,000 > 375,000$`, all of which comes from consumer surplus.`

### Case 2. Monopolistic Perfect Complements

`   In a second simple example, we imagine two autonomous links, `$I-J$` and `$J-K$`, which are pure monopolies and perfect complements, one cannot be consumed without consuming (driving on) the other. The links are in series.`

`   In this case, demand depends on the price of both links, so we can illustrate by using the following general expression, and a linear example :`

$Q_d = f(P_{ij} , P_{kl})$

$Q_d = \beta_0 - \beta_1 (P_{ij}+P_{jk})$

Again we assume no congestion costs.  When we profit maximize, we attain
a system which produces a Nash equilibrium that is both worse off for
the owners of the links, who face lower profits, and for the users of
the links, who face higher collective profits, than a monopoly.  Simply
put, the links do not suffer the full extent of their own pricing policy
as they would in the case of a monopoly, where the pricing externality
is internalized.

$\pi_{ij} = P_{ij} Q_d(P) = P_{ij} (\beta_0 - \beta_1P_{ij} - \beta_1P_{jk}) = \beta_0P_{ij} - \beta_1P_{ij}^2 - \beta_1 P_{ij} P_{jk}$

$\pi_{jk} = P_{jk} Q_d(P) = P_{jk} (\beta_0 - \beta_1P_{ij} - \beta_1P_{jk}) = \beta_0P_{jk} - \beta_1P_{jk}^2 - \beta_1 P_{ij} P_{jk}$

f.o.c.
$\delta \pi / dP_{ij} = \beta_0 - 2 \beta_1P_{ij} - \beta_1P_{jk} = 0$

$P_{ij} = (\beta_0- \beta_1P_{jk}) / 2 \beta_1$

$\delta \pi / \delta P_{jk} = \beta_0 - 2 \beta_1P_{jk} - \beta_1P_{ij} = 0$

$P_{jk} = (\beta_0- \beta_1P_{ij}) / 2 \beta_1$

solving the f.o.c. simultaneously yields:

$P_{ij} = P_{jk} = \beta_0 (2 \beta_1-1) / ( 4 \beta_1^2 - \beta_1)$

checking the s.o.c.: $\delta^2 \pi / \delta P_{ij}^2 = - 2 \beta_1 < 0$

$\delta^2 \pi / \delta P_{jk}^2 = - 2 \beta_1 < 0$

`   At `$\beta_0 = 1000$` and `$\beta_1 = 1$`, the solution is `$P_{ij} = P_{jk} = 333.33$`, which gives `$Q_d(P) = 333.33$`, `$\pi_{ij}=\pi_{jk}=111,111$`, which is less total profit than the case of the simple monopoly. This situation results in total profit to both firms of 222,222, and a consumer surplus of 55,555, or total social welfare of 277,000, which is less than the results from the case of a simple monopoly.`\
`   Similar arguments apply to three (or more) perfect complements, which are more and more dysfunctional if operated autonomously.  The general formula for N autonomous perfectly complementary links, with linear demand and  `$\beta_1=1$`, is given by:`

$P = Q_d(P)= \beta_0/(N+1).$

### Case 3. Duopoly of Perfect Substitutes

`   In a third example, we imagine two parallel autonomous links, `$I-J$` and `$K-L$`, which serve the same, homogenous market.   They are perfect substitutes (operate in parallel).`

`   The optimal pricing for this case depends upon assumptions about how users distribute themselves across suppliers and the relationships between the links.  First, assume there are no congestion costs and time costs are otherwise equal and not a factor in the decision.  Do users simply and deterministically choose the lowest cost link, or are there other factors which shape this choice, so that a minor reduction in price will not attract all users from the other link?  For this example, we assume deterministic route choice, so demand chooses the lowest cost link, or splits between the links if they post the same price.  Here, demand is defined as below:`\
`   `

$Q_d = f(P_{ij},P_{kl})$

$Q_d = \beta_0 - \beta_1 min(P_{ij},P_{kl}).$

As before, let $\beta_0=1000$, $\beta_1=1$.  Also assume that
competitive links can respond instantaneously.  Assume each link can
serve the entire market, so that there are no capacity restrictions.

`   Clearly there is a (welfare maximizing) stable equilibrium at `$P=0$` (assuming equal and zero costs for the links), the result for a competitive system.  Demonstration: Suppose each link sets price 500, and had 250 users.  If link IJ lowers its prices by one unit to 499, it attains all 501 users, and profits on link IJ increase to 249,999 from 125,000.  However profits on link KL drop to 0.  The most profitable decision for KL is to lower its price to 498, attain 502 users, and profits of 249,996.  This price war can continue until profits are eliminated.  At any point in the process raising prices by one link alone loses all demand.`\
`   `\
`   However it seems unlikely in the case of only two links.  Therefore, if the links could coordinate their actions they would want to.  Even in the absence of formal cartels, strategic gaming and various price signaling methods are possible.   For instance, a far sighted link KL, seeing that a price war will ultimately hurt both firms, may only match the price cut rather than undercut in retaliation.  If IJ did not follow with a price cut, a price will be maintained.  It has been argued (Chamberlin 1933), that the duopoly would act as a monopoly, and both links would charge the monopoly price and split the demand evenly, because that is the best result for each since lowering prices will lead to a price war, with one link either matching or undercutting the other, in both cases resulting in smaller profits.`

### Case 4. Monopoly and Congestion

`   The previous three cases did not exploit any special features of transportation systems.  In this case travel time is introduced on the network used in Case 1.  Here demand is a function of both Price (`$P$`) and Time (`$T$`):`\
`   `

$Q_d = f(P,T)$

For this example is given by linear form:

$Q_d = \beta_0 - \beta_1P - \beta_2T$

where travel time is evaluated with the following expression
incorporating both distance effects and congestion (queuing at a
bottleneck over a fixed period with steady demand):

if $(Q_d/Q_o) < 1$

$T = T_{f}$

if $(Q_d/Q_o) \ge 1$

$T=T_f + (C/2)((Q_d/Q_o) - 1)$

where: $T_f$ = freeflow travel time,

`   `$C$` = length of congested period, `\
`   `$Q_o$` = maximum flow through bottleneck.`

`   Because `$T_f$` is a constant, and we are dealing with only a single link, it can be combined with `$\beta_0$` for the analysis and won’t be considered further.  By inspection, if `$Q_o$` is large, it too does not figure into the analysis.  From Case 1, with the `$\beta$` as given, `$Q_o$` is only important if it is less than `$Q_d = 500$`.  For this example then, we will set `$Q_o$` at a value less than 500, in this case assume `$Q_o = 250$`.`\
`   `\
`   As before, the objective of the link is to maximize profit `$\pi= P Q_d(P)$`. Profit is maximized when the first derivative is set to zero and the second derivative is negative.`\
`   `

$\pi=PQ_d(P)=P(\beta_0-\beta_1P-\beta_2T)=\beta_0P-\beta_1P^2-\beta_2P(C/2)((Q_d/Q_o)-1)$

Giving the following first order conditions (f.o.c.):

$\delta\pi/dP=\beta_0-2\beta_1P-\beta_2(C/2)((Q_d/Q_o)-1)=0$

$P = (\beta_0-\beta_2(C/2)((Q_d/Q_o)-1))/(2\beta_1)$

Solving equations (4.2) and (4.6) simultaneously, at values:
$\beta_0= 1000$, $\beta_1= \beta_2 =1$, reflecting that the value of
time for all homogenous travelers is 1 in the chosen unit set,
 $C=1800$, representing 1800 time units (such as seconds) of congestion,
we get the following answer: $P = Q_d = 339.3, T = 320.4$.   It is thus
to the advantage of the monopoly in the short term, with capacity fixed,
to allow congestion (delay) to continue, rather than raising prices high
enough to eliminate it entirely.  In the longer term, capacity expansion
(which reduces delay), will allow the monopoly to charge a higher price.
 In this case,$\pi=115,600$, and $consumer surplus = 57,800$.  There is
a large deadweight loss to congestion, as can be seen by comparing with
Case 1.

### Simulation

More complex networks are not easily analyzed in the above fashion.
 Links serve as complements and substitutes at the same time.
 Simulation models address the same questions posed in the analytic
model on more complex networks, that is, what are the performance
measures and market organization under different model parameters and
scenarios.  Second, we can consider market organization within the model
framework, so that the question becomes: What market organization
emerges under alternative assumptions, and what are the social welfare
consequences of the organization?

Competing links restrict the price that an autonomous link can charge
and still maximize profits.  Furthermore, it is likely that government
regulations will ultimately constrain prices, though the level of
regulation may provide great latitude to the owners.  It is anticipated
that each link will have an objective function for profit maximization.
  However, depending upon assumptions of whether the firm perfectly
knows market demand, and how the firm treats the actions of competitors,
the Nash equilibrium solution to the problem may not be unique, or even
exist.

Because the demand on a link depends on the price of both upstream and
downstream links, its complements, revenue sharing between complementary
links, and the concomitant coordination of prices, may better serve all
links, increasing their profits as well as increasing social welfare.
Vertical integration among highly complementary links is Pareto
efficient.

It is widely recognized that the roadway network is subject to economies
of density, at least up to a point.  This means that as the flow of
traffic on a link increases, all else equal, the average cost of
operating the link declines.   It is less clear if links are subject to
economies of scale, that it is cheaper per unit of output (for instance
per  passenger kilometer traveled) to build and manage two links, a
longer link, or a wider link than it is to build and manage a single
link, a shorter link, or a narrower link.   If there are such economies
of scale, then link cost functions should reflect this.

Different classes of users (rich or poor; or cars, buses, or trucks)
have different values of time.  The amount of time spent on a link
depends upon flow on that link, which in turn depends on price.  It may
thus be a viable strategy for some links to price high and serve fewer
customers with a high value of time, and others to price low and serve
more customers with a lower value of time.  It is hypothesized that in a
sufficiently complex network, such distinct pricing strategies should
emerge from simple profit maximizing rules and limited amounts of
coordination.

There are a number of parameters and rules to be considered in such
simulation model, some are listed below.

#### Parameters

*Network Size and Shape*.  The first issue that must be considered is
the size of network in terms of  the number of links and nodes and how
those links connect, determined by the shape of the network  (symmetric:
grid, radial;  asymmetric).  While the research will begin with a small
network, it is possible that the equilibrium conditions found on limited
networks may not emerge on more complex networks, giving cause for
considering a more realistic system.

*Demand Size and Shape*.  A second issue is the number of
origin-destination markets served by the network, the level of demand,
and the number of user classes (each with a different value of time).
 Again, while the research will begin with very simple assumptions, the
results under simple conditions may be very different from those under
slightly more complex circumstances.

#### Rules

*Profit Seeking*.  How do autonomous links determine the profit
maximizing price in a dynamic situation?   Underlying the decision of
each autonomous link is an objective function, profit maximization given
certain amounts of information, and a behavioral rule which dictates the
amount and direction of price changes depending on certain factors.
 Once a link has found a toll which it can neither raise nor lower
without losing profit, it will be tempted to stick with it. However, a
more intelligent link may realize that while it may have found a local
maxima, because of the non-linearities comprising a complex network, it
may not be at a global maxima.  Furthermore other links may not be so
firmly attached to their decision, and a periodic probing of the market
landscape by testing alternative prices is in order.  This too requires
rules.

*Revenue Sharing*.  It may be advantageous for complementary links to
form coalitions to coordinate their action to maximize their profit.
 How do these coalition form?  By the inclusion of a share of the
profits of other links in one link's objective function, that link can
price more appropriately. What level of revenue sharing, between 0 and
100 percent is best?  These questions need to be tested with the model.
 An interlink negotiation process will need to be developed.

*Cost Sharing*. Similar to revenue sharing is the sharing of certain
expenses that each link faces.  Links face large expenses periodically,
such as resurfacing or snow clearance in winter, that have economies of
scale.  These economies of scale may be realized either through single
ownership of a great many links or through the formation of economic
networks.  Just as revenue sharing between links is a variable which can
be negotiated, so is cost sharing.

*Rule Evaluation and Propagation*.  A final set of considerations is the
possibility of competition between rules.  If we consider the rules to
be identified with the firms which own links or shares of links, and set
pricing policy, the rules can compete.  Accumulated profits can be used
by more successful rules to buy shares from less successful rules.  The
decision to sell will compare future expected profits under current
management with the lump sum payment by a competing firm.  An open
market in the shares of links will need to be modeled to test these
issues.  Similarly, it may be possible to model rules which learn, and
obtain greater intelligence iteration to iteration.

## Discussion

Just as airline networks seem to have evolved a hub and spoke hierarchy,
a specific geometry may be optimal in a private highway network.
 Initial analysis indicates that there are advantages to both the
private and social welfare to vertical integration of highly
complementary links.  However the degree of complementarity for which
integration serves both public and private interests remains to be
determined.  Other issues that are to be examined include the influence
of substitutes and degree of competition on pricing policies through
cross-elasticity of demand, economies of scale in the provision of
infrastructure, multiple classes of users with different values of time,
"free" roads competing with toll roads, and the consequences of
regulatory constraints.  Using the principles developed under the
analytic approach, a repeated game of road pricing by autonomous links
learning the behavior of the system through adaptive expectation will be
developed.

## Additional Problems

-   Homework

## References

-   Chamberlin, E (1933) \"Monopolistic competition\". Harvard
    University Press
-   Coase, Ronald (1992), \"The Problem of Social Cost, and Notes on the
    Problem of Social Cost\", reprinted in *The Firm, The Market and the
    Law*, Chicago: University of Chicago Press.
-   Daganzo, Carlos. (1995). *An Informal Introduction To Traffic Flow
    Theory*. University of California at Berkeley, Institute of
    Transportation Studies. Berkeley, CA.
-   Levinson, David and Peter Rafferty (2004) Delayer Pays Principle:
    Examining Congestion Pricing with
    Compensation.
    *International Journal of Transport Economics* 31:3 295-311
-   Vickrey, William (1969) Congestion Theory and Transport Investment.
    *American Economic Review* 59, pp. 251--260.


# A-level Computing/AQA/The Computing Practical Project

***Please note, that the AQA Computing practical has since been updated,
the proportion of marks allocated to the technical solution has been
significantly increased to 42/75 (56%), compared to the 20/75 (27%) on
the old specification.***

As such anyone on the current specification will **not** need to do the
following documentation:

-   i\. System Maintenance
-   ii\. User Guide

The following subsections are also **no** longer required:

-   i\. Analysis: Realistic appraisal of the feasibility of potential
    solutions
-   ii\. Analysis: Justification of chosen solution
-   iii\. Design: Identification of storage media
-   iv\. Design: Description of measures planned for security and
    integrity of data
-   v\. Design: Description of measures planned for system security
-   vi\. Design: Overall test strategy

This chapter aims to give you the skills to complete your A2 Computing
project. Unlike the rest of the course this unit is entirely based on
coursework submitted in May. This is great because if you work hard
enough then you can make sure you get some really good marks, you have
access to the mark scheme after all!!The classic waterfall
model Your project
involves making a **complex programming project** that will likely
involve **data processing**, and then writing a report about it. You
have to make a program for a **real user**, this is very important, you
can\'t just make them up. It doesn\'t have to be incredibly complicated,
but you need a degree of complexity in order to write a good report. You
can write a computer game but they can be an awful lot of work (2--3
years with a team of 40+ people for the latest console games) and it\'s
often difficult to find a real life user and a real need.

Over the course of the project you will be creating a report. This is
really important and lots of people spend so much time coding that they
forget to complete the write up. The **write up is worth nearly 70% of
the mark** and will take you through a waterfall
model of system development. There are
many other forms of system
development out there and you might find yourself completing sections of
the course not necessarily in the order given, the important thing is
that you make it a cohesive whole and **complete everything**.

Please use the links below to get you started and note where all the
marks are awarded, you might create a brilliant bit of code but if you
don\'t complete your writeup your grade will suffer.

+-------------------------------------+-----------------+------------+
| Chapter                             | Marks           | Percentage |
+=====================================+=================+============+
|


# A-level Computing/AQA/Java

**Java** is currently one of the most popular languages in Computing
worldwide. It was created to meet the need of the Internet age, with
programs that could run on any computer architecture (type of
hardware-processor combination) without the need for the programmer to
separately compile the code for each architecture. Java was developed by
Sun Microsystems, now acquired by, and merged into, Oracle Corporation.
Java is open source under the GNU Public License, and its standards are
controlled by a community process. There is an independent version of
Java called the OpenJDK Runtime Environment
(IcedTea6 1.9.10). This has been gaining ground since Oracle took over
Sun but it uses the same API (Application Programming Interface). There
is a widely recognised set of library functions for Java that are
available on-line for free.

Oracle produce versions of Java for Windows, Mac and Linux that are free
to download and use. These include three major flavours:

-   the Standard Edition comes with libraries for writing client
    (desktop computer) software, not unlike the standard libraries of
    many other programming languages. The Standard Edition is the one
    commonly used for learning Java.
-   the Enterprise Edition extends the Standard Edition by adding
    powerful libraries and tools for writing sophisticated web server
    applications. Most professional Java developers actually use the
    Java EE, which is why you will see numerous references to it on
    Oracle\'s Java web site and download pages.
-   the Micro Edition can be installed alongside the Standard Edition to
    give access to the cut down libraries used on many mobile phones.
    The Java ME is rather long in the tooth, and most Java mobile
    developers have shifted focus to Google\'s Android (which also uses
    Java).

There are at least three excellent and free IDEs (Integrated Development
environments) for Java. *viz* BlueJ,
Eclipse "wikilink") and
NetBeans.

If you are starting out then the author of this page would strongly
advise that you initially compile and run a few programs with the
command line and then start with BlueJ, advantages being:

1.  BlueJ does not add extra code to what you have written on
    compilations. A common theme with sophisticated IDEs that many users
    find that very confusing when they start out.
2.  it is very well supported by a couple of Universities.
3.  there is a huge tutorial
    site with examples
    maintained by Oracle.

## Java Myths

1.  *Java is slower than C++*. This was true when Java started out but
    for many years the JRE has used a \"Hotspot\" compiler which
    compiles all the frequent areas of code into machine code for the
    host architecture. You would be hard put to see a difference in all
    but special cases designed to show off C++
2.  *Java is for the web*. No Java is not for the web, it just happens
    that you can easily write Java Applets for the web. Since Java is
    not Architecture dependent it will run on any platform for which
    there is a JRE and within most web browsers. In other words nearly
    everywhere.
3.  *Java is related to JavaScript*. No - JavaScript was a web scripting
    language written by the Netscape people and they called it
    Javascript to tag on to the coat tails of the Java Brand.

## Why Java?

-   Users of many platforms can download free-of-charge Java compilers,
    libraries and runtime environments, so students can easily pursue
    their interest at home, work or at a computer club.
-   Java has static typing, also known as strong typing, recommended by
    some computer scientists to enforce contracts between modules at
    compile time.
-   As of 2012, Java is the standard application language for
    Android "wikilink") phones and
    tablets, and one of the two main languages that Google offers,
    alongside Python, for its customer
    APIs.

## Why not Java?

-   The syntax for Java is probably more difficult for beginners than
    VB or Pascal.
-   Writing simple programs can take a lot more typing than python or VB
    equivalents

## Getting Started

To get going you need to install a Java SDK (Software Development Kit):
the most popular is the Oracle JDK. You probably already have the JRE
(Java Runtime Environment). If you haven\'t, you get one with the JDK
anyway.

There are various versions of the JDK. The Standard Edition (Java SE)
gives you everything you need to compile programs to run on your own
computer, as well as database support. As of version 6, the Java SE SDK
come with Java DB (aka Apache Derby), a lightweight embedded database
originally developed by IBM.

To get access to something like a mysql database you will need the EE
version of the SDK (Enterprise version) and the mysql database
connector.

### SDK

-   The Oracle Java
    SDK
    PC/Linux/Mac
-   Users of Linux and Unix may find a version of the Oracle JDK or the
    IcedTea6 SDK in their distribution\'s official source repository.
    IcedTea6 is designed to be compatible with Oracle\'s JDK 6 and the
    Java 1.6 published standards.[^1]

### IDEs

-   BlueJ PC/Linux/Mac
-   Eclipse PC/Linux/Mac (use the
    drop down to select)
-   netbeans PC/Linux/Mac
    (use the drop down to select)
-   IntelliJ IDEA − the open
    source *Community* edition supports Standard Edition.[^2]

### Portable

Portableapps maintain a version of
eclipse that can be used from a memory stick on any windows machine

## COMP4

Java is the main language used for developing android applications. You
can download a plugin for the Eclipse IDE and there are many free
resources out there to get you started.

## Online resources

Java Programming and other Java books at
Wikibooks are listed under Java programming
language.

## Books

Useful printed books are as follows:

  Title                                                                ISBN             Suitable for
  -------------------------------------------------------------------- ---------------- --------------
  Sams Teach Yourself Java in 24 Hours (covering Java 7 and Android)   978-0672335754

Android Books:

  Title                                                               ISBN             Suitable for
  ------------------------------------------------------------------- ---------------- ----------------------------
  Sams Teach Yourself Android Application Development in 24 Hours     978-0321673350   Simple android development
  Hello, Android: Introducing Google\'s Mobile Development Platform   978-1934356562   Simple android development

## Notes

```{=html}
<references />
```

[^1]: In Fedora, `sudo yum install java-1.6.0-openjdk`. See also
    `/usr/share/doc/system-switch-java-1.1.5/README` in the
    `system-switch-java` package. In Ubuntu
    `sudo aptitude install default-jdk,`

[^2]: The proprietary commercial *Ultimate* edition supports Enterprise
    Edition and includes scripts to automate
    refactoring.


# A-level Computing/AQA/Pascal

Pascal is a structured language specially designed by Niklaus Wirth for
learning programming and computer science.

## Why Pascal?

Pascal is accessible to beginners, its use of English-like syntax and
avoidance of curly brackets and other arcane symbols being similar to
Python and VB. Modern versions such as Delphi and Lazarus are very
flexible and powerful, enabling creation of console programs for AS as
well as very easy and rapid development of Graphical User Interfaces for
A2 projects. They also provide full support for Object-Oriented
Programming as required for A2. Pascal is the only language on the AQA
list which enables practical experience of pointer programming.

The open-source Free Pascal/Lazarus project provides a free, high
quality compiler and development environments for Windows, Linux and Mac
OSX.

The AQA textbook and exam papers use Pascal or Pascal-like pseudocode to
describe alogorithms.

## Why not Pascal?

The use of Pascal as a teaching language in universities peaked in the
1980\'s and is now probably extinct in the UK and US.

Pascal was never intended as a language for commercial development
though Delphi is used by some software companies especially in Eastern
Europe.

## Delphi or Free Pascal?

Lazarus/Free Pascal is
open-source, multi-platform and free!

Delphi runs only on Windows and costs
money (£23 per concurrent licence for educational use). However the
Development Environment is more polished, the compiler is much faster
and database connectivity is easier and more powerful.

## Getting Started

Download Lazarus from <http://sourceforge.net/projects/lazarus/files/>

## COMP1

Pascal fits the AQA specification very closely:

-   it\'s very easy to create console programs using a purely procedural
    approach (no objects or classes needed)
-   the use of value and reference parameters matches that described in
    the specification
-   it supports static arrays, records and sets as native data types
-   procedures and functions are distinguished and named as in the
    specification
-   traditional text files and typed files are supported

Pascal enforces strong typing and explicit variable declaration which
encourages students to think about data types before they code

## COMP3

Modern Pascal compilers provide full support for Object-Oriented
programming with a structure and syntax similar to that used in textbook
and exam questions.

The ability to use pointers explicitly, although indicative of Pascal\'s
1970\'s origins, does make it easy to teach some of the more difficult
data structure topics: linked lists, trees, use of the heap.

## COMP4

Delphi and Lazarus excel at the rapid development of graphical user
interfaces, allowing the student to spend much more time on the
underlying algorithms in their project. Only Microsoft Visual Studio
competes with this.

## Online resources

-   Delphi Basics a very clear and
    accesible reference, suitable for beginners
-   PP4S Pascal Programming for Schools,
    includes introductions to Lazarus and Delphi Object Pascal
    environments
-   Pascal Programming at Wikibooks
-   Delphi For Fun full of excellent example
    programs, including complex algorithms relevant to A2
-   About Delphi includes a very good course
    on connecting to databases

### Development environments

-   Embarcadero Delphi
    commercial and proprietary Object Pascal compiler and IDE
    -   Delphi via AQA
        (PDF)
-   Lazarus/Free Pascal open
    source Object Pascal compiler and Lazarus IDE

## Books

Pascal\'s long history in universities and industry mean that it is
thoroughly documented. Useful printed books are as follows:

  Title                                      ISBN         Suitable for
  ------------------------------------------ ------------ --------------------------------------------------
  Learning to Program in Pascal and Delphi   1904467296   specially written for A Level students
  Delphi in a Nutshell                       1565926595   reference guide for more experienced programmers
  Discover Pascal in Delphi                  0201709198   beginners


# A-level Computing/AQA/Python

Python is a free multiplatform programming
language. Its original purpose and strengths were as a scripting
language to automate the administration of Unix systems. Both the core
language and the standard library have since been extended for many
other purposes, including web, database, interactive and graphical
applications.

## Why Python?

The reference implementation of Python, CPython,
runs almost everywhere, and is well supported for Linux, Unix, Mac OS X
and Windows. Many free text editors offer syntax highlighting, code
completion, class navigation, debugger integration and other tools.
Therefore students can pursue their interest easily at home, work or at
computer clubs.

The main implementations (CPython, Jython and
IronPython) are open source and
free-of-charge. CPython is included as standard in most Linux
distributions.

As of 2012, Python is one of the two main languages that Google offers,
alongside Java, for its customer
APIs. Though not as
popular in industry as Java and VB, it has been
adopted in various fields of employment.

Python is interpreted, so trial-and-error experimentation and debugging
can be fast. The standard runtime also includes an interactive console
with access to the executing program image.

Python has a wide range of data types, both built-in and in its standard
library, though there can be some quirks and inconsistencies among them.
For example, some types are mutable and
others are immutable.

Python\'s significant whitespace makes incorrect nesting of block
structured statements "wikilink") easy to spot.

## Why not Python?

CPython\'s virtual machine is a bytecode interpreter and execution of
Python can be much slower than say, execution of Java on its HotSpot
virtual machine with just-in-time compilation.

Python\'s significant whitespace can make it easy to break a working
method with the space bar or tab key.

Python uses variables without declaring datatypes, this can be confusing
when trying to teach them.

When using classes, python doesn\'t use the keywords public and private
to specify access to attributes and methods. They are
possible,
but may confuse students.

## 2.7 or 3.x?

When you read about python you will probably learn that there are two
different versions out there. AQA allows you to use either but which one
is most suitable for you? A quick summary:

2.7 is stable, end-of-life, no further updates, but solid and widely
deployed, with a vast array of libraries and learning resources.

3.x is the future - handles multi-lingual text correctly, many
improvements, but some libraries not yet converted.

Some tutorials written for python 2.7 won\'t work in python 3.x as there
are small changes in the language such as the `print` statement in
Python 2.x being replaced with the `print` function in Python 3.x:

``` python
print "hello world" #python 2.7
print("hello world") #python 3.x
```

You can install both and they\'ll play nicely together, but when
choosing what language to pick you might be wise to check out the
resources that you have available to your students.

## Getting Started

You can get a portable version of
python that can be run directly from a USB, available in 2.7 and 3.x
versions.

If you want to use Microsoft Visual Studio you can get
IronPython which is
free and integrates python 2.7. Alternatively
you can get Python Tools for Visual
Studio which is
free and works with existing
installations of Python 2.x and/or 3.x. This gives you syntax
highlighting, Intellisense, debugging, code folding, type hints, and
more in much the same way as Visual Studio works for other languages.

Python comes pre installed on the Raspberry
Pi with development tools and lots of
supporting learning resources.

## COMP1

### Arrays

Although some users encourage learners to use Python\'s built-in
`list` as an
array, the standard library includes the `array`
module which some teachers
may prefer. See, for example,

-   <http://www.brpreiss.com/books/opus7/html/page83.html> and
-   <http://stackoverflow.com/questions/176011/python-list-vs-array-when-to-use>

**Check which array the examiners prefer.**

## COMP3

### Object Orientation

Since Python doesn\'t have the concept of explicit declarations, or
PRIVATE and PUBLIC keywords, the syntax for defining classes differs
quite a lot from the generally accepted AQA syntax, e.g., the VB.NET
class\

``` vbnet
Class MediaFile
   Public
        Sub PlayFile
            ...
        End Sub
        Function GetTitle As String
            Return Title
        End Function
        Function GetDuration As Single
            Return Duration
        End Function
   Private
        Dim Title As String
        Dim Duration As Single
  End
```

is a reasonable match to the June 2010 COMP3 question:

``` vbnet
MediaFile = Class
   Public
        Procedure PlayFile
        Function GetTitle
        Function GetDuration
   Private
        Title : String
        Duration : Real
  End
```

The Python version looks something like this:

``` python
class MediaFile
    def __init__(self):
        self.Title = ""
        self.Duration = 0.0

    def PlayFile:
        ...

    def GetTitle(self):
        return self.Title

    def GetDuration(self):
        return self.Duration
```

## COMP4

Python can be used to build anything from websites to games using
pygame (v2.7).
Blender "wikilink") has a python scripting engine
(3.x) meaning that it is possible to create
projects involving 3D
animation. Python also has a decent RAD (Rapid - Application -
Development) tool in the form of Glade and
PyGTK. Python\'s origins as a scripting
language mean that it can be used to glue together Unix programs to make
an application.

Open source library code can be imported, as teaching examples or to
extend the practical project, from PyPI <http://pypi.python.org/pypi> ,
with package management tools built into Python.

To ease the generation of some documentation, students may be introduced
to the `docstring`, a form of embedded documentation supported by Python
source code. A number of tools are available for generating readable
documents from source code containing docstrings, including
`pydoc` (in the standard
library), `Epydoc`,
`doxygen` and
`Sphinx` "wikilink").

For website creation, Python is one of the alternative \'P\'s in
LAMP. (Like Perl
and PHP, Python integrates well with Linux,
Unix, Apache HTTP Server and
MySQL.)

## Online resources

If you\'re already proficient in another programming language, the
official tutorial will get you up to speed at speed. Even if you\'re not
a programmer, this fast-paced, no-frills introduction will get you
programming in Python quickly, with a reasonable degree of mental pain!

-   Official 3.2
    tutorial
-   Official 2.7 tutorial
-   <http://mit.edu/6.01/mercurial/spring12/www/handouts/readings.pdf> A
    free handout for an MIT first year undergraduate CS course based on
    Python.
-   <http://people.csail.mit.edu/pgbovine/python/> Online Python Tutor,
    free graphical visualisation of step-by-step program execution.

Other Python books at Wikibooks are listed under Python programming
language.

## Books

Useful printed books are as follows:

+----------------------+----------------------+----------------------+
| Title                | ISBN                 | Suitable for         |
+======================+======================+======================+
| Python Programming   | 978-1435455009       | Applications and     |
| for the Absolute     |                      | Games                |
| Beginner (3.1)       |                      |                      |
+----------------------+----------------------+----------------------+
| More Python          | 978-1435459809       | Applications and     |
| Programming for the  |                      | Games                |
| Absolute Beginner    |                      |                      |
| (2.7)                |                      |                      |
+----------------------+----------------------+----------------------+
| Dive Into Python     | 978-1590593561\      | Websites             |
| (2.7)                | available for free  |                      |
|                      | online |                      |
+----------------------+----------------------+----------------------+
| Python for Software  | 978-0521725965\      | Algorithms and CS    |
| Design: How to Think | available for free  | thinking             |
| Like a Computer      | onlin                |                      |
| Scientist (2.7)      | e |                      |
+----------------------+----------------------+----------------------+
| Invent Your Own      | 978-0982106013\      | Games                |
| Computer Games with  | available for free  |                      |
| Python (3.2)         | online |                      |
+----------------------+----------------------+----------------------+


# A-level Computing/AQA/VB

## Why VB?

VB.NET is an industry standard development platform. It offers a simple
syntax that is easy to learn by beginners, yet offering the latest
programming constructs and functionality.

-   The Visual Studio
    IDE provides a
    supportive platform for new programmers, flagging up errors before
    code execution, allowing for easy debugging and
    predicting code snippets. By predicting
    code snippets a new programmer can easily discover new program
    features that they probably otherwise wouldn\'t stumble across.
-   Visual Basic is not as strict as other languages and can normally
    handle you declaring a variable with a capital letter and using it
    with a lower case letter (some people might say that this is a bad
    point!).
-   Visual basic is also weakly typed,
    meaning that it won\'t cause new programmer so many issues when
    combining data types.
-   For the second year project VB.NET allows for quick creations of
    database links and forms.
-   Visual Basic .NET is currently the most popular language for A-Level
    Computing and wikibooks currently only supports VB.NET in its
    examples. (The official textbook supports all the languages)
-   VB.NET is compatible with Mono, which is an open-source project by
    Xamarin (Previously Novell); an implementation of the .NET framework
    which is compatible with many other operating systems. This means
    your programs can be ported over with minimal effort. There is also
    a compatible IDE (Integrated Development Environment) previously
    named \'MonoDevelop\', now named \'Xamarin Studio\', which although
    is no longer open-source, there is a free version available. Mono is
    also compatible with MonoGame, which can lead on to game programming
    for both PC/Mac/Linux and mobile devices.
-   VB.NET is a \'gateway\' programming language which is easier to get
    to grips with the concepts of programming. VB.NET easily leads on to
    more powerful and advanced programming languages like C# .NET which
    are more commonly used in the industry.

### VB.NET or VB 6.0

VB 6.0 has a long history and lots of
support in terms of teaching resources and available code. There are
also Development Environments freely available. However, as of March
2008 VB6 has entered Microsoft\'s \"non-supported phase\" and no further
development is being made on the language or the official development
environment. VB 6.0 is largely looked down upon within Universities and
thought by many not be be a good way to introduce programming.

VBA is a variant of VB 6.0
and is commonly used in Microsoft Office applications; especially Excel.
This can be useful for automating tasks and creating programs/games
within Excel.

VB.NET is a fairly new language built
upon the .NET framework. This means it offers interoperability with
languages such as C# "wikilink") and
F# "wikilink"). The Development
Platforms, Microsoft Visual
Studio (Windows only) and
Mono "wikilink") (cross platform), are being
actively developed and the language is fully supported by Microsoft.
VB.NET allows for easy Object Orientation and tools to create websites,
console applications and phone applications. Many academics look down
upon VB.NET, but it is unclear whether this might be a hang-over from
their hatred of VB 6.0.

The code written for each is not compatible with the other. Microsoft
provides a converter from VB 6.0 to VB.NET but it is not perfect.

Visual Basic.NET is currently the most popular language amongst centres
running AQA A-Level Computing and all code in this wikibook is provided
in VB.NET (there are plans to add python soon).

## Why not VB?

-   Due to VB.NET being a young language that isn\'t used much in
    universities there are fewer learning resources than you\'ll find
    with the other three languages. There is very little in the way of
    extension materials for learning the command line code required for
    Unit 1.
-   Students who don\'t have MS Windows at home might struggle to
    install the Mono development environment.
-   There is no \'portable\' version of the language
-   VB.NET is used less by industry than Java and Python (though you
    should be teaching concepts and not syntax!)
-   VB.NET is very much confined to Microsoft operating systems, and it
    is harder to port software over to GNU/Linux, OSX, BSD/other
    operating systems, due to its use of the Microsoft .NET Framework.

## Getting started

A free version of Visual Basic 2010
Express is available from
Microsoft.

The multi-platform
Mono project

## COMP1

COMP1 requires the student to sit an exam based around a command line
program published by AQA. There are very few command line tutorials for
VB.NET and the best currently available are:

-   studyvb.com
-   The Nelson Thornes AQA accredited
    textbook
-   This wikibook has a tutorial matched to the
    specification

Another way to start learning VB.NET is by starting with Microsoft Small
Basic as it is a simplified version of VB.NET: both these compilers are
available free. I would recommended that only a few weeks are spent
using this since there a number of differences, e.g., Visual Basic.NET
uses *Console* where Small Basic uses *TextWindow*.

Small Basic comes with a Tutorial
(PDF)
which is an introduction to programming and the language. Reference
Documentation is also available and
displays all the built-in Objects with their Properties and Operations.
Microsoft has also written a comprehensive
curriculum. It has the
feature to graduate to the full version and converts any Small Basic
programs in the process. One of the language\'s most useful features is
that it can publish any program online at a click of a button, providing
a shortened URL, but Silverlight is needed for this. Silverlight is
proprietary software and only officially works with Windows and OSX.
SmallBasic is not available for Linux and there are no open-source
alternatives (Like Mono and Xamarin Studio) and this may cause problems
with students who do not use a Microsoft based system.

## COMP3

To complete the COMP3 theory exam students should have experience of
programming many of the algorithms described. VB.NET allows for object
orientation with a few minor quirks.

## COMP4

The COMP4 project requires that students undertake a project of their
own. VB.NET offers the ability for students to build console apps,
forms, websites or phone apps. Students should not use Visual Basic for
Applications.

Microsoft has made video tutorials available on its Beginner Developer
Learning Center
which increase in complexity through three tiers. The first
tier introduces
the Visual Studio programming environment. The second
tier focuses on
the key features of the language through forms. Finally the third
tier follows
the development of an RSS reader, this can be useful for COMP4 projects.
They also have an
\[<http://msdn.microsoft.com/en-gb/library/bb330924(VS.80>).aspx
introduction document\] in the MSDN Library.

Home and Learn also offers useful tutorials on building a forms
application, Visual Basic .NET Programming for
Beginners.

The general wikibooks VB.NET article may
also be useful.

## Books

Useful printed books are as follows:

  Title                                                                     ISBN             Suitable for
  ------------------------------------------------------------------------- ---------------- ----------------------------
  Sams Teach Yourself Visual Basic 2010 in 24 Hours: Complete Starter Kit   978-0672331138   Applications and databases
  Visual Basic Game Programming for Teens (3rd edition)                     978-1435458109   Games and Graphics
  Sams Teach Yourself ASP.NET 4 in 24 Hours: Complete Starter Kit           978-0672333057   Websites
  (no known command line books)


# A-level Computing/AQA/CSharp

C# (pronounced \"C-sharp\") is an object-oriented programming language
from Microsoft that aims to combine the computing power of C++ with the
programming ease of Visual Basic. C# is based on C++ and contains
features similar to those of Java.

C# is designed to work with Microsoft\'s .Net platform. Microsoft\'s aim
is to facilitate the exchange of information and services over the Web,
and to enable developers to build highly portable applications. C#
simplifies programming through its use of Extensible Markup Language
(XML) and Simple Object Access Protocol (SOAP) which allow access to a
programming object or method without requiring the programmer to write
additional code for each step. Because programmers can build on existing
code, rather than repeatedly duplicating it, C# is expected to make it
faster and less expensive to get new products and services to market.


# Organic Chemistry/Cover

```{=html}
<div style="text-align: center;">
```
Welcome to the world\'s foremost open content\
`<big>`{=html}`<big>`{=html}`<big>`{=html}**Organic Chemistry
Textbook**`</big>`{=html}`</big>`{=html}`</big>`{=html}\
on the web!

```{=html}
</div>
```
  ------------------------------------------------------------------------------------------------------------------------------ ---------------------------------- -------------------------------------------------------------------------------------------------
  ------------------------------------------------------------------------------------------------------------------------------ ---------------------------------- -------------------------------------------------------------------------------------------------

## The Study of Organic Chemistry

Organic chemistry is primarily devoted to the unique properties of the
carbon atom and its compounds. These compounds play a critical role in
biology and ecology, Earth sciences and geology, physics, industry,
medicine and --- of course --- chemistry. At first glance, the new
material that organic chemistry brings to the table may seem complicated
and daunting, but all it takes is concentration and perseverance.
Millions of students before you have successfully passed this course and
you can too!

This field of chemistry is based less on formulas and more on reactions
between various molecules under different conditions. Whereas a typical
general chemistry question may ask a student to compute an answer with
an equation from the chapter that they memorized, a more typical organic
chemistry question is along the lines of \"what product will form when
substance X is treated with solution Y and bombarded by light\". The key
to learning organic chemistry is to *understand* it rather than cram it
in the night before a test. It is all well and good to memorize the
mechanism of Michael addition, but a superior accomplishment would be
the ability to explain *why* such a reaction would take place.

As in all things, it is easier to build up a body of new knowledge on a
foundation of solid prior knowledge. Students will be well served by
much of the knowledge brought to this subject from the subject of
General Chemistry. Concepts with
particular importance to organic chemists are covalent bonding,
Molecular Orbit theory, VSEPR Modeling, understanding acid/base
chemistry vis-a-vis pKa values, and even trends of the periodic table.
This is by no means a comprehensive list of the knowledge you should
have gained already in order to fully understand the subject of organic
chemistry, but it should give you some idea of the things you need to
know to succeed in an organic chemistry test or course.

Organic Chemistry is one of the subjects which are very useful and close
to our daily life. We always try to figure out some of the unknown
mysteries of our daily life through our factious thinking habit, which
generates superstitions. Through the help of chemistry we can help
ourselves to get out of this kind of superstition. We always try to find
the ultimate truth through our own convenience. In the ancient past we
had struggled to make things to go as per our need. In that context we
have found fire, house, food, transportation, etc\...

Now the burning question is: \"how can chemistry help our daily life?\"
To find the answer of this questions, we have to know the subject
thoroughly. Let us start it from now.


# Organic Chemistry/To-Do List

\_\_NOTOC\_\_ \_\_NEWSECTIONLINK\_\_

```{=html}
<div class="noprint">
```
![](Go_To_Organic_Chemistry_Contents.png "Go_To_Organic_Chemistry_Contents.png")

## Overview

This section is not meant to be part of the printed book. It is simply a
place for people working on the text to organize their thoughts about
work they have pending, ideas they\'re tossing around, and so forth.
Simply add a section for your own name and then add whatever information
you want specific to your own needs. Please do not edit or comment on
other peoples\' sections without first discussing it in the discussion
section.

Besides acting as personal reminders, it also allows other people
working on the book to see who else is working on different sections and
what plans they have, as an aid to avoid duplicated efforts, stepping on
each others\' toes, and so forth.

Just hit the + icon at the top and add a section for yourself (try not
to edit the whole page or you\'ll update the automated Last Updated code
for everyone who\'s using it.)

## Pete Davis

-   Need a clear index. Functional groups rather be the lesson 1 than
    one appendix.
-   Need to complete ToDo sections in
    cycloalkanes
-   Need to complete discussions of **E1** and **E2**
    elimination
    reactions.
-   Need to finish fixing up functional
    groups
    chart stolen from wikipedia
-   Glossary continues to need
    new definitions.
-   Haloalkanes needs a lot
    of work. The stuff on S~N~1 and S~N~2 reactions needs to be merged
    with the existing stuff on these reactions. The text also needs to
    be written like a textbook, not a checklist of information.
-   We need to discuss Torsional strain somewhere. I\'m mentioning it in
    cycloalkanes, but I don\'t believe it\'s covered before then and it
    should probably be discussed earlier than that, probably in either
    Alkanes or in the stereochemistry section.
-   Okay, more strange stuff. Ethers are at the end of the Alcohol
    section. Ethers should probably be their own section\...
-   McMurray has Ethers in a section called *Ethers and Epoxides; Thiols
    and Sulfides*. We might want to put together a miscellaneous section
    similar to that. On the other hand, Carey has *Alcohols, Diols, and
    Thiols* together and then a separate chapter for *Ethers, Epoxides,
    and Sulfides*. There\'s an argument to be made for placing Thiols
    with alcohols.
-   Before Ketones and Aldehydes, we might want to have a short section
    discussing carbonyls in general, since they encompass aldehydes,
    ketones, carboxylic acids, esters, amides, enones, acid chlorides,
    and anhydrides. I think of those, we only cover the first 3 well and
    have everything else summarized pretty briefly in Carboxylic Acid
    Derivatives, which barely scratches the surface on any of the
    remaining. Several of them, at least, deserve more than passing
    attention.
-   Add Kolbe\'s Electrolysis to Carboxylic Acids page. Radical reaction
    to create alkanes by decarboxylation and dimerisation of R groups of
    carboxylic acids.
-   Need to finish writing about bond polarities and dipole moment in
    the Bonding section. And then need to discuss Molecular
    Electrostatic Potential maps in Visualization.

## Up for Grabs

The items listed below need to be done, but nobody has claimed them yet.
If you want to claim one, add it to your list.

-   End of chapter problems. Every chapter should have problems for the
    reader to work. Instead of having them on the main chapter page,
    there should be a link to the problem page and a separate link to
    the answers page. We should try to come up with about 50 problems
    per chapter, eventually.

```{=html}
</div>
```
## Dharav Solanki

I will start contributing to this wikibook within about two months. I
already have concise notes of the subject ready, so that gives me an
impression that a better TO-DO list exists offline for me!

I would be concentrating on other side projects as well, So I request
the other contributors to chisel out the rough works that I submit. I
believe that starting from scratch is a tad too difficult and hence I
would advocate a layered editing rather than submission of already
edited work, because otherwise, the contributions are too scarce.

-   Grabbed - End Of Chapter Problems as well as Intext exercises.

```{=html}
<!-- -->
```
-   A lot of editing has to be done in the works already submitted. The
    text at many places is loose, in the sense that those having free
    access to a library or a good tutor do not have anything to reap
    from this book, while at the same time they have to stress
    themselves a lot in understanding the latter two.

```{=html}
<!-- -->
```
-   I feel I\'d edit the text as DIY format at places possible, so that
    some of the newer logic is more like an interactive session rather
    than a dull article.

\--Thewinster
(talk) 08:54, 12 February 2008 (UTC)

i think there HAS to be a individual topics such as amides rather than a
tiny tiny thing thats part of carboxylic acid derivatives. There is alot
of information missing.