I have an equation $x = 3a+4b+2c+4d$, where $a$, $b$, $c$ and $d$ are nonnegative integers such that $a+b+c+d=5$. What algorithm can I use to calculate maximum value of $x$?
Your problem is a special case of the integer programming problem which is known to be NP-complete. One possible approximation is branch-and-bound algorithm. However, if you have only 4 variables $a,b,c,d$ and and additional constraint such as $a,b,c,d \geq const$, then why not try brute force? In case $const =0$ you would have only $6^4 = 1296$ possibilities.