We focus on the optimal resource allocation problems with global equality constraints and convex function inequality constraints over heterogeneous linear multi-agent systems. The resource allocation problem aims to minimize the total objective function through neighboring information exchange. First, based on the state variable information, Karush-Kuhn-Tucker(KKT) conditions, and proportionalintegral control concept, we propose an initialization-free distributed optimization algorithm, where each agent is driven by the gradient(subgradient) of its local objective function and local constraint convex function. In addition, the penalty factor control parameter is changed adaptively. Next, we propose an output-based distributed optimization algorithm that uses a Luenberger observer when the state variable is not accessible. Based on Lyapunov stability, it is proved that the proposed algorithms converge to the optimal solution of the resource allocation problem. Finally, simulation examples are used to demonstrate the effectiveness of the proposed algorithms.