In reply to Hector Alvaro Rojas.

Thanks, Hector. Incorporating the "cost" variable is a pretty wider area in machine learning. Actually it can be considered as a subfield of reinforcement learning -- based on the cost (reward), the agent determines the actions that he/she wants to take. I considered this problem for a while and haven't found a good example (or real user case) for it. If I have a time, I will write a blog specifically for the reinforcement learning.