set_weight_to()
Set the weight of one or more edges in a network
Synopsis
set_weight_to(network, agent-id, pair-expression)
set_weight_to(network, agent-list, pair-expression)
Description
Set the weight on the edge from the calling agent to 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 arguments is a list of agent IDs, all existing edges between the calling agent and 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 to 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_to(age_network, members(Household), ask(_,age) - age)