Skip to content

Commit 3539b8e

Browse files
committed
tweaked 2018 json
1 parent 2847c95 commit 3539b8e

File tree

5 files changed

+30
-50
lines changed

5 files changed

+30
-50
lines changed

RoyalSociety2018/jsonUtils.cpp

+18-39
Original file line numberDiff line numberDiff line change
@@ -140,22 +140,6 @@ appendNSToJson(j, n);
140140

141141
}
142142

143-
void addNSJson(Worm & w, json & j)
144-
{
145-
146-
{string nsHead = "Nervous system";
147-
getNSJson(w.n, j[nsHead]);
148-
vector<string> cell_names = {"DB", "DD", "VBA", "VDA", "VBP", "VDP"};
149-
{Params< vector<string> > parvec = getNervousSysCellNames(cell_names, 6);
150-
appendToJson<vector<string> >(j[nsHead],parvec);}}
151-
152-
{string nsHead = "Head Nervous system";
153-
getNSJson(w.h, j[nsHead]);
154-
vector<string> cell_names = {"SMDD", "RMDD", "SMDV", "RMDV"};
155-
{Params< vector<string> > parvec = getNervousSysCellNames(cell_names, 1);
156-
appendToJson<vector<string> >(j[nsHead],parvec);}}
157-
158-
}
159143

160144
Params<double> getStretchReceptorParams(StretchReceptor& s)
161145
{
@@ -169,13 +153,6 @@ par.messages_inds = {0,1,2}; //must be ordered
169153
return par;
170154
}
171155

172-
void addSRJson(Worm & w, json & j)
173-
{
174-
Params<double> par = getStretchReceptorParams(w.sr);
175-
appendToJson<double>(j["Stretch receptor"],par);
176-
}
177-
178-
179156
Params<double> getWormParams(Worm & w)
180157
{
181158
Params<double> par;
@@ -186,12 +163,6 @@ par.names = {"NMJ_DB", "NMJ_VBa", "NMJ_VBp", "NMJ_DD", "NMJ_VDa", "NMJ_VDp",
186163
return par;
187164
}
188165

189-
void addWormJson(Worm & w, json & j)
190-
{
191-
Params<double> par = getWormParams(w);
192-
appendToJson<double>(j["Worm"],par);
193-
194-
}
195166

196167
void writeParsToJson(Worm & w)
197168
{
@@ -201,13 +172,7 @@ void writeParsToJson(Worm & w)
201172

202173
cout << "making json" << endl;
203174
vector<doubIntParamsHead> parvec;
204-
//doubIntParamsHead var1;
205175
doubIntParamsHead var1 = supArgs1.getParams();
206-
/* var1.parInt.head = "Evolutionary Optimization Parameters";
207-
var1.parInt.names = {"pop_size", "randomseed"};
208-
var1.parInt.vals = {supArgs1.pop_size, supArgs1.randomseed};
209-
var1.parInt.messages ={"population size", "seed"};
210-
var1.parInt.messages_inds = {0,1}; */
211176
parvec.push_back(var1);
212177

213178
for (size_t i=0;i<parvec.size(); i++) {
@@ -217,10 +182,24 @@ void writeParsToJson(Worm & w)
217182
appendToJson<long>(j[parvec[i].parInt.head],parvec[i].parInt);
218183
}
219184

220-
// writeParsToJson(w, "worm_data.json", evolutionParams);
221-
addNSJson(w,j);
222-
addWormJson(w,j);
223-
addSRJson(w,j);
185+
186+
{string nsHead = "Nervous system";
187+
getNSJson(w.n, j[nsHead]);
188+
vector<string> cell_names = {"DB", "DD", "VBA", "VDA", "VBP", "VDP"};
189+
{Params< vector<string> > parvec = getNervousSysCellNames(cell_names, 6);
190+
appendToJson<vector<string> >(j[nsHead],parvec);}}
191+
192+
{string nsHead = "Head Nervous system";
193+
getNSJson(w.h, j[nsHead]);
194+
vector<string> cell_names = {"SMDD", "RMDD", "SMDV", "RMDV"};
195+
{Params< vector<string> > parvec = getNervousSysCellNames(cell_names, 1);
196+
appendToJson<vector<string> >(j[nsHead],parvec);}}
197+
198+
{Params<double> par = getWormParams(w);
199+
appendToJson<double>(j["Worm"],par);}
200+
201+
{Params<double> par = getStretchReceptorParams(w.sr);
202+
appendToJson<double>(j["Stretch receptor"],par);}
224203

225204
ofstream json_out(supArgs1.rename_file("worm_data.json"));
226205
json_out << std::setw(4) << j << std::endl;

exampleRun/worm_data.json

+4
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@
6666
"message": "optimization simulation duration",
6767
"value": 24
6868
},
69+
"max_gens": {
70+
"message": "maximum evolution generations",
71+
"value": 10
72+
},
6973
"pop_size": {
7074
"message": "population size",
7175
"value": 96

exampleRunRS18/evolution_pars.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2+
"Duration": 50,
23
"pop_size": 56,
34
"randomseed": 151750,
4-
"Duration": 50,
55
"max_gens": 20
66
}

exampleRunRS18/simulation_pars.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"doNML": 0,
33
"seed": 151750,
4-
"Duration": 24,
4+
"Duration": 50,
55
"doRandInit": 0
66
}

run_main.py

+6-9
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@
3737
"doNML": 0,
3838
"doRandInit": 0,
3939
"maxGens": 2000,
40-
41-
4240
}
4341

4442

@@ -179,7 +177,7 @@ def process_args():
179177
type=float,
180178
metavar="<duration>",
181179
default=DEFAULTS["duration"],
182-
help="Duration of simulation for evolution and best worm in ms."
180+
help="Duration of simulation for evolution and best worm in ms.",
183181
)
184182

185183
parser.add_argument(
@@ -188,8 +186,7 @@ def process_args():
188186
type=int,
189187
metavar="<pop size>",
190188
default=DEFAULTS["popSize"],
191-
help="Population size for evolutionary algorithm."
192-
189+
help="Population size for evolutionary algorithm.",
193190
)
194191

195192
parser.add_argument(
@@ -198,7 +195,7 @@ def process_args():
198195
type=int,
199196
metavar="<max generations>",
200197
default=DEFAULTS["maxGens"],
201-
help="Maximum number of generations for evolutionary algorithm."
198+
help="Maximum number of generations for evolutionary algorithm.",
202199
)
203200

204201
parser.add_argument(
@@ -363,11 +360,11 @@ def run(a=None, **kwargs):
363360
else:
364361
do_randInit = 0
365362

366-
if a.modelFolder == '.':
363+
if a.modelFolder == ".":
367364
defaults_base = defaults_base_celoc
368-
elif a.modelFolder == 'RoyalSociety2018':
365+
elif a.modelFolder == "RoyalSociety2018":
369366
defaults_base = defaults_base_2018
370-
elif a.modelFolder == 'exampleRunNet21':
367+
elif a.modelFolder == "exampleRunNet21":
371368
defaults_base = defaults_base_2021
372369
else:
373370
defaults_base = defaults_base_celoc

0 commit comments

Comments
 (0)