Skip to content

Commit

Permalink
Modify quotes around identifiers (#52)
Browse files Browse the repository at this point in the history
Signed-off-by: parvy <pierre.arvy@artelys.com>
  • Loading branch information
p-arvy authored Jan 15, 2024
1 parent 9545cd6 commit 23d92d2
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
public final class AmplIOUtils {

private static final String QUOTE = "'";
private static final String QUOTE = "\"";

public static String addQuotes(String str) {
return QUOTE + str + QUOTE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.powsybl.commons.util.StringToIntMapper;
import com.powsybl.iidm.network.Network;
import com.powsybl.openreac.exceptions.InvalidParametersException;
import com.powsybl.openreac.parameters.AmplIOUtils;
import org.jgrapht.alg.util.Pair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -94,7 +95,7 @@ public void write(BufferedWriter writer, StringToIntMapper<AmplSubset> stringToI

if (!Double.isNaN(limits.getFirst()) || !Double.isNaN(limits.getSecond())) {
int amplId = stringToIntMapper.getInt(AmplSubset.VOLTAGE_LEVEL, voltageLevelId);
String[] tokens = {Integer.toString(amplId), Double.toString(limits.getFirst()), Double.toString(limits.getSecond()), "\"" + voltageLevelId + "\""};
String[] tokens = {Integer.toString(amplId), Double.toString(limits.getFirst()), Double.toString(limits.getSecond()), AmplIOUtils.addQuotes(voltageLevelId)};
writer.write(String.join(" ", tokens));
writer.newLine();
}
Expand Down
11 changes: 6 additions & 5 deletions open-reac/src/main/resources/openreac/reactiveopf.run
Original file line number Diff line number Diff line change
Expand Up @@ -1112,8 +1112,9 @@ include reactiveopfoutput.run;
let fileOut := "debug_bus.csv";
printf{LOG_DEBUG} "#bus_id;Vnom;V;Vlb;Vub;Vmin_mod;Vmax_mod;Vmin_OK;Vmax_OK;Vmin_ori;Vmax_ori;sQ1;sQ2;\n" > (fileOut);
for {n in BUSCC}
printf{LOG_DEBUG} "%Q;%i;%.4f;%.4f;%.4f;%.4f;%.4f;%s;%s;%.4f;%.4f;%.2f;%.2f;\n",
bus_id[1,n],substation_Vnomi[1,bus_substation[1,n]],
printf{LOG_DEBUG} "%s;%i;%.4f;%.4f;%.4f;%.4f;%.4f;%s;%s;%.4f;%.4f;%.2f;%.2f;\n",
'"' & bus_id[1,n] & '"',
substation_Vnomi[1,bus_substation[1,n]],
V[n],V[n].lb,V[n].ub,
voltage_lower_bound[1,bus_substation[1,n]],
voltage_upper_bound[1,bus_substation[1,n]],
Expand All @@ -1129,16 +1130,16 @@ close (fileOut);
let fileOut := "reactiveopf_results_generators_Pnull.csv";
printf{LOG_DEBUG} "#variant;num;bus;vRegul;V(pu);targetP(MW);targetQ(Mvar);P(MW);Q(MW);id;bus_id;\n" > (fileOut);
for {(g,n) in UNITCC diff UNITON}
printf{LOG_DEBUG} "%i;%i;%i;%Q;%.3f;%.3f;%.3f;%.3f;%.3f;%Q;%Q;\n",
printf{LOG_DEBUG} "%i;%i;%i;%Q;%.3f;%.3f;%.3f;%.3f;%.3f;%s;%s;\n",
1,g,n,
unit_vregul[1,g,n],
V[n],
unit_Pc[1,g,n],
unit_Qc[1,g,n],
unit_P0[1,g,n],
unit_Q0[1,g,n],
unit_id[1,g,n],
bus_id[1,n]
'"' & unit_id[1,g,n] & '"',
'"' & bus_id[1,n] & '"'
> (fileOut);
close (fileOut);

Expand Down
6 changes: 3 additions & 3 deletions open-reac/src/main/resources/openreac/reactiveopfoutput.run
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,12 @@ then {
let fileOut := "reactiveopf_results_reactive_slacks.csv";
printf "#variant;bus;slack_condensator(Mvar);slack_self(Mvar);id;substation;\n" > (fileOut);
printf{n in BUSCC_SLACK: slack1_balance_Q[n]>Pnull or slack2_balance_Q[n]>Pnull}
"%i;%i;%.2f;%.2f;%Q;%Q;\n",
"%i;%i;%.2f;%.2f;%s;%s;\n",
1,n,
if slack1_balance_Q[n]>Pnull then slack1_balance_Q[n] else 0,
if slack2_balance_Q[n]>Pnull then slack2_balance_Q[n] else 0,
bus_id[1,n],
substation_id[1,bus_substation[1,n]]
'"' & bus_id[1,n] & '"',
'"' & substation_id[1,bus_substation[1,n]] & '"'
> (fileOut);
close (fileOut);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#num id
1 'VL1_0'
1 "VL1_0"

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#num id
1 'B1-G'
1 "B1-G"

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#num id
1 'B18-SH'
1 "B18-SH"

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#num id
64 'T4-18-1'
64 "T4-18-1"

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
col1;col2;col3;col4;col5;col6;
'a1';'b1';5.3;6.9;'slack1';'voltageLevel1';
'a2';'b2';1.2;-99999;'slack2';'voltageLevel2';
'a1';'b1';5.3;6.9;"slack1";"voltageLevel1";
'a2';'b2';1.2;-99999;"slack2";"voltageLevel2";

0 comments on commit 23d92d2

Please sign in to comment.