Commit 623c5b8f authored by Benoît Barbot's avatar Benoît Barbot

progress

parent 900ec599
Pipeline #974 failed with stages
in 3 minutes and 29 seconds
......@@ -17,7 +17,7 @@ def poly_to_c_first(p):
if triplet[cardclocks]>1:
s+="*pow(t,"+ str(triplet[cardclocks])+')';
return(s);
def poly_to_c_bis(p):
supp=p.exponents();
s='0.0';
......@@ -44,9 +44,9 @@ def matrix_to_c(tab,name):
for v2 in v:
s+= '%d, ' %v2;
s+= '}, ';
return s+'};\n';
def poly_to_c_ter(poly):
s0=re.sub('\{\(','{{',str(poly.dict()))
s1=re.sub('\, *?\(','}, {',s0)
......@@ -58,7 +58,7 @@ def poly_to_c_ter(poly):
return (s2+ ',{ ' +s3+',0}' +'}');
else :
return ('{{ ' +s3+',0}}');
def poly_to_c(p):
return (poly_to_c_ter(p));
......@@ -83,7 +83,7 @@ def poly_to_c_data(p,fichier_data,cardclocks):
s= "{0";
for i in range(cardclocks):
s+=",x_%d " %(i+1);
return ("customDistr.evalPoly(%i" %n) + (",%s,0.0})" %s);
################################################################################
......@@ -176,13 +176,13 @@ def printDefineUserDistribution(file,name,var,nbparam, low, up, norm, cdf ,pdf):
s+=" <attribute name=\"pdf\">%i</attribute>\n" %pdf;
s+=' </attribute>\n'
return(s);
def printUserDefineDistribution(id,param):
t= ' <attribute name=\"type\">\n';
t+=' USERDEFINE\n';
t+=' </attribute>\n';
t+=' <attribute name="param">\n'
t+=' <attribute name="expr"><attribute name=\"unParsed\"> %s' %id;
t+=' <attribute name="expr"><attribute name=\"unParsed\"> %s' %id;
t+=' </attribute></attribute>\n';
t+=' </attribute>\n';
for c in param:
......@@ -204,7 +204,7 @@ def printGRML_Start(consts, clocks, distributions, external):
s+=' <attribute name=\"expr\"><attribute name=\"numValue\">%i</attribute></attribute>\n' %(value);
s+=' </attribute>\n';
s+=' </attribute>\n';
s+=' </attribute>\n';
s+=' </attribute>\n';
s+= distributions
s+=' <attribute name="variables">\n';
s+=' <attribute name="clocks">\n';
......
......@@ -10,10 +10,13 @@ sage script_tocosmos_PTA.sage $1 $1.grml $size_poly $size_poly -unif
echo "$1_Unif.png";
Cosmos $1.grml taTacas2018.lha --tmp-status 2 --output-raw histdata.raw --max-run "$nb_points" --const "N=$loopsize" --tmp-status 2 --set-Horizon "$loopsize"
cp histdata.raw histUnif.raw
gnuplot -c histogram.gnu "$1_Unif.png"
Cosmos Iso_$1.grml taTacas2018.lha --tmp-status 2 --output-raw histdata.raw --max-run "$nb_points" --const "N=$loopsize" --tmp-status 2 --set-Horizon "$loopsize"
cp histdata.raw histIso.raw
gnuplot -c histogram.gnu "$1_ISO.png"
Cosmos $1.grml taTacas2018.lha --tmp-status 2 --output-raw histdata.raw --max-run "$nb_points" --const "N=$loopsize" --tmp-status 2 --set-Horizon "$loopsize" --use-van-der-corput
cp histdata.raw histVDC.raw
gnuplot -c histogram.gnu "$1_VDC.png"
......@@ -14,7 +14,6 @@ if len(sys.argv)<2:
print("usage: script_tocosmos_PTA.sage prism_file [out_file] [num_poly (default 3)] [deadline (default -1)] [-isotropic])");
exit(1);
sagepath,ext = os.path.splitext(str(sys.argv[1]));
outpath=sagepath+'.grml';
......@@ -201,6 +200,11 @@ for i in range(cardclocks):
passingClockParameters += ",x_%d" %(i+1);
passingClockParametersDelay = "";
for i in range(cardclocks):
passingClockParametersDelay += ",x_%d-incrtime" %(i+1);
def printGRML_distribution(alldistr,idtransinv,statelist,data_path,cardclocks,fichier_data,Dline):
s="";
maxid = len(idtransinv);
......@@ -228,11 +232,10 @@ def printGRML_distribution(alldistr,idtransinv,statelist,data_path,cardclocks,fi
return((s,tabidDistrHorizon));
def get_reset(cardclocks,edge):
t='<attribute name=\"update\">\n ';
t='';
for c in range(cardclocks):
if edge['reset'][c]==0:
t+='x_%d=0;' %(c+1);
t+='\n </attribute>';
return t;
## Print all transitions
......@@ -279,23 +282,29 @@ def printGRML_transition(statelist,allones,isIsotropic,Dline):
t="" #time
r="" #reset
if(isIsotropic):
#nbcdfpoly=poly_to_data(allones[0]['Cdf'][i][j],fichier_data,cardclocks,'');
horizon2='max( Marking.P-&gt;_PL_Counter -%i + %i-1,0 )' %(Dline,len(allones)-1);
distrn='transDistrTab[%d][%s]' %(trans['id'],horizon2);
cdfpoly='customDistr.userDefineCDF( { ((double)%s) %s } ,incrtime) ' %(distrn, passingClockParametersDelay);
debug='customDistr.print_poly(%s) &lt;&lt; \"->\" &lt;&lt;' %distrn
#r='std::cerr &lt;&lt; \"time_%d_%d\t\" &lt;&lt; incrtime &lt;&lt; \"\t\" &lt;&lt; %s %s &lt;&lt; std::endl;' %(i,j,debug, cdfpoly);
t+=printUniformDistribution(poly_to_c_data(trans['lowerBound'],fichier_data,cardclocks),
poly_to_c_data(trans['upperBound'],fichier_data,cardclocks));
else:
#r='std::cerr &lt;&lt; \"time_%d_%d\t\" &lt;&lt; incrtime &lt;&lt; std::endl;' %(i,j);
t+=printUserDefineDistribution( 'transDistrTab[%d][%s]' %(trans['id'],horizon)
,range(cardclocks));
#if only 1 miniedge compute reset
r="";
if(len(trans['miniedge'])==1 and not all_miniedge):
r=get_reset(cardclocks,trans['miniedge'][0]);
r+=get_reset(cardclocks,trans['miniedge'][0]);
s+=printGRML_OneTransition('16%d' %(trans['id']),
'time_%d_%d' %(i,j),
t,
"1.00",
"<attribute name=\"numValue\">1</attribute>",
r);
'<attribute name=\"update\">\n%s</attribute>\n' %(r));
#miniedge
k=-1;
......@@ -306,7 +315,7 @@ def printGRML_transition(statelist,allones,isIsotropic,Dline):
'miniedge_%d_%d_%d' %(i,j,k),
"1",
'<attribute name=\"numValue\"> %f </attribute>\n' %(edge['prob']),
get_reset(cardclocks,edge));
'<attribute name=\"update\">\n%s</attribute>\n' %(get_reset(cardclocks,edge)));
return(s);
def printGRML_arc(statelist):
......@@ -347,13 +356,13 @@ def action_to_signal(a):
def toCOSMOS(allones,isIsotropic,Dline):
tab = '';
distributions='';
if( not isIsotropic):
(s2,tab2)=printGRML_distribution(allones,idtransinv,statelist,outpath,cardclocks,fichier_data,Dline);#alldistr
distributions+=s2;
tab=matrix_to_c(tab2,"transDistrTab");
else:
distributions+=printDefineUserDistribution(outpath, 'DummyDistribution', 't', cardclocks+1,
0,0,0,0,0);
#if( not isIsotropic):
(s2,tab2)=printGRML_distribution(allones,idtransinv,statelist,outpath,cardclocks,fichier_data,Dline);#alldistr
distributions+=s2;
tab=matrix_to_c(tab2,"transDistrTab");
#else:
# distributions+=printDefineUserDistribution(outpath, 'DummyDistribution', 't', cardclocks+1,
# 0,0,0,0,0);
external= 'void magicReset(){};\n'
external+= 'bool magicConditional(int){return true;};\n'
external+= 'void magicUpdate(int,double){};\n'
......
......@@ -332,6 +332,8 @@ void SimulatorBase<S,EQT,DEDS>::interactiveSimulation(){
cerr << "Fail to parse time!" << endl;
}
} else if(input_line.compare("exit")==0){
exit(EXIT_SUCCESS);
} else if(input_line.compare("help")==0 || input_line.compare("h")==0){
cerr << "Available command:\n\thelp:\tdisplay this message"<<endl;
cerr << "\ts, step:\tmake one step of simulation" << endl;
......@@ -339,7 +341,8 @@ void SimulatorBase<S,EQT,DEDS>::interactiveSimulation(){
cerr << "\tfire tr:\tfire transition tr" << endl;
cerr << "\twait tr:\twait until transition tr occurs" << endl;
cerr << "\twait t:\twait t times unit" << endl;
cerr << "\texit t:\texit simulator" << endl;
} else if (input_line.compare("s")==0 || input_line.compare("s")==0)continueLoop=false;
else if (input_line.compare("")==0);
else {
......
......@@ -158,19 +158,19 @@ double unif01ofint(unsigned long v){
double res= 1.0;
while( v != 0){
if(v %2){
res /= 2.0;
res /= 2.0;
}else{
res = (0.5 + res)/2.0;
res = (0.5 + res)/2.0;
}
v /=2;
}
return res;
}
void KroneckerState::seed(unsigned long seed){
void KroneckerState::seed(unsigned long seed){
//double * tmp = reinterpret_cast<double*>(&seed);
seed_val = unif01ofint(seed);
}
double KroneckerState::sample(){
......@@ -401,10 +401,22 @@ double timeGen::GenerateTime(DistributionType distribution,size_t trid, const ar
std::uniform_real_distribution<> unif(0.0, 1.0);
gentime = unif(RandomNumber);
}
//cerr << gentime << endl;
double lower = cd.userDefineLowerBound(param);
double upper = cd.userDefineUpperBound(param);
/*
//Isotrop Hack
//std::uniform_real_distribution<> unif(lower, upper);
//gentime = unif(RandomNumber);
gentime = sampleQuasiRandom(trid);
gentime = (upper-lower)*gentime + lower;
cerr << cd.userDefineCDF(param,gentime) << endl;
return gentime;
//Isotrop Hack
*/
//cerr << "sample(" << gentime << ",[" << lower << "," << upper << "]):" <<endl;
double initialpt = (lower+upper)/ 2.0;
return boost_newton_raphson_iterate([&](double x){
......
open Unix
let _ =
if Array.length Sys.argv <= 2 then (
print_endline "usage: split_merge file chunk_size [sep]";
exit 1;)
let file = open_in Sys.argv.(1)
let chunk_size = int_of_string Sys.argv.(2)
let sep = if Array.length Sys.argv<=3 then "\t"
else Sys.argv.(3)
let _ =
let n = ref 0 in
try while true do
incr n;
let l = input_line file in
if !n mod chunk_size =0 then
print_endline l
else print_string (l^sep)
done with
End_of_file -> ()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment