A resource allocation problem, called the dynamic and stochastic knapsack p
roblem (DSKP), is studied. A known quantity of resource is available, and d
emands for the resource arrive randomly over time. Each demand requires an
amount of resource and has an associated reward. The resource requirements
and rewards are unknown before arrival and become known at the time of the
demand's arrival. Demands can be either accepted or rejected. If a demand i
s accepted, the associated reward is received; if a demand is rejected, a p
enalty is incurred. The problem can be stopped at any lime, at which time a
terminal value is received that depends on the quantity of resource remain
ing. A holding cost that depends on the amount of resource allocated is inc
urred until the process is stopped. The objective is to determine an optima
l policy for accepting demands and for stopping that maximizes the expected
value (rewards minus costs) accumulated. The DSKP is analyzed for both the
infinite horizon and the finite horizon cases. It is shown that the DSKP h
as an optimal policy that consists of an easily computed threshold acceptan
ce rule and an optimal stopping rule. A number of monotonicity and convexit
y properties are studied. This problem is motivated by the issues facing a
manager of an LTL transportation operation regarding the acceptance of load
s and the dispatching of a vehicle. It also has applications in many other
areas, such as the scheduling of batch processors, the selling of assets, t
he selection of investment projects, and yield management.