Hi Jane, 
      
    There are quite a few
        ways to do this. What we have been doing while working on demand
        calibration methods is to have a wrap-like functions that do all
        the estimations, save the OD file, and then run all SUMO procedures
        from that point on. 
      
    We have tested implementations
        for both Matlab and R and it is quite easy to do in any
        programming language. As you can understand this might or might
        not run traci. In our case, we do not use it. 
      
    The "secret" to doing
        everything (that worked for us) is the `system` command. With
        this we use the SUMO tools and get we need. You can have a look
        at the code below, which provides the logic and is pretty much
        the core of running sumo this way:
    High level description:
      
    
      - First we are
          creating the OD file
- then we do time formatting
- set the seed
- convert OD2TRIPS
- RUN trip based sumo
- Convert output to
          csv (to make it easier to read in matlab)
- Read output in
          Matlab
Matlab important pieces
        of code (just for guidance, not guaranteed to work as is):
    
    % CREATE the file
        format to pass from a matrix to an OD
        TheBeginText= strcat("$OR;D2 \n* From-Time  To-Time
        \n",starttime," ", endtime,"\n* Factor \n1.00\n");
        Expr = zeros(size(FullOD,1)*size(FullOD,1),3);
        Expr = string(Expr);
        Counter=1;
        for i = 1:size(FullOD,1)
            for j = 1:size(FullOD,2)
                    Expr(Counter,1) = Zones_masks(i,2);
                    Expr(Counter,2) = Zones_masks(j,2);
                    Expr(Counter,3) = string(FullOD(i,j));
                    Counter=Counter+1;
            end
        end
        % SAVE the OD File in the temp location (each file gets a k for
        the par loop)
        ma=strcat(pathtoCaseOutput,'/',num2str(k),'myODUpdated.txt');
        fileID = fopen(ma, 'w');
        fprintf(fileID,TheBeginText);
        fprintf(fileID,'%s %s %s \n', [Expr(:,1),Expr(:,2),Expr(:,3)]');
        fclose(fileID);
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        TIME FORMATTING %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        % Start Simulation Times
        integ=floor(str2double(starttime));
        fract=100*(str2double(starttime)-integ);
        beginSimTime = integ*60*60 + fract*60;
        % End Simulation Times
        integ=floor(str2double(endtime));
        fract=100*(str2double(endtime)-integ);
        endSimTime = integ*60*60 + fract*60;
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        SEED SETTING %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
        seedNN =  randi(100000, 1);
    %%%%%%%%%%%%%%%% MAC /
        LINUX OD2TRIPS %%%%%%%%%%%%%%%%
            oD2TRIPS = strcat(pathtoSUMOBIN,"od2trips --no-step-log
        --output-prefix ",num2str(k),...
                " --spread.uniform ",...
                " --taz-files ", pathToNetwork_a,tazname, " -d ", ...
                pathtoCaseOutput,"/",num2str(k),"myODUpdated.txt -o ",
        ...
                pathtoCaseOutput,"/","upd_ODTrips.trips.xml",...
                " --seed ", num2str(seedNN));
            [~,~] = system(oD2TRIPS); % [~,~] =  suppresses any console
        outcome. Not recommended when running first time
        
      
      %%%%%%%%%%%%%%%% TRIPBASED RUN
          %%%%%%%%%%%%%%%%
        
    sumoRUN=strcat(pathtoSUMOBIN,"sumo
        --mesosim --no-step-log --output-prefix ",num2str(k)," -n ",...
                    pathToNetwork_a,mesoNet, ...
                    " -b ",num2str(beginSimTime),...
                    " -e ",num2str(endSimTime+500),...
                    " --load-state
        ",pathtoCaseOutput,"/",num2str(iter-1),"state.xml" , ...
                    " --save-state.times ", num2str(endSimTime), ...
                    " --save-state.files ",
        pathtoCaseOutput,"/",num2str(iter),"state.xml", ...
                    " -r ", pathtoCaseOutput,"/", num2str(k),
        "upd_ODTrips.trips.xml",...
                    " --additional-files ", pathtoCaseOutput,"/",
        additionalName,...
                    "  --xml-validation never",...
                    " --device.rerouting.probability
        ",string(rerouteProb),...
                    " --seed ",  num2str(seedNN));
                [~,~] =  system(sumoRUN);  % [~,~] =  suppresses any
        console outcome. Not recommended when running first time
      
    
      %%%%%%%%%%%%%%%%
            Read Output %%%%%%%%%%%%%%%%
    Data2csv =
        strcat("python ", pathToSUMOtools,"/tools/xml/xml2csv.py",...
            " ", pathtoCaseOutput,'/' ,loopDataName , " -o ",
        pathtoCaseOutput,'/' , loopDataName,".csv",...
            " -x ", pathToSUMOtools,'data/xsd/det_e1meso_file.xsd');
        system(Data2csv);
    newStr =
        strrep(pathtoCaseOutput,"\","");
        mDir = char(newStr);
        KKname=strcat(mDir,'/',loopDataName,".csv");
        simulated_tripsInTable = readtable(KKname);
simulated_tripsInTable(simulated_tripsInTable.interval_end>endSimTime+1,:)
        =[];
        
        % The final step is to aggregate the counts per link (so that we
        do can
        % estimate per link flow and not per lane). 
        mm=simulated_tripsInTable.interval_id;
        newStr = split(mm,'_');
        myEdges = newStr(:,2);
        simulated_tripsInTable.EdgeID = myEdges;
        G = findgroups(simulated_tripsInTable.EdgeID);
        
        AllPeriodEdgesFlows = unique(myEdges);
        AllPeriodEdgesFlows(:,2) =
        num2cell(splitapply(@sum,simulated_tripsInTable.interval_entered,G));
      
    
      I hope this helps!
    Best, 
        
    Manos
        
    -- 
Chaniotakis Manos (Emmanouil)
Technical University of Munich
Department of Civil, Geo and Environmental Engineering
Chair of Transportation Systems Engineering
e:mail: m.chaniotakis@xxxxxx
website: https://www.tse.bgu.tum.de/en/staff/mchaniotakis/
Tel: +49 89 28910461
    On 29/10/2018 16:07, Jane Cheung wrote:
    
    
      
      ![]()
Hi guys, there is
        one problem that 
 I would like to listen to your
        suggestion. Appreciated in advance!
        
        
        The thing is that  how to simulate  different scenarios,
          one by one. It does not need to click the renewed
          configuration. In other would, the route files or other files
          could be generated automatically and the new .sumocfg could be
          generated. 
        
        
        There is an original configuration in my file and run it,
          the interested variables (like the mean travel time in one
          edge) in the whole solution duration could be got .Then, 
          other options would be done (by some TRACI or some other
          methods) to modify the  route files or related files and the
          renewed one could be generated (like the density is increasing
          or the width of the edges is becoming larger or some others)
          by TRACI , then, call the SUMO  command line
            again, run the .sumocfg again. Repeat the simulation
            again and again to the get the  changing trend of
            variable you are interested in. 
        
          
        Simplely, could some options be called to renew the
          route.xml  automatically?
        
        
        Thanks in advance!
        
        
        Best regards!
        
        
        Jane 
      
      
      
      _______________________________________________
sumo-user mailing list
sumo-user@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://www.eclipse.org/mailman/listinfo/sumo-user