-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#102: implemented fixed step smoothing support +
working on #100, #101, #99 working on path based implementation. now working with exp transformed weibit as well as MNL (verified).
- Loading branch information
markr
committed
Feb 8, 2024
1 parent
585d5c0
commit f7a9bd1
Showing
19 changed files
with
239 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 127 additions & 0 deletions
127
src/main/java/org/goplanit/sdinteraction/smoothing/FixedStepSmoothing.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
package org.goplanit.sdinteraction.smoothing; | ||
|
||
import org.goplanit.utils.id.IdGroupingToken; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* Fixed step smoothing implementation | ||
* | ||
* @author markr | ||
* | ||
*/ | ||
public class FixedStepSmoothing extends Smoothing { | ||
|
||
/** generated UID */ | ||
private static final long serialVersionUID = -3016251188673804117L; | ||
|
||
/** | ||
* Step size | ||
*/ | ||
protected double stepSize = DEFAULT_STEP_SIZE; | ||
|
||
/** | ||
* The default step size to use | ||
*/ | ||
public static final double DEFAULT_STEP_SIZE = 0.25; | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param groupId contiguous id generation within this group for instances of this class | ||
*/ | ||
public FixedStepSmoothing(IdGroupingToken groupId) { | ||
super(groupId); | ||
} | ||
|
||
/** | ||
* Copy constructor | ||
* | ||
* @param other to copy | ||
* @param deepCopy when true, create a deep copy, shallow copy otherwise | ||
*/ | ||
public FixedStepSmoothing(FixedStepSmoothing other, boolean deepCopy) { | ||
super(other, deepCopy); | ||
this.stepSize = other.stepSize; | ||
} | ||
|
||
/** | ||
* Set the new fixed step size to use | ||
* @param stepSize | ||
*/ | ||
public void setStepSize(double stepSize) { | ||
this.stepSize = stepSize; | ||
} | ||
|
||
/** | ||
* Get the fixed step size | ||
* @return stepSize | ||
*/ | ||
public double getStepSize(double stepSize) { | ||
return this.stepSize; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public double execute(final double previousValue, final double proposedValue) { | ||
return (1 - stepSize) * previousValue + stepSize * proposedValue; | ||
} | ||
|
||
/** | ||
* Update stepSize | ||
*/ | ||
@Override | ||
public void updateStepSize() { | ||
// N/A | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public double[] execute(final double[] previousValues, final double[] proposedValues, final int numberOfValues) { | ||
final double[] smoothedValues = new double[numberOfValues]; | ||
for (int i = 0; i < numberOfValues; ++i) { | ||
smoothedValues[i] = (1 - stepSize) * previousValues[i] + stepSize * proposedValues[i]; | ||
} | ||
return smoothedValues; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public FixedStepSmoothing shallowClone() { | ||
return new FixedStepSmoothing(this, false); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public FixedStepSmoothing deepClone() { | ||
return new FixedStepSmoothing(this, true); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public void reset() { | ||
this.stepSize = DEFAULT_STEP_SIZE; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public Map<String, String> collectSettingsAsKeyValueMap() { | ||
var settingsMap = new HashMap<String, String>(); | ||
settingsMap.put("fixed step-size", "" + stepSize); | ||
return settingsMap; | ||
} | ||
|
||
} |
Oops, something went wrong.