set_weight_from()

Set the weight of one or more edges in a network

Synopsis

set_weight_from(network, agent-id, pair-expression)
set_weight_from(network, agent-list, pair-expression)

Description

Set the weight on the edge to the calling agent from the agent-id in the given network. Has no effect if there is not already an edge between the two agents in the network.

If the second argument is a list of agent IDs, all existing edges to the calling agent from the agents in the list are set.

The pair-expression is evaluated for each target agent to set the weight of the edge, if it exists. All agent properties in the pair-expression refer to the calling agent, but any occurrence of the special variable “_” refers to the target agent.

Parameters

network

The name of a network. The network must bedeclared in the model.

agent-id

An expression that evaluates to an agent ID.

agent-list

A list-expression that evaluates to a list of agent IDs.

pair-expression

A pair-expression that evaluates to a number.

Examples

Set the weights in the age-network on edges from members of the agent’s household, with weight equal to the age of the other agent minus the age of the calling agent:

set_weight_from(age_network, members(Household), ask(_,age) - age)

See Also

set_weight_to(), pair-expression