Portfolio allocation with a few twists
I'd suggest using integer linear programming (ILP).  You need to buy an integer number of stocks, so you can use integer variables to represent the amount of each stock you buy.  ILP can express constraints (requirements that must be true).  The main limitation is that the objective function you are trying to minimize must be a linear function of the variables, but that can often be accomodated with auxiliary variables.  For instance, your rules about the fees for buying different stocks can be expressed with ILP.

You'll have to figure out how you want to quantify and formalize "allocation that is approximately close to the model", as currently that is rather vague.  Also note that anytime you say you have two goals, you aren't ready to formulate this as an optimization problem, because that leaves open how you plan to trade off the goals.  You need to identify a single objective function you want to minimize, which means you'll need to think how you want to combine fee minimization with approximate model allocation.  We can't tell you how to do that as that is a matter of what you want to achieve.  One way would be to sum up the absolute value of the deviations from the model, and require this to be no more than a certain maximum.  Another way would be to sum up the absolute value of the deviations, and add that to the objective function as an extra penalty.