Custom optimization algorithms for efficient hardware implementation