In this minimization problem we have $N$ items, $j= 1, 2, \dots, N$ and a decision variable $x_j$ which are continuous values. For every item, we have a nonlinear objective function $f$ in function of the decision variables $x_j$ that we want to minimize. We also have a variable $d_j$ that is different for every item and a variable $a_j$ that contains values from the set $\lbrace 0, 1, 2\rbrace$. Look at this $a$-variable as a classification that puts all items in one of three classes. I want to formulate the problem where we minimize $\sum_{j=1}^Nf(x_{j})$ but $x_j$ must be fixed for each class, so there are at most $3$ different values for $x_j$. Apart from that, we have the constraints $0.00 \le x_j < 1.00$ and $$\frac{\sum_{j=1}^N d_jx_{j}}{\sum_{j=1}^N d_j} = \beta,$$ where $0.00 \le \beta < 1.00$.
To make it a bit more clear, you can imagine the following table as an example of a valid (but not necessarily optimal) solution:
item a x d f(x)
1 0 0.98 198 212.5
2 1 0.95 50 1245.2
3 0 0.98 110 100.2
4 2 0.92 20 120.8
5 1 0.95 80 521.2
6 1 0.95 36 8232.1
7 0 0.98 109 3245.7
8 2 0.92 15 58.2
9 0 0.98 140 5123.2
10 2 0.92 10 4128
In this valid solution, $\beta = 0.97$ and the result of the objective function is $22987.1$.
How can I formulate this NLP problem by enforcing the constraints mentioned?