1. A method of assigning sets of assignments to at least one agent, the at least one agent being capable of assuming a plurality of states, the method comprising, operating a data processor executing the following program instructions for each said agent; constructing a graph having a plurality of vertices and a plurality of edges, each vertex of said plurality of vertices representing an assignment performable by said agent while being at a respective state of said plurality of states, and each edge of said plurality of edges connecting two vertices of said plurality of vertices, hence representing a transition between two states of said plurality of states; assigning a predetermined weight for each vertex of said plurality of vertices; and using a longest-path algorithm for obtaining a path over said graph, said path having a plurality of connected vertices and being characterized by a substantial optimal objective function defined using respective weights of said plurality of connected vertices; thereby assigning to said agent a set of assignments represented by said plurality of connected vertices of said graph.