Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

editoast: harmonize comfort type #8525

Merged
merged 5 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package fr.sncf.osrd.railjson.schema.rollingstock;

public enum RJSComfortType {
AC,
public enum Comfort {
AIR_CONDITIONING,
HEATING,
STANDARD
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static final class RJSConditionalEffortCurve {
}

public static final class RJSEffortCurveConditions {
public RJSComfortType comfort = null;
public Comfort comfort = null;

@Json(name = "electrical_profile_level")
public String electricalProfileLevel = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.squareup.moshi.Json;
import fr.sncf.osrd.railjson.schema.common.Identified;
import fr.sncf.osrd.railjson.schema.rollingstock.RJSComfortType;
import fr.sncf.osrd.railjson.schema.rollingstock.Comfort;

public class RJSStandaloneTrainSchedule implements Identified {
/** The identifier of this train */
Expand Down Expand Up @@ -35,7 +35,7 @@ public class RJSStandaloneTrainSchedule implements Identified {
public String tag;

/** The type of comfort the train using */
public RJSComfortType comfort;
public Comfort comfort;

/** Ranges on the path where power restrictions are to be applied */
@Json(name = "power_restriction_ranges")
Expand All @@ -52,7 +52,7 @@ public RJSStandaloneTrainSchedule(
RJSAllowance[] allowances,
RJSTrainStop[] stops,
String tag,
RJSComfortType comfort,
Comfort comfort,
RJSTrainScheduleOptions options,
RJSPowerRestrictionRange[] powerRestrictionRanges) {
this.id = id;
Expand All @@ -73,7 +73,7 @@ public RJSStandaloneTrainSchedule(
RJSAllowance[] allowances,
RJSTrainStop[] stops,
String tag) {
this(id, rollingStock, initialSpeed, allowances, stops, tag, RJSComfortType.STANDARD, null, null);
this(id, rollingStock, initialSpeed, allowances, stops, tag, Comfort.STANDARD, null, null);
}

public RJSStandaloneTrainSchedule(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package fr.sncf.osrd.railjson.parser;

import fr.sncf.osrd.railjson.schema.rollingstock.RJSComfortType;
import fr.sncf.osrd.railjson.schema.rollingstock.RJSEffortCurves;
import fr.sncf.osrd.railjson.schema.rollingstock.RJSRollingResistance;
import fr.sncf.osrd.railjson.schema.rollingstock.RJSRollingStock;
Expand Down Expand Up @@ -130,15 +129,7 @@ private static RollingStock.EffortCurveConditions parseEffortCurveConditions(
RJSEffortCurves.RJSEffortCurveConditions rjsCond, String fieldKey) {
if (rjsCond == null) throw OSRDError.newMissingRollingStockFieldError(fieldKey);
return new RollingStock.EffortCurveConditions(
parseComfort(rjsCond.comfort), rjsCond.electricalProfileLevel, rjsCond.powerRestrictionCode);
}

/** Parse rjsComfort into a RollingStock comfort */
public static RollingStock.Comfort parseComfort(RJSComfortType rjsComfort) {
if (rjsComfort == null) return null;
if (rjsComfort == RJSComfortType.AC) return RollingStock.Comfort.AIR_CONDITIONING;
if (rjsComfort == RJSComfortType.HEATING) return RollingStock.Comfort.HEATING;
return RollingStock.Comfort.STANDARD;
rjsCond.comfort, rjsCond.electricalProfileLevel, rjsCond.powerRestrictionCode);
}

/** Parse RJSModeEffortCurve into a ModeEffortCurve */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package fr.sncf.osrd.railjson.parser;

import static fr.sncf.osrd.railjson.parser.RJSRollingStockParser.parseComfort;

import com.google.common.collect.ImmutableRangeMap;
import com.google.common.collect.Range;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
Expand Down Expand Up @@ -49,7 +47,7 @@ public static StandaloneTrainSchedule parse(
throw new OSRDError(ErrorType.InvalidScheduleInvalidInitialSpeed);

// Parse comfort
var comfort = parseComfort(rjsTrainSchedule.comfort);
var comfort = rjsTrainSchedule.comfort;

// Parse options
var options = new TrainScheduleOptions(rjsTrainSchedule.options);
Expand Down
7 changes: 1 addition & 6 deletions core/src/main/java/fr/sncf/osrd/train/RollingStock.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import fr.sncf.osrd.envelope_sim.electrification.Electrified;
import fr.sncf.osrd.envelope_sim.electrification.Neutral;
import fr.sncf.osrd.envelope_sim.electrification.NonElectrified;
import fr.sncf.osrd.railjson.schema.rollingstock.Comfort;
import fr.sncf.osrd.railjson.schema.rollingstock.RJSLoadingGaugeType;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -154,12 +155,6 @@ public boolean match(EffortCurveConditions other) {

public record InfraConditions(String mode, String electricalProfile, String powerRestriction) {}

public enum Comfort {
STANDARD,
HEATING,
AIR_CONDITIONING,
}

protected record CurveAndCondition(TractiveEffortPoint[] curve, InfraConditions cond) {}

public record CurvesAndConditions(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.google.common.collect.ImmutableRangeMap;
import com.google.common.collect.RangeMap;
import fr.sncf.osrd.envelope_sim.allowances.Allowance;
import fr.sncf.osrd.railjson.schema.rollingstock.Comfort;
import fr.sncf.osrd.utils.jacoco.ExcludeFromGeneratedCodeCoverage;
import java.util.List;
import java.util.Objects;
Expand All @@ -22,7 +23,7 @@ public class StandaloneTrainSchedule {

public final String tag;

public final RollingStock.Comfort comfort;
public final Comfort comfort;

public final RangeMap<Double, String> powerRestrictionMap;

Expand All @@ -36,7 +37,7 @@ public StandaloneTrainSchedule(
List<TrainStop> stops,
List<? extends Allowance> allowances,
String tag,
RollingStock.Comfort comfort,
Comfort comfort,
ImmutableRangeMap<Double, String> powerRestrictionMap,
TrainScheduleOptions options) {
this.rollingStock = rollingStock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import fr.sncf.osrd.api.api_v2.RangeValues
import fr.sncf.osrd.api.api_v2.TrackRange
import fr.sncf.osrd.conflicts.TravelledPath
import fr.sncf.osrd.envelope_sim.PhysicsRollingStock.GammaType
import fr.sncf.osrd.railjson.schema.rollingstock.Comfort
import fr.sncf.osrd.railjson.schema.rollingstock.RJSEffortCurves.RJSModeEffortCurve
import fr.sncf.osrd.railjson.schema.rollingstock.RJSRollingResistance
import fr.sncf.osrd.railjson.schema.schedule.RJSAllowanceDistribution
import fr.sncf.osrd.sim_infra.api.Path
import fr.sncf.osrd.train.RollingStock
import fr.sncf.osrd.train.RollingStock.Comfort
import fr.sncf.osrd.utils.json.UnitAdapterFactory
import fr.sncf.osrd.utils.units.Duration
import fr.sncf.osrd.utils.units.Length
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import fr.sncf.osrd.envelope_sim_infra.EnvelopeTrainPath
import fr.sncf.osrd.envelope_sim_infra.MRSP
import fr.sncf.osrd.graph.Pathfinding
import fr.sncf.osrd.graph.PathfindingEdgeLocationId
import fr.sncf.osrd.railjson.schema.rollingstock.Comfort
import fr.sncf.osrd.reporting.exceptions.ErrorType
import fr.sncf.osrd.reporting.exceptions.OSRDError
import fr.sncf.osrd.reporting.warnings.DiagnosticRecorderImpl
Expand Down Expand Up @@ -140,7 +141,7 @@ class STDCMEndpointV2(private val infraManager: InfraManager) : Take {
path: STDCMResult,
rollingStock: RollingStock,
speedLimitTag: String?,
comfort: RollingStock.Comfort,
comfort: Comfort,
): SimulationSuccess {
val reportTrain =
runScheduleMetadataExtractor(
Expand Down Expand Up @@ -180,7 +181,7 @@ class STDCMEndpointV2(private val infraManager: InfraManager) : Take {
infra: FullInfra,
path: STDCMResult,
rollingStock: RollingStock,
comfort: RollingStock.Comfort
comfort: Comfort
): RangeValues<ElectricalProfileValue> {
val envelopeSimPath = EnvelopeTrainPath.from(infra.rawInfra, path.trainPath, null)
val electrificationMap =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import fr.sncf.osrd.api.api_v2.conflicts.TrainRequirementsRequest
import fr.sncf.osrd.api.api_v2.standalone_sim.MarginValue
import fr.sncf.osrd.api.api_v2.standalone_sim.MarginValueAdapter
import fr.sncf.osrd.api.api_v2.standalone_sim.PhysicsRollingStockModel
import fr.sncf.osrd.railjson.schema.rollingstock.Comfort
import fr.sncf.osrd.railjson.schema.rollingstock.RJSLoadingGaugeType
import fr.sncf.osrd.railjson.schema.rollingstock.RJSRollingResistance
import fr.sncf.osrd.train.RollingStock.Comfort
import fr.sncf.osrd.utils.json.UnitAdapterFactory
import fr.sncf.osrd.utils.units.Duration
import fr.sncf.osrd.utils.units.TimeDelta
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import fr.sncf.osrd.envelope_sim_infra.MRSP
import fr.sncf.osrd.graph.Pathfinding
import fr.sncf.osrd.railjson.parser.RJSRollingStockParser
import fr.sncf.osrd.railjson.parser.RJSStandaloneTrainScheduleParser
import fr.sncf.osrd.railjson.schema.rollingstock.Comfort
import fr.sncf.osrd.reporting.exceptions.ErrorType
import fr.sncf.osrd.reporting.exceptions.OSRDError
import fr.sncf.osrd.reporting.warnings.DiagnosticRecorderImpl
Expand All @@ -22,7 +23,6 @@ import fr.sncf.osrd.stdcm.STDCMStep
import fr.sncf.osrd.stdcm.graph.findPath
import fr.sncf.osrd.stdcm.preprocessing.implementation.makeBlockAvailability
import fr.sncf.osrd.train.RollingStock
import fr.sncf.osrd.train.RollingStock.Comfort
import fr.sncf.osrd.train.StandaloneTrainSchedule
import fr.sncf.osrd.train.TrainStop
import org.takes.Request
Expand Down Expand Up @@ -52,7 +52,7 @@ class STDCMEndpoint(private val infraManager: InfraManager) : Take {
// TODO : change with get infra when the front is ready
val infra = infraManager.getInfra(request.infra, request.expectedVersion, recorder)
val rollingStock = RJSRollingStockParser.parse(request.rollingStock)
val comfort = RJSRollingStockParser.parseComfort(request.comfort)
val comfort = request.comfort
val steps = parseSteps(infra, request.steps)
val tag = request.speedLimitComposition
var standardAllowance: AllowanceValue? = null
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/kotlin/fr/sncf/osrd/api/stdcm/STDCMRequest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings
import fr.sncf.osrd.api.pathfinding.request.PathfindingWaypoint
import fr.sncf.osrd.railjson.schema.common.ID
import fr.sncf.osrd.railjson.schema.rollingstock.RJSComfortType
import fr.sncf.osrd.railjson.schema.rollingstock.Comfort
import fr.sncf.osrd.railjson.schema.rollingstock.RJSRollingResistance
import fr.sncf.osrd.railjson.schema.rollingstock.RJSRollingStock
import fr.sncf.osrd.railjson.schema.schedule.RJSAllowance
Expand Down Expand Up @@ -41,7 +41,7 @@ constructor(
maximumRunTime: Double = 12.0 * 3600.0
) {
/** Train comfort */
var comfort: RJSComfortType? = null
var comfort: Comfort? = null

/** Time step used in simulations (defaults to 2) */
@Json(name = "time_step") var timeStep = 2.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import fr.sncf.osrd.envelope_sim.pipelines.MaxSpeedEnvelope
import fr.sncf.osrd.envelope_sim_infra.EnvelopeTrainPath
import fr.sncf.osrd.envelope_sim_infra.MRSP
import fr.sncf.osrd.external_generated_inputs.ElectricalProfileMapping
import fr.sncf.osrd.railjson.schema.rollingstock.Comfort
import fr.sncf.osrd.railjson.schema.schedule.RJSAllowanceDistribution
import fr.sncf.osrd.sim_infra.api.*
import fr.sncf.osrd.sim_infra.impl.ChunkPath
Expand All @@ -51,7 +52,7 @@ fun runStandaloneSimulation(
routes: StaticIdxList<Route>,
electricalProfileMap: ElectricalProfileMapping?,
rollingStock: RollingStock,
comfort: RollingStock.Comfort,
comfort: Comfort,
constraintDistribution: RJSAllowanceDistribution,
speedLimitTag: String?,
powerRestrictions: DistanceRangeMap<String>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package fr.sncf.osrd.stdcm.graph

import fr.sncf.osrd.envelope_sim.EnvelopeSimContext
import fr.sncf.osrd.envelope_sim.EnvelopeSimPath
import fr.sncf.osrd.railjson.schema.rollingstock.Comfort
import fr.sncf.osrd.train.RollingStock
import fr.sncf.osrd.train.RollingStock.Comfort

/** Computes the rolling stock effort curves that will be used and creates a context */
fun build(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import fr.sncf.osrd.envelope_sim.allowances.LinearAllowance
import fr.sncf.osrd.envelope_sim.allowances.MarecoAllowance
import fr.sncf.osrd.envelope_sim.allowances.utils.AllowanceRange
import fr.sncf.osrd.envelope_sim.allowances.utils.AllowanceValue
import fr.sncf.osrd.railjson.schema.rollingstock.Comfort
import fr.sncf.osrd.reporting.exceptions.ErrorType
import fr.sncf.osrd.reporting.exceptions.OSRDError
import fr.sncf.osrd.standalone_sim.EnvelopeStopWrapper
import fr.sncf.osrd.stdcm.infra_exploration.withEnvelope
import fr.sncf.osrd.stdcm.preprocessing.interfaces.BlockAvailabilityInterface
import fr.sncf.osrd.train.RollingStock
import fr.sncf.osrd.train.RollingStock.Comfort
import fr.sncf.osrd.train.TrainStop
import fr.sncf.osrd.utils.units.Distance
import fr.sncf.osrd.utils.units.Length
Expand All @@ -24,8 +24,6 @@ import fr.sncf.osrd.utils.units.meters
import java.util.*
import kotlin.math.max

object STDCMStandardAllowance

private data class FixedTimePoint(
val time: Double,
val offset: Offset<TravelledPath>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import fr.sncf.osrd.envelope.Envelope
import fr.sncf.osrd.envelope_sim.allowances.utils.AllowanceValue
import fr.sncf.osrd.envelope_sim.allowances.utils.AllowanceValue.FixedTime
import fr.sncf.osrd.graph.Graph
import fr.sncf.osrd.railjson.schema.rollingstock.Comfort
import fr.sncf.osrd.stdcm.STDCMAStarHeuristic
import fr.sncf.osrd.stdcm.STDCMHeuristicBuilder
import fr.sncf.osrd.stdcm.STDCMStep
import fr.sncf.osrd.stdcm.preprocessing.interfaces.BlockAvailabilityInterface
import fr.sncf.osrd.train.RollingStock
import fr.sncf.osrd.train.RollingStock.Comfort
import fr.sncf.osrd.utils.units.meters
import java.lang.Double.isFinite
import java.lang.Double.isNaN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import fr.sncf.osrd.envelope_sim.allowances.utils.AllowanceValue
import fr.sncf.osrd.graph.Pathfinding
import fr.sncf.osrd.graph.PathfindingConstraint
import fr.sncf.osrd.graph.PathfindingEdgeLocationId
import fr.sncf.osrd.railjson.schema.rollingstock.Comfort
import fr.sncf.osrd.reporting.exceptions.ErrorType
import fr.sncf.osrd.reporting.exceptions.OSRDError
import fr.sncf.osrd.sim_infra.api.Block
Expand Down Expand Up @@ -45,7 +46,7 @@ val logger: Logger = LoggerFactory.getLogger("STDCM")
fun findPath(
fullInfra: FullInfra,
rollingStock: RollingStock,
comfort: RollingStock.Comfort?,
comfort: Comfort?,
startTime: Double,
steps: List<STDCMStep>,
blockAvailability: BlockAvailabilityInterface,
Expand Down Expand Up @@ -76,7 +77,7 @@ fun findPath(
class STDCMPathfinding(
private val fullInfra: FullInfra,
private val rollingStock: RollingStock,
private val comfort: RollingStock.Comfort?,
private val comfort: Comfort?,
private val startTime: Double,
private val steps: List<STDCMStep>,
private val blockAvailability: BlockAvailabilityInterface,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import fr.sncf.osrd.graph.Pathfinding.EdgeLocation
import fr.sncf.osrd.graph.Pathfinding.EdgeRange
import fr.sncf.osrd.graph.PathfindingEdgeLocationId
import fr.sncf.osrd.graph.PathfindingEdgeRangeId
import fr.sncf.osrd.railjson.schema.rollingstock.Comfort
import fr.sncf.osrd.sim_infra.api.*
import fr.sncf.osrd.stdcm.STDCMResult
import fr.sncf.osrd.stdcm.preprocessing.interfaces.BlockAvailabilityInterface
import fr.sncf.osrd.train.RollingStock
import fr.sncf.osrd.train.RollingStock.Comfort
import fr.sncf.osrd.train.TrainStop
import fr.sncf.osrd.utils.units.meters
import io.opentelemetry.api.trace.SpanKind
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import fr.sncf.osrd.envelope_sim.pipelines.MaxEffortEnvelope
import fr.sncf.osrd.envelope_sim.pipelines.MaxSpeedEnvelope
import fr.sncf.osrd.envelope_sim_infra.EnvelopeTrainPath
import fr.sncf.osrd.envelope_sim_infra.MRSP
import fr.sncf.osrd.railjson.schema.rollingstock.Comfort
import fr.sncf.osrd.reporting.exceptions.OSRDError
import fr.sncf.osrd.sim_infra.api.Block
import fr.sncf.osrd.sim_infra.api.BlockId
Expand All @@ -24,7 +25,6 @@ import fr.sncf.osrd.sim_infra.api.RawSignalingInfra
import fr.sncf.osrd.stdcm.BacktrackingSelfTypeHolder
import fr.sncf.osrd.stdcm.infra_exploration.InfraExplorer
import fr.sncf.osrd.train.RollingStock
import fr.sncf.osrd.train.RollingStock.Comfort
import fr.sncf.osrd.utils.SelfTypeHolder
import fr.sncf.osrd.utils.units.Distance
import fr.sncf.osrd.utils.units.Offset
Expand Down
Loading
Loading