Skip to content

Commit f98ee1c

Browse files
committed
Take out storage
1 parent e17c261 commit f98ee1c

13 files changed

+11
-128
lines changed

include/Adadelta.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,6 @@ namespace net {
3535
*/
3636
void train(net::NeuralNet *network, const std::vector< std::vector<double> > &input, const std::vector< std::vector<double> > &correctOutput);
3737

38-
/**
39-
* \brief Stores an Adadelta object using specified ofstream.
40-
*
41-
* \param output pointer to the output stream which the neural network will be written to
42-
**/
43-
void store(std::ofstream *output);
4438

4539
double targetErrorLevel; /**< The target error level, set by constructor */
4640
int maximumEpochs; /**< The maximum number of epochs for one training run, set by constructor */

include/Fido.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include "LSInterpolator.h"
1414
#include "NeuralNet.h"
1515
#include "Neuron.h"
16-
#include "Pruner.h"
1716
#include "QLearn.h"
1817
#include "Trainer.h"
1918
#include "WireFitQLearn.h"

include/FidoControlSystem.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ namespace rl {
1717
*/
1818
FidoControlSystem(int stateDimensions, Action minAction, Action maxAction, int baseOfDimensions);
1919

20+
/** Choose an action using a non-specified, dynamically adjusted exploration level.
21+
*
22+
* \param state a vector of the current sensor values
23+
*/
2024
std::vector<double> chooseBoltzmanActionDynamic(State state);
2125

2226
/** Update the control system's model, by giving it reward for its last action.
@@ -32,12 +36,6 @@ namespace rl {
3236
*/
3337
void reset();
3438

35-
const double initialExploration = 1;
36-
//const double initialExploration = 0.4;
37-
const int samplesOfHistory = 10;
38-
double explorationLevel;
39-
double lastError;
40-
4139
private:
4240
struct History {
4341
State initialState, newState;
@@ -52,6 +50,11 @@ namespace rl {
5250
}
5351
};
5452

53+
const double initialExploration = 1;
54+
const int samplesOfHistory = 10;
55+
double explorationLevel;
56+
double lastError;
57+
5558
std::vector<History> histories;
5659

5760
std::vector<FidoControlSystem::History> selectHistories();

include/Interpolator.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@ namespace rl {
1515
class Interpolator {
1616
public:
1717

18-
/** Initializes the parameters of an interpolator from a file. Returns false if the interpolator stored in the file is not the correct type */
19-
virtual bool initFromStream(std::ifstream *in) = 0;
20-
21-
/** Stores the parameters of an interpolator in a file */
22-
virtual void store(std::ofstream *out) = 0;
23-
2418
/** Uses the interpolator function to compute the reward of an action vector given a set of control wires */
2519
virtual double getReward(const std::vector<Wire> &controlWires, const std::vector<double> &action) = 0;
2620

@@ -29,9 +23,7 @@ namespace rl {
2923

3024
/** The partial derivative of the interpolator function with respect to the value of one term of the action vector of a control wire */
3125
virtual double actionTermDerivative(double actionTerm, double wireActionTerm, const std::vector<double> &action, const Wire &wire, const std::vector<Wire> &controlWires) = 0;
32-
33-
/** Gets an interpolator from a file. Tries out every interpolator and throws an error none of the interpolators successfully read from the file */
34-
static Interpolator * getAnyInterpolatorFromFile(std::ifstream *in);
26+
3527
};
3628
}
3729

include/LSInterpolator.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,6 @@ namespace rl {
2626
*/
2727
LSInterpolator(double smoothingFactor_, double e_);
2828

29-
/**
30-
* \brief Initializes a LSInterpolator using the information from a file.
31-
*
32-
* \param in the file from which initialize the LSInterpolator
33-
*
34-
* \return False if the interpolator stored in the file is not a LSInterpolator.
35-
*/
36-
bool initFromStream(std::ifstream *in);
37-
38-
/**
39-
* \brief Stores the interpolator object in a file
40-
*
41-
* \param out the file to which to write the LSInterpolator
42-
*/
43-
void store(std::ofstream *out);
44-
4529
/**
4630
* \brief Uses the interpolator function to compute the reward of an action vector given a set of control wires
4731
*

include/QLearn.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@ namespace rl {
8383
*/
8484
void reset();
8585

86-
/** Stores this model in a stream. */
87-
void store(std::ofstream *output);
8886
private:
8987
net::Backpropagation backprop;
9088
std::vector<Model> models;

include/Trainer.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,6 @@ namespace net {
2222
* \param correctOutput network is trained to output an element of correctOutput when fed a corresponding element of the input vector
2323
*/
2424
virtual void train(net::NeuralNet *network, const std::vector< std::vector<double> > &input, const std::vector< std::vector<double> > &correctOutput) = 0;
25-
26-
/**
27-
* \brief Stores a Trainer object using specified stream.
28-
*
29-
* \param output pointer to the output stream which the neural network will be written to
30-
**/
31-
virtual void store(std::ofstream *output) = 0;
3225
};
3326
}
3427

include/WireFitQLearn.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ namespace rl {
5252
/** Initializes an empty, non-valid WireFitQLearn object. */
5353
WireFitQLearn();
5454

55-
/** Initializes a WireFitQLearn object from a stream */
56-
WireFitQLearn(std::ifstream *input);
57-
5855
/** Gets the action that the network deems most benificial for the current state
5956
*
6057
* \param currentState a vector of doubles representing the "inputs" or sensor values of the system
@@ -80,9 +77,6 @@ namespace rl {
8077
/** Resets the system's model so that to a newely initialized state */
8178
void reset();
8279

83-
/** Stores this model in a stream. */
84-
void store(std::ofstream *output);
85-
8680
protected:
8781
// Feeds the state into the network, parses to the output of the network into wire form, and outputs these wires
8882
std::vector<Wire> getWires(State state);

src/Adadelta.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,6 @@ double Adadelta::trainOnDataPoint(net::NeuralNet *network, const std::vector<dou
6161
return networkError;
6262
}
6363

64-
void Adadelta::store(std::ofstream *output) {
65-
66-
}
67-
6864
void Adadelta::resetAccumulatedVectors(net::NeuralNet *network) {
6965
accumulatedGradients.clear();
7066
accumulatedUpdates.clear();

src/FidoControlSystem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "../include/FidoControlSystem.h"
22

33
#include "../include/NeuralNet.h"
4-
#include "../include/Pruner.h"
4+
#include "../include/Backpropagation.h"
55
#include "../include/LSInterpolator.h"
66

77

src/Interpolator.cpp

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/LSInterpolator.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,6 @@ LSInterpolator::LSInterpolator(double smoothingFactor_, double e_) {
1818
e = e_;
1919
}
2020

21-
bool LSInterpolator::initFromStream(std::ifstream *in) {
22-
std::string name;
23-
if (!(*in >> name)) {
24-
std::cout << "Interpolator could not read ifstrem\n";
25-
throw 1;
26-
}
27-
28-
if (name != "LS") {
29-
return false;
30-
}
31-
32-
*in >> smoothingFactor >> e;
33-
return true;
34-
}
35-
36-
void LSInterpolator::store(std::ofstream *out) {
37-
*out << " LS " << smoothingFactor << " " << e << " ";
38-
}
39-
4021
double LSInterpolator::getReward(const std::vector<Wire> &controlWires, const std::vector<double> &action) {
4122
double maxReward = -9999999;
4223
for (std::vector<Wire>::const_iterator a = controlWires.begin(); a != controlWires.end(); ++a) if (a->reward > maxReward) maxReward = a->reward;

src/WireFitQLearn.cpp

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,6 @@ WireFitQLearn::WireFitQLearn(unsigned int stateDimensions, unsigned int actionDi
4646
baseOfDimensions = baseOfDimensions_;
4747
}
4848

49-
WireFitQLearn::WireFitQLearn() {
50-
51-
}
52-
53-
WireFitQLearn::WireFitQLearn(std::ifstream *input) {
54-
55-
}
56-
5749
Action WireFitQLearn::chooseBestAction(State currentState) {
5850
std::vector<double> action = bestAction(currentState);
5951
lastAction = action;
@@ -111,27 +103,6 @@ void WireFitQLearn::reset() {
111103
network->randomizeWeights();
112104
}
113105

114-
void WireFitQLearn::store(std::ofstream *output) {
115-
if(output->is_open()) {
116-
*output << learningRate << " " << devaluationFactor << "\n";
117-
*output << actionDimensions << " " << numberOfWires << "\n";
118-
*output << controlPointsGDErrorTarget << " " << controlPointsGDLearningRate << " " << controlPointsGDMaxIterations << " " << baseOfDimensions << "\n";
119-
120-
for(unsigned int a = 0; a < minAction.size(); a++) *output << minAction[a] << " ";
121-
for(unsigned int a = 0; a < maxAction.size(); a++) *output << maxAction[a] << " ";
122-
for(unsigned int a = 0; a < lastAction.size(); a++) *output << lastAction[a] << " ";
123-
124-
trainer->store(output);
125-
interpolator->store(output);
126-
network->store(output);
127-
128-
output->close();
129-
} else {
130-
std::cout << "Could not store wirefitqlearn in file\n";
131-
throw 1;
132-
}
133-
}
134-
135106
std::vector<Wire> WireFitQLearn::getWires(State state) {
136107
std::vector<Wire> wires(numberOfWires);
137108
std::vector<double> rawOutput = network->getOutput(state);

0 commit comments

Comments
 (0)