Save user-defined scenarios from AnyLogic.
This is an internal library which mostly exists to bundle dependencies.
Download the latest release and add it to your AnyLogic project dependencies.
Set environment variables in a startup script for AnyLogic.
Windows:
set UPLUX_ACCESS_KEY=xxx
set UPLUX_SECRET_KEY=xxx
Anylogic.exeLinux:
export UPLUX_ACCESS_KEY=xxx
export UPLUX_SECRET_KEY=xxx
export GTK_THEME=adwaita:light
./anylogicUplux uses the repository pattern to save and load scenarios.
Intialize repository class:
import energy.lux.uplux.UserScenarioRepository;
import java.util.UUID;
var repository = UserScenarioRepository.builder()
// p_userIdToken is a model input parameter which is injected by the Lux.energy website
.userIdToken(p_userIdToken)
.modelName("Mordor")
.build();Save scenario:
import com.fasterxml.jackson.databind.ObjectMapper;
ObjectMapper jacksonMapper;
repository.saveUserScenario(
"Use electric arc furnaces in the forges of Mordor",
jacksonMapper.writeValueAsBytes(userAnyLogicScenario)
)List saved scenarios:
var scenarioList = repository.listScenarios();
for (var scenario : scenarioList) {
System.out.println(scenario.getName());
}Load scenario content:
var jsonStream = repository.fetchUserScenarioContent(scenarioList.get(2).getId());
var deserializedScenario = jackson.readValue(jsonStream, MyAnyLogicScenario.class);Delete scenario:
repository.deleteUserScenario(scenarioList.get(2).getId());Uplux currently does not verify that the user is authorized to access requested objects.
It is up to the library consumer to ensure access control and protect against user ID spoofing and ID guessing vulnerability.