I hope you are asking about the approach of portfolio structuring rather than the measurement of returns. The former is more interesting because any level of "return" is achievable with leverage, which should incentivize you to incorporate the idea of risk into your problem.
This is a core problem of financial economics, so there is plenty of literature to explore in regards to "clever ways" of doing this. To help get you started, here is a quick intro (most of which you already have the intuition of):
- At time $t$, each stock $i$ has a price $p_{i,t}$
- In general, we care about the return $R_{i,t} = \frac{p_{i, t} + d_{i, t}}{p_{i, t-1}}$, where $d_{i,t}$ represents the dividend of stock $i$
- We typically consider the return to be a random variable $\tilde{R}_{i,t}$, and thus care about it's expected return $E[\tilde{R}_{i,t}]$
- Putting all of your $n$ stocks together with weights $w$ results in a portfolio return $E[\tilde{R}_{t}] = \sum\limits_{i=1}^n w_i E[\tilde{R}_{i,t}]$
Now, your question what one should do from here. The classic formulation is not a constrained maximization with the portfolio return as the objective function. This is because such a problem does not account for the risk in your portfolio, by which we mean the variance of the portfolio $w'Vw = \sum\limits_{i=1}^n \sum\limits_{j=1}^n w_i w_j Cov(R_i, R_j)$. The basic economic intuition is that the market won't allow you to have high returns without taking high risk.
Thus, the constrained optimization problem is to minimize your portfolio variance subject to a minimum level of return $\mu$ and your portfolio weights summing to 1:
$$\min\limits_w \frac{1}{2} w'Vw$$
subject to:
$$w'E[R] \geq \mu$$
$$w'1 = 1$$
This is the famous Modern Portfolio Theory result by Harry Markowitz. From here, there is plenty of clever work and disagreement on what constitutes the best portfolio, so I leave that to you :D