An algebraic framework for swarm and evolutionary algorithms in combinatorial optimization