I've the following problem: I have 890 data points, having a value which we will call y, I have the following relationship defined:
$h(y) = -\log(y + 0.1)*5 $
I have to attribute a value $m_i$ to each data point, such that $ m$ is proportional to $h^2(y_i)$ (for high $h^2(y_i)$ we give high $m_i$ values and for low $h^2$ values we give low $m$ values).
In order to get a better intuition, I plotted $h^2(y)$ for each data point and I'm getting this plot
Intuitively, we would define a simple linear function $f$ such that:
$m = f(u) = \alpha u + \beta$
where $u = h(y)^2$, this we way we can have the same curve as $h$ and the propotionality problem is solved. However I have two main constraints to respect:
- Every $m_i$ must be less or equal to 100 ($m_i$ is real and positive, it can be null)
- The sum of all $m_i$ is less or equal to 50 000 (or any number $K$ I have).
This problem was originally an optimization problem, so it's preferable to use all available quantity of $m_i$ (the sum should equal 50 000 (or K in general))
I have absolutely no clue on how to find the right $\alpha$ and $\beta$ that achieve this while respecting the constraints above
Thanks for your help
$Note:$ $y_i$ is a real number between 0 and 1 as you can see for the plot (x axis).

The OLS objective is $\sum_{i=1}^N (m_i - \alpha u_i - \beta)^2$. Impose the additional constraints that $\alpha u_i + \beta \le 100$ for all $i$, and $\sum_{i=1}^N (\alpha u_i + \beta) \le K$.
So the Lagrangian is $$ \mathcal{L} = \sum_{i=1}^N (m_i - \alpha u_i - \beta)^2 + \sum_{i=1}^N \mu_i \left(\alpha u_i + \beta -100\right) + \lambda \left( \sum_{i=1}^N (\alpha u_i + \beta) - K \right) $$ where the $\mu_i$ are the multiplier's on each 100-constraint, and $\lambda$ is the multiplier on the $K$-constraint. The FONCs would be $$ -\sum_{i=1}^N 2(m_i-\alpha u_i - \beta)u_i + \sum_{i=1}^N \mu_i u_i + \lambda \sum_{i=1}^N u_i =0 $$ and $$ - \sum_{i=1}^N 2(m_i - \alpha u_i - \beta) + \sum_{i=1}^N \mu_i + \lambda N = 0 $$ plus the complementary slackness conditions. You can solve simple OLS by hand, but it's not obvious to me that it's true here because of the complementary slackness conditions. If there was an obvious pattern between $m_i$ and $u_i$, like monotonicity, maybe you could.
You probably want to just run OLS or OLS plus the $K$-constraint first to get a guess, then launch the solver from that guess once you impose the extra constraints. If many of the $N$ 100-constraints are binding, and $N=890$, there are $2^{890}$ potential patterns of active/slack constraints. You could play with the FONC's for the problem above to potentially characterize which are $i$ constraints are binding and which are slack a priori, instead of letting the solver sort it out.
https://en.wikipedia.org/wiki/Karush%E2%80%93Kuhn%E2%80%93Tucker_conditions