Skip to content

Commit

Permalink
Coverage of all classes to be used in initial stage of demo.
Browse files Browse the repository at this point in the history
  • Loading branch information
vjoel committed Sep 6, 2012
1 parent 6548016 commit 5aa5965
Show file tree
Hide file tree
Showing 10 changed files with 1,494 additions and 33 deletions.
54 changes: 53 additions & 1 deletion src/main/avro/ModelElements.avdl
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ protocol ModelElements {
string name;
string type;

int laneCount;
double laneCount;
double length;
int laneOffset = 0;

NodeRef begin;
NodeRef end;
Expand Down Expand Up @@ -96,4 +97,55 @@ protocol ModelElements {
/** map key is linkId */
map<array<double>> metersPerSecond = {};
}

/** Fundamental diagram on one link at one time */
record FD {
// ### TODO units?
double freeFlowSpeed;
double freeFlowSpeedStdev;
double congestionWaveSpeed;
double congestionWaveSpeedStdev;
double capacity;
double capacityStdev;
double jamDensity;
double capacityDrop;
}

/** Fundamental diagrams on each link as time series */
record FDProfile {
double dt = 300.0;
double startTime = 0.0;

/** map key is linkId, array is time series, as per dt and startTime. */
map<array<FD>> fd = {};
}

/** Demands on each link as time series */
record DemandProfile {
double dt = 300.0;
double startTime = 0.0;
// ### TODO knob etc

/** may not be null */
LinkRef origin;

/** may be null */
LinkRef destination;

/** map key is linkId, array is time series, as per dt and startTime. */
map<array<double>> demand = {};
// ### TODO vehicle type dimension
}

// ### TODO Controllers

record Scenario {
string id;
string name;

Network network;
DensityProfile initialDensityProfile;
FDProfile fdProfile;
DemandProfile demandProfile;
}
}
319 changes: 319 additions & 0 deletions src/main/java/edu/berkeley/path/ModelElements/DemandProfile.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,319 @@
/**
* Autogenerated by Avro
*
* DO NOT EDIT DIRECTLY
*/
package edu.berkeley.path.ModelElements;
@SuppressWarnings("all")
/** Demands on each link as time series */
public class DemandProfile extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"DemandProfile\",\"namespace\":\"edu.berkeley.path.ModelElements\",\"doc\":\"Demands on each link as time series\",\"fields\":[{\"name\":\"dt\",\"type\":\"double\",\"default\":300.0},{\"name\":\"startTime\",\"type\":\"double\",\"default\":0.0},{\"name\":\"origin\",\"type\":{\"type\":\"record\",\"name\":\"LinkRef\",\"fields\":[{\"name\":\"linkId\",\"type\":\"string\"}]},\"doc\":\"may not be null\"},{\"name\":\"destination\",\"type\":\"LinkRef\",\"doc\":\"may be null\"},{\"name\":\"demand\",\"type\":{\"type\":\"map\",\"values\":{\"type\":\"array\",\"items\":\"double\"}},\"doc\":\"map key is linkId, array is time series, as per dt and startTime.\",\"default\":{}}]}");
@Deprecated public double dt;
@Deprecated public double startTime;
/** may not be null */
@Deprecated public edu.berkeley.path.ModelElements.LinkRef origin;
/** may be null */
@Deprecated public edu.berkeley.path.ModelElements.LinkRef destination;
/** map key is linkId, array is time series, as per dt and startTime. */
@Deprecated public java.util.Map<java.lang.CharSequence,java.util.List<java.lang.Double>> demand;
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
// Used by DatumWriter. Applications should not call.
public java.lang.Object get(int field$) {
switch (field$) {
case 0: return dt;
case 1: return startTime;
case 2: return origin;
case 3: return destination;
case 4: return demand;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
// Used by DatumReader. Applications should not call.
@SuppressWarnings(value="unchecked")
public void put(int field$, java.lang.Object value$) {
switch (field$) {
case 0: dt = (java.lang.Double)value$; break;
case 1: startTime = (java.lang.Double)value$; break;
case 2: origin = (edu.berkeley.path.ModelElements.LinkRef)value$; break;
case 3: destination = (edu.berkeley.path.ModelElements.LinkRef)value$; break;
case 4: demand = (java.util.Map<java.lang.CharSequence,java.util.List<java.lang.Double>>)value$; break;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}

/**
* Gets the value of the 'dt' field.
*/
public java.lang.Double getDt() {
return dt;
}

/**
* Sets the value of the 'dt' field.
* @param value the value to set.
*/
public void setDt(java.lang.Double value) {
this.dt = value;
}

/**
* Gets the value of the 'startTime' field.
*/
public java.lang.Double getStartTime() {
return startTime;
}

/**
* Sets the value of the 'startTime' field.
* @param value the value to set.
*/
public void setStartTime(java.lang.Double value) {
this.startTime = value;
}

/**
* Gets the value of the 'origin' field.
* may not be null */
public edu.berkeley.path.ModelElements.LinkRef getOrigin() {
return origin;
}

/**
* Sets the value of the 'origin' field.
* may not be null * @param value the value to set.
*/
public void setOrigin(edu.berkeley.path.ModelElements.LinkRef value) {
this.origin = value;
}

/**
* Gets the value of the 'destination' field.
* may be null */
public edu.berkeley.path.ModelElements.LinkRef getDestination() {
return destination;
}

/**
* Sets the value of the 'destination' field.
* may be null * @param value the value to set.
*/
public void setDestination(edu.berkeley.path.ModelElements.LinkRef value) {
this.destination = value;
}

/**
* Gets the value of the 'demand' field.
* map key is linkId, array is time series, as per dt and startTime. */
public java.util.Map<java.lang.CharSequence,java.util.List<java.lang.Double>> getDemand() {
return demand;
}

/**
* Sets the value of the 'demand' field.
* map key is linkId, array is time series, as per dt and startTime. * @param value the value to set.
*/
public void setDemand(java.util.Map<java.lang.CharSequence,java.util.List<java.lang.Double>> value) {
this.demand = value;
}

/** Creates a new DemandProfile RecordBuilder */
public static edu.berkeley.path.ModelElements.DemandProfile.Builder newBuilder() {
return new edu.berkeley.path.ModelElements.DemandProfile.Builder();
}

/** Creates a new DemandProfile RecordBuilder by copying an existing Builder */
public static edu.berkeley.path.ModelElements.DemandProfile.Builder newBuilder(edu.berkeley.path.ModelElements.DemandProfile.Builder other) {
return new edu.berkeley.path.ModelElements.DemandProfile.Builder(other);
}

/** Creates a new DemandProfile RecordBuilder by copying an existing DemandProfile instance */
public static edu.berkeley.path.ModelElements.DemandProfile.Builder newBuilder(edu.berkeley.path.ModelElements.DemandProfile other) {
return new edu.berkeley.path.ModelElements.DemandProfile.Builder(other);
}

/**
* RecordBuilder for DemandProfile instances.
*/
public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<DemandProfile>
implements org.apache.avro.data.RecordBuilder<DemandProfile> {

private double dt;
private double startTime;
private edu.berkeley.path.ModelElements.LinkRef origin;
private edu.berkeley.path.ModelElements.LinkRef destination;
private java.util.Map<java.lang.CharSequence,java.util.List<java.lang.Double>> demand;

/** Creates a new Builder */
private Builder() {
super(edu.berkeley.path.ModelElements.DemandProfile.SCHEMA$);
}

/** Creates a Builder by copying an existing Builder */
private Builder(edu.berkeley.path.ModelElements.DemandProfile.Builder other) {
super(other);
}

/** Creates a Builder by copying an existing DemandProfile instance */
private Builder(edu.berkeley.path.ModelElements.DemandProfile other) {
super(edu.berkeley.path.ModelElements.DemandProfile.SCHEMA$);
if (isValidValue(fields()[0], other.dt)) {
this.dt = (java.lang.Double) data().deepCopy(fields()[0].schema(), other.dt);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.startTime)) {
this.startTime = (java.lang.Double) data().deepCopy(fields()[1].schema(), other.startTime);
fieldSetFlags()[1] = true;
}
if (isValidValue(fields()[2], other.origin)) {
this.origin = (edu.berkeley.path.ModelElements.LinkRef) data().deepCopy(fields()[2].schema(), other.origin);
fieldSetFlags()[2] = true;
}
if (isValidValue(fields()[3], other.destination)) {
this.destination = (edu.berkeley.path.ModelElements.LinkRef) data().deepCopy(fields()[3].schema(), other.destination);
fieldSetFlags()[3] = true;
}
if (isValidValue(fields()[4], other.demand)) {
this.demand = (java.util.Map<java.lang.CharSequence,java.util.List<java.lang.Double>>) data().deepCopy(fields()[4].schema(), other.demand);
fieldSetFlags()[4] = true;
}
}

/** Gets the value of the 'dt' field */
public java.lang.Double getDt() {
return dt;
}

/** Sets the value of the 'dt' field */
public edu.berkeley.path.ModelElements.DemandProfile.Builder setDt(double value) {
validate(fields()[0], value);
this.dt = value;
fieldSetFlags()[0] = true;
return this;
}

/** Checks whether the 'dt' field has been set */
public boolean hasDt() {
return fieldSetFlags()[0];
}

/** Clears the value of the 'dt' field */
public edu.berkeley.path.ModelElements.DemandProfile.Builder clearDt() {
fieldSetFlags()[0] = false;
return this;
}

/** Gets the value of the 'startTime' field */
public java.lang.Double getStartTime() {
return startTime;
}

/** Sets the value of the 'startTime' field */
public edu.berkeley.path.ModelElements.DemandProfile.Builder setStartTime(double value) {
validate(fields()[1], value);
this.startTime = value;
fieldSetFlags()[1] = true;
return this;
}

/** Checks whether the 'startTime' field has been set */
public boolean hasStartTime() {
return fieldSetFlags()[1];
}

/** Clears the value of the 'startTime' field */
public edu.berkeley.path.ModelElements.DemandProfile.Builder clearStartTime() {
fieldSetFlags()[1] = false;
return this;
}

/** Gets the value of the 'origin' field */
public edu.berkeley.path.ModelElements.LinkRef getOrigin() {
return origin;
}

/** Sets the value of the 'origin' field */
public edu.berkeley.path.ModelElements.DemandProfile.Builder setOrigin(edu.berkeley.path.ModelElements.LinkRef value) {
validate(fields()[2], value);
this.origin = value;
fieldSetFlags()[2] = true;
return this;
}

/** Checks whether the 'origin' field has been set */
public boolean hasOrigin() {
return fieldSetFlags()[2];
}

/** Clears the value of the 'origin' field */
public edu.berkeley.path.ModelElements.DemandProfile.Builder clearOrigin() {
origin = null;
fieldSetFlags()[2] = false;
return this;
}

/** Gets the value of the 'destination' field */
public edu.berkeley.path.ModelElements.LinkRef getDestination() {
return destination;
}

/** Sets the value of the 'destination' field */
public edu.berkeley.path.ModelElements.DemandProfile.Builder setDestination(edu.berkeley.path.ModelElements.LinkRef value) {
validate(fields()[3], value);
this.destination = value;
fieldSetFlags()[3] = true;
return this;
}

/** Checks whether the 'destination' field has been set */
public boolean hasDestination() {
return fieldSetFlags()[3];
}

/** Clears the value of the 'destination' field */
public edu.berkeley.path.ModelElements.DemandProfile.Builder clearDestination() {
destination = null;
fieldSetFlags()[3] = false;
return this;
}

/** Gets the value of the 'demand' field */
public java.util.Map<java.lang.CharSequence,java.util.List<java.lang.Double>> getDemand() {
return demand;
}

/** Sets the value of the 'demand' field */
public edu.berkeley.path.ModelElements.DemandProfile.Builder setDemand(java.util.Map<java.lang.CharSequence,java.util.List<java.lang.Double>> value) {
validate(fields()[4], value);
this.demand = value;
fieldSetFlags()[4] = true;
return this;
}

/** Checks whether the 'demand' field has been set */
public boolean hasDemand() {
return fieldSetFlags()[4];
}

/** Clears the value of the 'demand' field */
public edu.berkeley.path.ModelElements.DemandProfile.Builder clearDemand() {
demand = null;
fieldSetFlags()[4] = false;
return this;
}

@Override
public DemandProfile build() {
try {
DemandProfile record = new DemandProfile();
record.dt = fieldSetFlags()[0] ? this.dt : (java.lang.Double) defaultValue(fields()[0]);
record.startTime = fieldSetFlags()[1] ? this.startTime : (java.lang.Double) defaultValue(fields()[1]);
record.origin = fieldSetFlags()[2] ? this.origin : (edu.berkeley.path.ModelElements.LinkRef) defaultValue(fields()[2]);
record.destination = fieldSetFlags()[3] ? this.destination : (edu.berkeley.path.ModelElements.LinkRef) defaultValue(fields()[3]);
record.demand = fieldSetFlags()[4] ? this.demand : (java.util.Map<java.lang.CharSequence,java.util.List<java.lang.Double>>) defaultValue(fields()[4]);
return record;
} catch (Exception e) {
throw new org.apache.avro.AvroRuntimeException(e);
}
}
}
}
Loading

0 comments on commit 5aa5965

Please sign in to comment.