In MiniZinc you can write the decision variables and constraints in the following manner:
set of int: Products = 1..3;
array[Products] of string: color = ["red", "green", "blue"];
array[Products] of int: merit = [10, 5, 27];
array[Products] of int: price = [4, 7, 20];
% decision variables: how much of which product?
array[Products] of var int: volume;
% the money available to spend on products
int: Budget = 100;
% money is our limiting factor
constraint
Budget > sum([volume[p] * price[p] | p in Products]);
% volumes mustn't be negative
constraint
forall(p in Products) ( volume[p] >= 0 );
% as much merit as fits into our budget
solve maximize sum([volume[p] * merit[p] | p in Products]);
output
[ "\n\(p): \(volume[p]) x \(color[p]) "
++ "cost:\(volume[p]*price[p]) merit:\(volume[p]*merit[p])"
| p in Products ];
This is somehow similar for most constraint solvers. The given example could also be solved with linear programming solvers.