> For the complete documentation index, see [llms.txt](https://documentation.virtuedeep.tech/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documentation.virtuedeep.tech/affective-computing-by-virtue/designing-solutions-powered-by-affective-computing/understanding-project-components/logics.md).

# Logics

Understand what logics are and the role they play in solution design.

Logics customize and guide the platform's interactions with users. They are the key to personalizing the experience provided by your solution. They work hand in hand with other core components of projects ([entities](https://documentation.virtuedeep.tech/affective-computing-by-virtue/designing-solutions-powered-by-affective-computing/understanding-project-components/entities.md), [objects](https://documentation.virtuedeep.tech/affective-computing-by-virtue/designing-solutions-powered-by-affective-computing/understanding-project-components/objects.md), [actions](https://documentation.virtuedeep.tech/affective-computing-by-virtue/designing-solutions-powered-by-affective-computing/understanding-project-components/actions.md), [attributes](https://documentation.virtuedeep.tech/affective-computing-by-virtue/designing-solutions-powered-by-affective-computing/understanding-project-components/attributes.md), and [interaction channels](https://documentation.virtuedeep.tech/affective-computing-by-virtue/designing-solutions-powered-by-affective-computing/understanding-project-components/interaction-channels.md)) to help you define when, for whom, and what actions are delivered over the course of running your solution.

For example, you can configure a logic that plays a personalized greeting (audio message) whenever a user enters a room in the experience environment.

{% hint style="info" %}
**A note on naming.** What this documentation calls a **variable** appears as a *condition* in API request and response fields, and what it calls an **output** appears as an *action*. The product vocabulary changed ahead of the API field names; the fields will be brought in line during a later API revision.
{% endhint %}

## Logic components

When creating logics for Affective Computing (powered by Virtue) projects, you must configure the following components:

<table><thead><tr><th width="193">Component</th><th data-type="checkbox">Mandatory</th><th>Description</th></tr></thead><tbody><tr><td>Activator</td><td>true</td><td><p>The subject of the logic; the recipient for whom the logic is activated.</p><p>You can configure any of the following activators:</p></td></tr><tr><td>Variable</td><td>true</td><td><p>The measured conditions that can trigger the logic. A variable is one of three types: user motion, environmental, or user geotargeting.</p><p>You can configure any of the following variables:</p></td></tr><tr><td>Output</td><td>true</td><td>What is delivered when the logic is triggered.<br><br>An output names an action type and an attribute. Only the actions of that type inside the attribute are eligible, and one of them is delivered through an interaction channel output.</td></tr><tr><td>Operators</td><td>false</td><td>Logical operators (AND and OR) that define the flow of the logic and enable you to introduce multiple variables and rules of interdependence between variables and outputs.</td></tr></tbody></table>

To set up the logic described in the previous example (that plays a personalized greeting when a user enters a room), you can configure the components as follows:

* **Activator**: Profile > All
* **Variable**: User motion > User detected
* **Output**: Type *media*, and the attribute that groups your personalized audio greeting messages. One of the media actions inside that attribute is delivered.

### Setting up logic blueprints

Setting up a logic blueprint simply means configuring the different logic components to define the flow of the logic. You can set up a logic blueprint as follows:

#### Activators

<table><thead><tr><th width="129">Activator</th><th>Type</th><th>Required input (value) and format</th><th>Description</th></tr></thead><tbody><tr><td>Profile</td><td><ul><li>Self-centered</li><li>Average</li><li>Role model</li><li>Reserved</li><li>All</li></ul></td><td>No input required; select a profile type from the drop-down menu.</td><td>The logic is activated only for users having the selected type of psychological profile.</td></tr><tr><td>Entity</td><td></td><td>Entity ID of an VH</td><td>The logic is activated only for the specific Virtual Human (VH).</td></tr><tr><td>Safety</td><td>Heart rate<br><br><strong>Note</strong>: You must include this type in "condition" to set the values using operators.</td><td>A number between 50 and 200</td><td>The logic is activated based on the heart rates of end-users.<br><br><strong>Note</strong>: You can use this activator for solutions in the safety domain.</td></tr></tbody></table>

#### Variables

<table><thead><tr><th>Condition</th><th width="130">Type</th><th>Required input (value) and format</th><th>Description</th></tr></thead><tbody><tr><td>Environmental</td><td>Location</td><td>No input required; select the coordinates of the required location (which you previously declared as an interaction input) from the drop-down menu.</td><td>The logic is triggered when the defined location condition is met.<br><br>For example, you can set up the logic to be triggered when a user arrives at a location.</td></tr><tr><td></td><td>Speed</td><td>A number in km/h</td><td>The logic is triggered when the defined speed condition is met.<br><br>For example, you can set up the logic to be triggered when a user is travelling faster than the defined speed.</td></tr><tr><td></td><td>Time</td><td>Numbers in HHMMSS format</td><td>The logic is triggered when the defined time condition is met.<br><br>For example, you can set up the logic to be triggered at a specific time.</td></tr><tr><td></td><td>External signal</td><td>No input required; select the name of the required object (which you previously declared as an interaction input) from the drop-down menu.</td><td>The logic is triggered when the defined external signal condition is met.<br><br>For example, you can set up the logic to be triggered when when a traffic light turns red (the external signal).</td></tr><tr><td></td><td>Camera ID</td><td><p>No input required; select one of the following:</p><ul><li>The name of the required camera (which you previously declared as an interaction input) from the drop-down menu</li><li>The (current) camera in the user's device</li></ul></td><td>The logic is triggered when the defined camera ID condition is met.<br><br>For example, you can set up the logic to be triggered if a user is detected using facial recognition by a specific camera.</td></tr><tr><td></td><td>Crowd counting</td><td>A number</td><td>The logic is triggered when the defined crowd counting condition is met.<br><br>For example, you can set up the logic to be triggered if more than a specific number of people have gathered at a location.</td></tr><tr><td></td><td>Object</td><td><mark style="background-color:red;">No input required; select the name of the required object (which you previously declared as an interaction input) from the drop-down menu. - </mark><em><mark style="background-color:red;">validate</mark></em></td><td>The logic is triggered when the defined object condition is met.<br><br>For example, you can set up the logic to be triggered <mark style="background-color:red;">if a traffic light (object) turns red. - </mark><em><mark style="background-color:red;">validate</mark></em></td></tr><tr><td>User motion</td><td>User is detected</td><td>A binary value (True/False)</td><td>The logic is triggered when the user is detected.<br><br>For example, you can set up the logic to be triggered if facial recognition detects a user.</td></tr><tr><td>User geotargeting</td><td>Location</td><td><em><mark style="background-color:red;">test and validate</mark></em></td><td>The logic is triggered when a user's location is identified based on a location interaction input.<br><br>For example, you can set up the logic to be triggered if the user is present at a location.</td></tr><tr><td></td><td>QR</td><td><em><mark style="background-color:red;">test and validate</mark></em></td><td>The logic is triggered when a user's location is identified based on a QR code scan (interaction input).<br><br>For example, you can set up the logic to be triggered if the user scans a specific QR code (which is at a specific location).</td></tr><tr><td></td><td>Camera</td><td><em><mark style="background-color:red;">test and validate</mark></em></td><td>The logic is triggered when a user's location is identified through a camera (interaction input).<br><br>For example, you can set up the logic to be triggered if the user is detected by a specific camera (which is at a specific location) through facial recognition.</td></tr><tr><td></td><td>Beacon</td><td><em><mark style="background-color:red;">test and validate</mark></em></td><td>The logic is triggered when a user's location is identified by a beacon (interaction input).<br><br>For example, you can set up the logic to be triggered if the user's positioning beacon indicates that they are at a specific location.</td></tr><tr><td>Profile</td><td>Anomaly</td><td>A number in percentage</td><td>The logic is triggered if the user deviates from the goal of the task by more than the defined threshold.<br><br><strong>Note</strong>: You can configure this condition to set it up as a baseline for EDAA™, the underlying technology that powers Affective Computing (powered by Virtue).</td></tr></tbody></table>

#### Outputs

An output is defined by two choices: the **type** of action to deliver, and the **attribute** to draw it from.

| Output type      | What is delivered                                            |
| ---------------- | ------------------------------------------------------------ |
| Media            | One of the media actions inside the selected attribute       |
| Interaction      | One of the interaction actions inside the selected attribute |
| Triggered action | One of the triggered actions inside the selected attribute   |

Because a single [attribute](https://documentation.virtuedeep.tech/affective-computing-by-virtue/designing-solutions-powered-by-affective-computing/understanding-project-components/attributes.md) can hold actions of all three types, the same attribute can serve several outputs, each drawing the kind it asked for. An attribute holding no action of the requested type is not offered for that output.

Every output is delivered through an [interaction channel output](https://documentation.virtuedeep.tech/affective-computing-by-virtue/designing-solutions-powered-by-affective-computing/understanding-project-components/interaction-channels.md), which carries an identity so the receiving system can tell which output produced which response.

## Logic types

In Affective Computing (powered by Virtue), you can work with logics of the following types:

| Logic type       | Description                                                                 |
| ---------------- | --------------------------------------------------------------------------- |
| User calibration | Logics triggered only when the project is running in user calibration mode. |
| Action           | Logics that result in action delivery                                       |

## Logic anchoring

EDAA™, the underlying technology that powers Affective Computing (powered by Virtue) has the ability to generatively evolve and fine-tune your logics to generate personalized actions for end-users and deliver them in the most effective way. This, in turn, enables you to incorporate a high degree of personalization in your solutions.

However, you can also prevent generative evolution of your logics by anchoring them.

{% hint style="info" %}
You can anchor both logics and actions to ensure that they are used as-is;

* You can anchor any logic to prevent generation of new logics based on it.
* You can anchor any action to prevent the following:
  * Any changes to it.
  * Generation of additional actions based on it inside the respective parent attribute.
    {% endhint %}

The following table describes how your solution behaves when you anchor actions and logics in the following ways:

<table><thead><tr><th width="156">Logic</th><th width="143">Action</th><th>Behavior</th></tr></thead><tbody><tr><td>Anchored</td><td>Anchored</td><td>The solution will always use the logic exactly as configured and deliver an action from the same pool.<br><br>You can configure logic anchoring in this manner to have absolute control over the solution's behavior and performance.<br><br><strong>Note</strong>: This configuration is a good choice when initially designing your solution. Later, when you gain more expertise in using Affective Computing (powered by Virtue), you can remove the anchors as required.</td></tr><tr><td>Anchored</td><td>Non-anchored</td><td>The solution uses the logic exactly as configured but uses variations of the actions that are generated according to their attribution. This enables better efficiency of the logic with respect to the actions' purpose.<br><br>For example, if you enable generative evolution of the action of delivering a greeting message ("<em>Hi!</em>"), other similar statements ("<em>Good morning</em>", "<em>Hello there!</em>") relevant for the same conditions might be generated and delivered.<br><br><strong>Note</strong>: Generated actions are eligible for inclusion in the action pool only after they are validated.</td></tr><tr><td>Non-anchored</td><td>Anchored</td><td><p>Affective Computing (powered by Virtue) generatively changes the logic but doesn't create variations of anchored actions.<br><br>The solution might deliver the same actions under different conditions.</p><p>For example, if an anchored action that delivers a greeting message is configured for a non-anchored logic that is triggered upon user detection, the same actions might be used in a similar logic designed to greet users when they arrive at a specified location (such as a room in the experience environment).</p></td></tr><tr><td>Non-anchored</td><td>Non-anchored</td><td>The solution utilizes Affective Computing (powered by Virtue)'s generative capabilities entirely; it generates better iterations of the logic that deliver appropriate actions that yield better engagement with higher efficiency.</td></tr></tbody></table>

{% hint style="warning" %}
Anchoring reduces personalization, therefore we recommend anchoring logics only if your solution really requires it.
{% endhint %}

## Logics and projects

A logic used to belong to exactly one project. A logic can now apply to one or many projects, so a rule you want enforced across a portfolio is created once and attached to each project that needs it rather than duplicated.

A logic is scoped either by the projects attached to it or by a solution, never both. Clearing the project list removes the scoping rather than leaving the logic attached to nothing.

### Hierarchy

Logics have the following hierarchy, which determines how their parameterization is inherited over different levels:

Parent > Domain > Tenant > Project

## Creating and managing logics in projects

You can create and manage logics using the Portal, our no-code SaaS GUI platform, or through a low-code integration with our APIs.

### Working with logics using the Portal

{% content-ref url="/pages/20ZG33ZzYU7sXeI9MtFr" %}
[Creating logic blueprints](https://documentation.virtuedeep.tech/guides/using-the-portal/creating-logic-blueprints.md)
{% endcontent-ref %}

### Working with logics using APIs

***

### Related information

{% content-ref url="/pages/nHDJq3o3jRRisUuUTlsg" %}
[Logic blueprinting](https://documentation.virtuedeep.tech/affective-computing-by-virtue/about-our-framework/edaa-tm-features/logic-blueprinting.md)
{% endcontent-ref %}
