# Resource Assignment

### Algorithms

Algorithms are encapsulated within **docker** container. \
They can be created seperately in an arbitrary programming language. \
To include them in Rembrandt they need to be **registered** to the platform in the Algorithms tab by providing:

1. The algorithm name.
2. All incoming resource types.
3. The outcoming result resource type.
4. The Docker container location.

Registered algorithms can be used later to create recipes. The Docker image is later startet during recipe execution and passed a unique folder path where all input resources are stored in text files. For this reason it is important to include a function in the algorithm which processes the passed path and reads the optimization inputs. Additionally, the optimized output resource needs to be written to the same folder to be registered by Rembrandt.

Algorithms can not be **modified** to ensure that all recipes maintain their functionality, specifically in regards to ingoing and outgoing resource types. For the same reason an algorithm can only be **deleted** if it is not included in a recipe.<br>

### Transformers

Transformers are used to modify the list of resource instances. The modification can either be that each instance is altered (*map*), *filtering* for e.g. certain attribute values, or *reducing* the set to a new object. When **creating** the transformer multiple inputs are required:

1. A name for the Transformer.
2. The resource type the transformer is operating at.
3. The transformer function (*map*, *filter* or *reduce*)
4. the javascript source code as function body.

The provided source code is wrapped into the selected function type and executed during recipe execution. That is why it is important to not contain syntax error, hence we recommend testing the code before using the transformator.

By using `instance.attribute.[attributeName]`  access (read or write) to the specific attribute is possible.

The source code for a transformer to filter for all persons that are older than 18 years based on their year of birth could look like this:

```javascript
var date = new Date();
var currentYear = date.getFullYear();
var currentAge = instance.attributes.yearOfBirth - currentYear;
instance.attributes.age = currentAge;
return (instance.attributes.age > 18);
```

The transformer overview displays all existing transformers while clicking on one leadts to the detail view of the selected transformer. It is possible to **modify** the source code by clicking the corresponding button in the detail view. Likewise transformers can be **deleted**.&#x20;

### Recipes

Rembrandt offers a recipe **creation** view, where you can drag and drop ingredients to create a recipe.\
All known resource types, transformers and algorithms are displayed on the left and clicking on one of them creates the building block in the recipe area in the middle.\
Connecting blocks can be done by dragging one close to the others input or output ports, but will only work, if the respective types fit. For example the resource type *Car* will not connect to a port that expects the *Driver* resource type.

![](/files/-LmenkGsFJCNxxmQFIfr)

Recipes can be inspected in their detail page to see which ingredients are included. Furthermore they can be **deleted** and it is possible to manually start the recipe **execution** there.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://rembrandt.gitbook.io/docs/user-guide-1/resource-assignment.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
