/
Castor.java
69 lines (58 loc) · 2.59 KB
/
Castor.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
* Copyright (c) 2020, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package com.powsybl.openrao.searchtreerao.castor.algorithm;
import com.powsybl.openrao.data.raoresultapi.RaoResult;
import com.powsybl.openrao.raoapi.RaoInput;
import com.powsybl.openrao.raoapi.RaoProvider;
import com.powsybl.openrao.raoapi.parameters.*;
import com.powsybl.openrao.searchtreerao.commons.*;
import com.powsybl.openrao.searchtreerao.result.impl.*;
import com.google.auto.service.AutoService;
import java.time.Instant;
import java.util.concurrent.CompletableFuture;
import static com.powsybl.openrao.commons.logs.OpenRaoLoggerProvider.*;
/**
* @author Joris Mancini {@literal <joris.mancini at rte-france.com>}
* @author Philippe Edwards {@literal <philippe.edwards at rte-france.com>}
* @author Peter Mitri {@literal <peter.mitri at rte-france.com>}
* @author Godelaine De-Montmorillon {@literal <godelaine.demontmorillon at rte-france.com>}
* @author Baptiste Seguinot {@literal <baptiste.seguinot at rte-france.com>}
*/
@AutoService(RaoProvider.class)
public class Castor implements RaoProvider {
private static final String SEARCH_TREE_RAO = "SearchTreeRao";
// Do not store any big object in this class as it is a static RaoProvider
// Objects stored in memory will not be released at the end of the RAO run
@Override
public String getName() {
return SEARCH_TREE_RAO;
}
@Override
public String getVersion() {
return "1.0.0";
}
@Override
public CompletableFuture<RaoResult> run(RaoInput raoInput, RaoParameters parameters) {
return run(raoInput, parameters, null);
}
@Override
public CompletableFuture<RaoResult> run(RaoInput raoInput, RaoParameters parameters, Instant targetEndInstant) {
RaoUtil.initData(raoInput, parameters);
// optimization is made on one given state only
if (raoInput.getOptimizedState() != null) {
try {
return new CastorOneStateOnly(raoInput, parameters).run();
} catch (Exception e) {
BUSINESS_LOGS.error("Optimizing state \"{}\" failed: ", raoInput.getOptimizedState().getId(), e);
return CompletableFuture.completedFuture(new FailedRaoResultImpl());
}
} else {
// else, optimization is made on all the states
return new CastorFullOptimization(raoInput, parameters, targetEndInstant).run();
}
}
}