When a practical problem can be modeled as a constraint satisfaction problem (CSP), which is a set of constraints that need to be satisfied, it can be solved using many constraint programming techniques. In many practical applications, while users can recognize examples of where a CSP should be satisfied or violated, they cannot articulate the specification of the CSP itself. In these situations, it can be helpful if the computer can take an active role in learning the CSP from examples of its solutions and non-solutions. This is called constraint acquisition. This paper introduces a framework for constraint acquisition in which one can uniformly define and formulate constraint acquisition problems of different types as optimization problems. The difference between constraint acquisition problems within the framework is not only in the type of constraints that need to be acquired but also in the learning objective. The generic framework can be instantiated to obtain specific formulations for acquiring classical, fuzzy, weighted or probabilistic constraints. The paper shows as an example how recent techniques for acquiring classical constraints can be directly obtained from the framework. Specifically, the formulation obtained from the framework to acquire classical CSPs with the minimum number of violated examples is equivalent to a simple pseudo-boolean optimization problem, thus being efficiently solvable by using many available optimization tools. The paper also reports empirical results on constraint acquisition methods to show the utility of the framework..