Skip to content
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
1 change: 1 addition & 0 deletions CPP_Source_Code/ModifiedPolicyIteration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ ModifiedPolicyIteration::ModifiedPolicyIteration(double epsilon, string algorith
PIparIterLim((int)1e6), //iteration limit for policy evaluation in PI
initPol(false),
initVal(false),
norm(numeric_limits<double>::infinity()),
parallel(parallel),
genMDP(genMDP),
printStuff(verbose), //set "true" to print algorithm progress at runtime
Expand Down
20 changes: 0 additions & 20 deletions CPP_Source_Code/ModuleInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,16 +467,6 @@ void ModuleInterface::loadTranMatElementwise(py::list tranMatElementwise){
for (int sidx=0; sidx<numberOfStates; sidx++){
nCol[sidx].resize((nAct[sidx]+1),0);
}
// nCol must be the *count* of transitions for each (state,action), not
// the largest to-state index seen. Transition targets are not
// guaranteed contiguous (e.g. a state may jump to states 2 and 7 but
// not 0,1,3,4,5,6), so sizing columns off the max index left trailing
// slots that never got assigned a real value - still holding
// TransitionMatrix::setNumberOfColumns()'s -1 "unassigned" fill value.
// getNumberOfJumps() (which returns this size) was then used as a loop
// bound in ModifiedPolicyIteration, reading vpOld[-1] - 8 bytes before
// the value vector's allocation - once the loop ran past the real
// entries into those leftover slots.
for (int i=0; i<tranMatElementwise.size(); i++){
innerRew = tranMatElementwise[i].cast<py::list>();
k0 = innerRew[0].cast<int>(); k1 = innerRew[1].cast<int>();
Expand Down Expand Up @@ -569,16 +559,6 @@ void ModuleInterface::loadTranMatFromFile(string tranMatFromFile, char sep, bool
file.clear();
file.seekg(0,ios::beg);

// nCol must be the *count* of transitions for each (state,action), not
// the largest to-state index seen. Transition targets are not
// guaranteed contiguous (e.g. a state may jump to states 2 and 7 but
// not 0,1,3,4,5,6), so sizing columns off the max index left trailing
// slots that never got assigned a real value - still holding
// TransitionMatrix::setNumberOfColumns()'s -1 "unassigned" fill value.
// getNumberOfJumps() (which returns this size) was then used as a loop
// bound in ModifiedPolicyIteration, reading vpOld[-1] - 8 bytes before
// the value vector's allocation - once the loop ran past the real
// entries into those leftover slots.
i=0;
while (getline(file,line)){
if (!header||i>0){
Expand Down
2 changes: 1 addition & 1 deletion Python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ CMAKE_BUILD_TYPE = "Release"

[project]
name = "mdpsolver"
version = "0.10.0"
version = "0.10.1"
authors = [
{ name="Anders Reenberg Andersen", email="andersra@live.dk" },
{ name="Jesper Fink Andersen", email="jesperfinkandersen@gmail.com" },
Expand Down
8 changes: 4 additions & 4 deletions Python/tests/test1.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
sys.exit("Model 1a failed!")
if not np.array_equal(
np.round(np.array(mdl1a.getValueVector()), 3),
np.round(np.array([354.2101307157537, 368.21018917357264, 457.21037278800077]), 3),
np.round(np.array([367.6724223596708, 381.67249768303293, 470.67273547568027]), 3),
):
sys.exit("Model 1a failed!")

Expand All @@ -138,7 +138,7 @@
sys.exit("Model 2a failed!")
if not np.array_equal(
np.round(np.array(mdl2a.getValueVector()), 3),
np.round(np.array([354.2101307157537, 368.21018917357264, 457.21037278800077]), 3),
np.round(np.array([367.6724223596708, 381.67249768303293, 470.67273547568027]), 3),
):
sys.exit("Model 2a failed!")

Expand Down Expand Up @@ -168,7 +168,7 @@
sys.exit("Model 1b failed!")
if not np.array_equal(
np.round(np.array(mdl1b.getValueVector()), 3),
np.round(np.array([354.2101307157537, 368.21018917357264, 457.21037278800077]), 3),
np.round(np.array([367.6724223596708, 381.67249768303293, 470.67273547568027]), 3),
):
sys.exit("Model 1b failed!")

Expand All @@ -186,7 +186,7 @@
sys.exit("Model 2b failed!")
if not np.array_equal(
np.round(np.array(mdl2b.getValueVector()), 3),
np.round(np.array([354.2101307157537, 368.21018917357264, 457.21037278800077]), 3),
np.round(np.array([367.6724223596708, 381.67249768303293, 470.67273547568027]), 3),
):
sys.exit("Model 2b failed!")

Expand Down
8 changes: 4 additions & 4 deletions Python/tests/test1_pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
sys.exit("Model 1a failed!")
if not np.array_equal(
np.round(np.array(mdl1a.getValueVector()), 3),
np.round(np.array([354.2101307157537, 368.21018917357264, 457.21037278800077]), 3),
np.round(np.array([367.6724223596708, 381.67249768303293, 470.67273547568027]), 3),
):
sys.exit("Model 1a failed!")

Expand All @@ -134,7 +134,7 @@
sys.exit("Model 2a failed!")
if not np.array_equal(
np.round(np.array(mdl2a.getValueVector()), 3),
np.round(np.array([354.2101307157537, 368.21018917357264, 457.21037278800077]), 3),
np.round(np.array([367.6724223596708, 381.67249768303293, 470.67273547568027]), 3),
):
sys.exit("Model 2a failed!")

Expand Down Expand Up @@ -164,7 +164,7 @@
sys.exit("Model 1b failed!")
if not np.array_equal(
np.round(np.array(mdl1b.getValueVector()), 3),
np.round(np.array([354.2101307157537, 368.21018917357264, 457.21037278800077]), 3),
np.round(np.array([367.6724223596708, 381.67249768303293, 470.67273547568027]), 3),
):
sys.exit("Model 1b failed!")

Expand All @@ -182,7 +182,7 @@
sys.exit("Model 2b failed!")
if not np.array_equal(
np.round(np.array(mdl2b.getValueVector()), 3),
np.round(np.array([354.2101307157537, 368.21018917357264, 457.21037278800077]), 3),
np.round(np.array([367.6724223596708, 381.67249768303293, 470.67273547568027]), 3),
):
sys.exit("Model 2b failed!")

Expand Down
Loading