I have a simple (indeed standard in economics) nonlinear constrained *discrete* maximisation problem to solve in R and am having trouble. I found solutions for *parts* of the problem (nonlinear maximisation; discrete maximisation) but not for the union of all the problems.

Here is the problem. A consumer wants to buy three products (ananas, banana, cookie), knows the prices and has a budget of 20€. He likes variety (i.e., he wants to have all three products if possible) and his satisfaction is decreasing in the amount consumed (he likes his first cookie way more than his 100th). 

The function he wishes to maximise is

[![function to maximize](https://i.stack.imgur.com/ATIKS.png)](https://i.stack.imgur.com/ATIKS.png)

and of course since each has a price, and he has a limited budget, he maximises this function under the constraint that

[![enter image description here](https://i.stack.imgur.com/N7UQI.png)](https://i.stack.imgur.com/N7UQI.png)

What I want to do is to find the optimal buying list (N ananas, M bananas, K cookies) that satisfies the constraint.

If the problem were linear, I would simply use linprog::solveLP(). But the objective function is nonlinear.
If the problem were of a continuous nature, ther would be a simple analytic solution to it.

The question being discrete and nonlinear, I do not know how to proceed.

Here is some toy data to play with.

```
df <- data.frame(rbind(c("ananas",2.17),c("banana",0.75),c("cookie",1.34)))
names(df) <- c("product","price")

```

I'd like to have an optimization routine that gives me an optimal buying list of (N,M,K).

Any hints?