A growing body of evidence suggests that the drug concentration in the effect compartment of the body is the major factor regulating self-administration behavior. A novel computer-based protocol was developed to facilitate studies on mechanisms of drug addiction by determining correlations between drug levels and behavior during multiple drug injections and infusions. The core of the system is a user's program written in Medstate Notation language® (Med-Associates, Inc.), which runs the self-administration session (with MED-PC® software and hardware, Med-Associates, Inc.) and calculates the levels of infused and/or injected drugs in real time during the session. From the comparison of classical exponential and simple linear models of first-order kinetics, it is concluded that exponential solutions for the appropriate differential equations may be replaced with linear equations if the cycle of computation is much shorter than the shortest half-life for the drug. The choice between particular computation equations depends on assumptions about the pharmacokinetics of the particular drug: (i) one-, two-or three-compartment model, (ii) zero-, first-or second-order process of elimination, (iii) the constants of distribution and elimination half-lives of the drug are known or can be reasonably assumed, (iv) dependence of the constants on the drug level, and (v) temporal stability of all parameters during the session. This method of drug level computation can be employed not only for self-administration but also for other behavioral paradigms to advance pharmacokinetic/pharmacodynamic modeling.