Skip to content

Commit ce8dead

Browse files
Merge pull request #714 from cambridge-cares/711-modssimpleagent-add-mcdm-only-functionality
711 modssimpleagent add mcdm only functionality
2 parents 45ee00b + ae79d23 commit ce8dead

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1181
-733
lines changed

Agents/MoDSSimpleAgent/.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
*log4j2.xml
2-
*AMIII*
2+
*AMIII*
3+
!.vscode
4+
savedsurrogates/*
5+
!savedsurrogates/example-surrogate/
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "java",
9+
"name": "Debug",
10+
"request": "attach",
11+
"hostName": "localhost",
12+
"port": "6005",
13+
"preLaunchTask": "compose-deploy",
14+
"projectName": "${workspaceFolderBasename}"
15+
},
16+
{
17+
"type": "java",
18+
"name": "Build and Debug",
19+
"request": "attach",
20+
"hostName": "localhost",
21+
"port": "6005",
22+
"preLaunchTask": "compose-build-deploy",
23+
"projectName": "${workspaceFolderBasename}"
24+
},
25+
{
26+
"type": "java",
27+
"name": "Reattach and Debug",
28+
"request": "attach",
29+
"hostName": "localhost",
30+
"port": "6005",
31+
"projectName": "${workspaceFolderBasename}"
32+
}
33+
]
34+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
// See https://go.microsoft.com/fwlink/?LinkId=733558
3+
// for the documentation about the tasks.json format
4+
"version": "2.0.0",
5+
"tasks": [
6+
{
7+
"type": "shell",
8+
"label": "compose-build",
9+
"command": "docker",
10+
"args": [
11+
"compose",
12+
"build"
13+
],
14+
"group": {
15+
"kind": "build",
16+
"isDefault": true
17+
}
18+
},
19+
{
20+
"type": "shell",
21+
"label": "compose-deploy-internal",
22+
"command": "docker",
23+
"args": [
24+
"compose",
25+
"-f",
26+
"docker-compose.yml",
27+
"-f",
28+
"docker-compose.debug.yml",
29+
"up",
30+
"-d"
31+
]
32+
},
33+
{
34+
"type": "shell",
35+
"label": "compose-deploy",
36+
"command": "sleep 1",
37+
"dependsOn": [
38+
"compose-deploy-internal"
39+
],
40+
"windows": {
41+
"options": {
42+
"shell": {
43+
"executable": "powershell"
44+
}
45+
}
46+
}
47+
},
48+
{
49+
"type": "shell",
50+
"label": "compose-build-deploy",
51+
"dependsOn": [
52+
"compose-build",
53+
"compose-deploy-internal"
54+
],
55+
"dependsOrder": "sequence"
56+
}
57+
]
58+
}

Agents/MoDSSimpleAgent/Dockerfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# First stage: build war file
22
#==================================================================================================
3-
FROM maven:3.6-openjdk-11-slim as builder
3+
FROM maven:3.6.3-openjdk-17-slim AS builder
44

55
# Copy all files into root's home, including the source, pom file, ./m2 directory and credentials
66
ADD . /root
@@ -26,7 +26,11 @@ ARG MODS_SAVE_DIR="/usr/local/mods-simple-agent/savedsurrogates"
2626
ARG USER="user"
2727
RUN useradd -s /bin/bash ${USER}
2828

29-
RUN apt update && apt install openjdk-11-jre mpich rsync -y && \
29+
RUN mkdir -p /etc/apt/keyrings && \
30+
wget -O - https://packages.adoptium.net/artifactory/api/gpg/key/public | tee /etc/apt/keyrings/adoptium.asc && \
31+
echo "deb [signed-by=/etc/apt/keyrings/adoptium.asc] https://packages.adoptium.net/artifactory/deb $(awk -F= '/^VERSION_CODENAME/{print$2}' /etc/os-release) main" | tee /etc/apt/sources.list.d/adoptium.list
32+
33+
RUN apt update && apt install temurin-17-jdk mpich rsync -y && \
3034
mkdir -p "${MODS_BIN_DIR}" && \
3135
mkdir -p "${MODS_SAVE_DIR}" && \
3236
chown ${USER}:${USER} "${MODS_BIN_DIR}" && \

Agents/MoDSSimpleAgent/README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# MoDS Simple Agent
2+
This agent is able to access a limited amount of the functionality of [the Model Development Suite (MoDS)](https://cmclinnovations.com/solutions/products/mods/).
3+
4+
## Deployment
5+
This agent is currently deployed at `https://kg.cmclinnovations.com/mods-agent` however if you require local deployment you can follow the following instructions.
6+
7+
Login to [TWA repo](https://github.com/cambridge-cares/TheWorldAvatar) using the following command using a token with read (and write if developing) access.
8+
```bash
9+
docker login ghcr.io/cambridge-cares
10+
```
11+
To deploy the MoDS Simple Agent a `.lic` licence file is required to be placed in the [`secrets`](./secrets/) directory.
12+
Running the following command will spin up the MoDS Simple Agent at port `58085`.
13+
```bash
14+
docker compose up -d
15+
```
16+
17+
## Usage
18+
Example input files can be found in the [`examples`](./examples) directory.
19+
To submit a job via curl or a web browser use https://kg.cmclinnovations.com/mods-agent/request (remote on KG server) or http://localhost:58085/request (local), with a "`query`" parameter with a value (URL-encoded if working through a browser) similar to these input files.
20+
For example click [here](https://kg.cmclinnovations.com/mods-agent/request?query=%7B%22SimulationType%22%3A%22MOOonly%22%2C%22Algorithms%22%3A%5B%7B%22name%22%3A%22algorithm1%22%2C%22type%22%3A%22GenSurrogateAlg%22%2C%22surrogateToLoad%22%3A%22example-surrogate%22%7D%2C%7B%22name%22%3A%22algorithm2%22%2C%22type%22%3A%22MOO%22%2C%22maxNumberOfResults%22%3A10%2C%22variables%22%3A%5B%7B%22name%22%3A%22var1%22%2C%22type%22%3A%22input%22%7D%2C%7B%22name%22%3A%22var2%22%2C%22type%22%3A%22input%22%7D%2C%7B%22name%22%3A%22var3%22%2C%22type%22%3A%22input%22%7D%2C%7B%22name%22%3A%22var4%22%2C%22type%22%3A%22output%22%2C%22objective%22%3A%22Maximise%22%2C%22minimum%22%3A0.5%2C%22weight%22%3A0.5%7D%2C%7B%22name%22%3A%22var5%22%2C%22type%22%3A%22output%22%2C%22objective%22%3A%22Minimise%22%2C%22maximum%22%3A1.5%2C%22weight%22%3A0.1%7D%2C%7B%22name%22%3A%22var6%22%2C%22type%22%3A%22output%22%2C%22objective%22%3A%22Maximise%22%2C%22minimum%22%3A2.5%2C%22weight%22%3A0.7%7D%5D%7D%5D%7D) to run a the job specified in the [multi-objective optimisation with pregenerated surrogate example](./examples/MOOonly.json).
21+
22+
Some `SimulationType`s will be returned the results of the simulation immediately in a JSON object.
23+
- Multi-Criteria Decision Making (`MCDM`)
24+
- Sensitivity Analysis (`Sensitivity`)
25+
26+
Others will return only return a the "jobID" and the "SimulationType" in a JSON object and run asynchronously.
27+
- High-Dimensional Model Representation Surrogate Generation (`HDMR`)
28+
- Surrogate Generation and Multi-Objective Optimisation (`MOO`)
29+
- Multi-Objective Optimisation with a pregenerated saved surrogate (`MOOonly`)
30+
- Evaluation of a pregenerated saved surrogate (`Evaluate`)
31+
The JSON object returned by this query (URL-encoded if working through a browser) can then be passed as the "`query`" parameter to this URL https://kg.cmclinnovations.com/mods-agent/output/request (remote on KG server) or http://localhost:58085/output/request (local) to retrieve the results when the simulation is complete.
32+
33+
The MoDS Simple Agent supports the loading and saving of surrogates generated.
34+
In the examples an "`example-surrogate`" is loaded using `"surrogateToLoad": "example-surrogate"`.
35+
This field can be replace with the `jobID` of a previous job where `"saveSurrogate": true`.
36+
37+
## Development
38+
Add the following files to the [`credentials`](./credentials/) directory.
39+
- `cmcl_repo_username.txt` username for nexus on bradman repo
40+
- `cmcl_repo_password.txt` password for nexus on bradman repo
41+
- `wa_repo_username.txt` username for into [TWA repo](https://github.com/cambridge-cares/TheWorldAvatar)
42+
- `wa_repo_password.txt` password (or preferably token) for [TWA repo](https://github.com/cambridge-cares/TheWorldAvatar)

Agents/MoDSSimpleAgent/docker-compose.debug.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ version: '3.4'
33
services:
44
modssimpleagent:
55
environment:
6-
JAVA_OPTS: -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005,quiet=y
6+
- "JAVA_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005"
77
ports:
88
- 6005:5005

Agents/MoDSSimpleAgent/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: "3.8"
22

33
services:
44
modssimpleagent:
5-
image: docker.cmclinnovations.com/modssimpleagent:0.3.1
5+
image: ghcr.io/cambridge-cares/modssimpleagent:0.4.0
66
build: .
77
container_name: modssimpleagent
88
environment:

Agents/MoDSSimpleAgent/examples/Evaluate.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
"name": "algorithm1",
66
"type": "GenSurrogateAlg",
7-
"surrogateToLoad": "mods-sim-8700472979756370358"
7+
"surrogateToLoad": "example-surrogate"
88
},
99
{
1010
"name": "algorithm2",
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
{
2+
"SimulationType": "MCDM",
3+
"Algorithms": [
4+
{
5+
"name": "algorithm1",
6+
"type": "MCDM",
7+
"maxNumberOfResults": 10,
8+
"variables": [
9+
{
10+
"name": "var1",
11+
"type": "input"
12+
},
13+
{
14+
"name": "var2",
15+
"type": "input"
16+
},
17+
{
18+
"name": "var3",
19+
"type": "input"
20+
},
21+
{
22+
"name": "var4",
23+
"type": "output",
24+
"objective": "Maximise",
25+
"minimum": 0.2,
26+
"weight": 0.5
27+
},
28+
{
29+
"name": "var5",
30+
"type": "output",
31+
"objective": "Minimise",
32+
"maximum": 2.0,
33+
"weight": 0.1
34+
},
35+
{
36+
"name": "var6",
37+
"type": "output",
38+
"objective": "Maximise",
39+
"minimum": 2.0,
40+
"weight": 0.7
41+
}
42+
]
43+
}
44+
],
45+
"Inputs": [
46+
{
47+
"name": "var1",
48+
"values": [
49+
"0.1",
50+
"0.3",
51+
"0.6",
52+
"0.1",
53+
"0.2"
54+
]
55+
},
56+
{
57+
"name": "var2",
58+
"values": [
59+
"0.4",
60+
"0.9",
61+
"0.0",
62+
"0.1",
63+
"0.8"
64+
]
65+
},
66+
{
67+
"name": "var3",
68+
"values": [
69+
"0.5",
70+
"0.1",
71+
"0.2",
72+
"0.3",
73+
"0.5"
74+
]
75+
},
76+
{
77+
"name": "var4",
78+
"values": [
79+
"0.1",
80+
"0.9",
81+
"0.1",
82+
"0.7",
83+
"0.1"
84+
]
85+
},
86+
{
87+
"name": "var5",
88+
"values": [
89+
"1.2",
90+
"2.0",
91+
"1.0",
92+
"1.6",
93+
"1.7"
94+
]
95+
},
96+
{
97+
"name": "var6",
98+
"values": [
99+
"2.5",
100+
"3.0",
101+
"1.2",
102+
"2.1",
103+
"4.0"
104+
]
105+
}
106+
]
107+
}

Agents/MoDSSimpleAgent/examples/MOOonly.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{
55
"name": "algorithm1",
66
"type": "GenSurrogateAlg",
7-
"surrogateToLoad": "mods-sim-8700472979756370358"
7+
"surrogateToLoad": "example-surrogate"
88
},
99
{
1010
"name": "algorithm2",

0 commit comments

Comments
 (0)