Revised 2011-05-10 BLW

Return to the Index

# Using Internal Resources

Avida has the ability to allow organisms to uptake resources from the environment and keep them in a private store of "resource bins". These internal resources may then be used instead of the normal environmental resources to complete reactions.

Most configuration of internal resource use is done with config options in avida.cfg, all of which are found in the HOARD_RESOURCE_GROUP. Some more advanced uses require modifications to the environment file as well. There is also a family of instructions which allows organisms to manipulate resources.

## Turning on internal resources

Most internal resource code is protected by a guard to make sure it does not slow Avida down if internal resources are not being used. In order to use internal resources, you must change a line in avida.cfg:

    USE_RESOURCE_BINS 0

to

    USE_RESOURCE_BINS 1

## Basic resource uptake

To remove resource from the environment and transfer it into its private store, an organism must execute the collect instruction (or one like it, see below). This instruction should be added to the instruction set.

    ABSORB_RESOURCE_FRACTION .0025

This setting controls the fraction of the available environmental resource the organism may absorb. The default value is the same as the default value for the 'frac' reaction specification, so that an organism will remove the same amount of resource from the environment whether it is storing it or using it to complete a reaction.

    MAX_TOTAL_STORED -1

This setting defines a cap on the maximum total amount of internal resource an organism can store. The default is -1, indicating that there is no cap.

## nop-specification

The collect instruction (and most of its variants) determine which resource to affect by looking at the nop instructions which follow it. This specification is robust to both the number of specifying nops (i.e. nop-A, nop-B, and nop-C, but not nop-X) in the instruction set and the number of resources in the environment file.

collect always affects a single resource. If there are no nops follwing it, it chooses randomly from all the resources. Increasing levels of specification narrow down the range of the resource spectrum from which it chooses randomly. For example, in a three-nop, nine-resource system, collect nop-A nop-B affects resource 1 (remember resource ids are 0-based), which is usually the resource tied to NOR.

## collect variant instructions

### collect-unit-prob

Resources ought to be harder to uptake as they become more scarce. The original collect instruction models this by uptaking a smaller amount of resource as the resource becomes more scarce. collect-unit-prob models the scarcity issue differently: 1 unit of resource is always collected, but the instruction may fail, and fails more frequently as the resource becomes scarce: the instruction has a probability of succeeding equal to the current units of resource available divided by the COLLECT_PROB_DIVISOR setting. This instruction ignores the ABSORB_RESOURCE_FRACTION setting.

    COLLECT_PROB_DIVISOR 1000

This setting defines the divisor for probabilistic collect instructions, which have a chance of (current level of resource) / COLLECT_PROB_DIVISOR of succeeding -- this chance is capped at 1. As it is a divisor, it should not be set to 0.

### destroy

The destroy instruction removes an amount of resource from the environment, but does not add it to the organism's internal resource bin. Like collect, the amount removed is governed by ABSORB_RESOURCE_FRACTION.

### collect-no-env-remove

The collect-no-env-remove instruction adds an amount of resource to the internal resource bin of the organism, but does not remove any resource from the environment; it injects extra resource into the system. Even though no resource is removed from the environment, the amount added to the organism is still controlled by the ABSORB_RESOURCE_FRACTION setting.

### nop-collect

The nop-collect instruction neither adds resource to the organism nor removes it from the environment. Instead, it provides a no-operation instruction to use in comparison with the other collect instructions. It should be used in place of nop-X for such comparisons; since the collect instructions are nop-specified, they effectively "eat" nops, affecting execution flow as well as dealing with resources. nop-collect affects execution flow in the same way.

### collect-specific

The collect-specific instruction is not nop-specified (and so should be compared to nop-X rather than nop-collect). Instead, the resource it affects is determined by the config setting COLLECT_SPECIFIC_RESOURCE.

    COLLECT_SPECIFIC_RESOURCE 0

This setting determines which resource the collect-specific instruction affects. (Remember that resources are numbered from 0 in the order they appear in the environment file.) It also specifies which resource should be added to injected or newborn organisms if non-zero amounts are specified by RESOURCE_GIVEN_ON_INJECT or RESOURCE_GIVEN_AT_BIRTH. It should not be given a value outside of the range of resource ids.

## Using internal resources to complete reactions

Once an organism has internal resources in its resource bins, it may use internal resources instead of environmental resources to complete reactions. An organism will do this when the amount of environmental resources available is less than the amount of internal resource available. How much of the internal resource is used is controlled with the USE_STORED_FRACTION config setting. The amount of environmental resource which is considered may be controlled by the ENV_FRACTION_THRESHOLD config setting.

    USE_STORED_FRACTION 1.0

This setting controls the fraction of the internal resource that the organism will use to complete a reaction. By default this 1.0, meaning that the organism will use all the available internal resource to complete a reaction. As a fraction, this value should remain between 0.0 and 1.0.

    ENV_FRACTION_THRESHOLD 1.0

This setting controls how much of the available environmental resource the organism should consider when deciding which type of resource to use. By default it is set to 1.0, indicating that the organism should consider all the available environmental resource. As a fraction, this value should remain between 0.0 and 1.0

### Forcing internal resource use

It is possible to force organisms to always use internal resources to complete reactions -- consequently forcing the population to either use the collect instruction or become pure self-replicators. This can be done by forcing the organisms to believe that no environmental resource is ever available, setting:

    ENV_FRACTION_THRESHOLD 1.0

to

    ENV_FRACTION_THRESHOLD 0.0

As a precaution, you should also change the 'frac' specification of the REACTIONs in your environment file to be 0.0 (rather than the common .0025 or the default 1.0).

## Resource sources and sinks

The most common source of internal resource is via collect or one of its variants, in most cases from the environment (but see collect-no-env-remove). However, an organism may also recieve new internal resource when it is injected (if RESOURCE_GIVEN_ON_INJECT is set above 0) or when it is born (if RESOURCE_GIVEN_AT_BIRTH is set above 0).

    RESOURCE_GIVEN_ON_INJECT 0

This setting specifies the units of the resource given by COLLECT_SPECIFIC_RESOURCE that should be added to an organism when it is injected. The default is to add no resource.

    RESOURCE_GIVEN_AT_BIRTH 0

This setting specifies the units of the resource given by COLLECT_SPECIFIC_RESOURCE that should be added to an organism when it is born. The default is to add no resources.

When an organism splits into two daughter organisms, each daughter gets half of the original internal resource store if SPLIT_ON_DIVIDE is set. (If it is set to 0, the resource disappears.)

    SPLIT_ON_DIVIDE 1

This setting determines whether the mother cell's resources should be split between its two daughter cells on division. It defaults to true; if set to 0 (false), the mother cell's internal resource simply disappears. This setting has not been tested with DIVIDE_METHODs other than 1.

When an organism dies, its internal resources are returned to the environment if RETURN_STORED_ON_DEATH is set.

    RETURN_STORED_ON_DEATH

This setting determines whether an organsim's internal resources are returned to the environment when the organism dies. It defaults to true; if set to 0 (false), the resource simply disappears. This setting has not been tested with deaths not by old age.