negmas.ga

Implements GA-based negotiation mechanisms

class negmas.ga.GAMechanism(initial_state: GAState | None = None, *args, n_population: int = 100, mutate_rate: float = 0.1, **kwargs)[source]

Bases: Mechanism[NegotiatorMechanismInterface, GAState, MechanismAction, SorterNegotiator]

Naive GA-based mechanism that assume multi-issue discrete domains.

Parameters:
  • *args – positional arguments to be passed to the base Mechanism

  • **kwargs – keyword arguments to be passed to the base Mechanism

  • n_population – The number of outcomes for each generation

  • mutate_rate – The rate of mutation

crossover(outcome1: tuple, outcome2: tuple) tuple[source]

Uniform crossover

generate(n: int) list[tuple][source]

Generate.

Parameters:

n – Number of items.

Returns:

The result.

Return type:

list[Outcome]

mutate(outcome: tuple) tuple[source]

Uniform crossover with random outcome

next_generation(parents: list[tuple]) list[tuple][source]

Generate the next generation from parents

select(outcomes: list[tuple]) list[tuple][source]

Select Pareto optimal outcomes

update_dominant_outcomes()[source]

Return dominant outcomes of population

update_ranks()[source]

Update ranks.

class negmas.ga.GAState(running: bool = False, waiting: bool = False, started: bool = False, step: int = 0, time: float = 0.0, relative_time: float = 0.0, broken: bool = False, timedout: bool = False, agreement: Outcome | None = None, results: Outcome | OutcomeSpace | tuple[Outcome] | None = None, n_negotiators: int = 0, has_error: bool = False, error_details: str = '', erred_negotiator: str = '', erred_agent: str = '', dominant_outcomes: list[Outcome] = NOTHING)[source]

Bases: MechanismState

Defines extra values to keep in the mechanism state. This is accessible to all negotiators

dominant_outcomes: list[tuple][source]