Optimization Based Control For Multi-Agent System With Interaction