<commit_before>

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <unistd.h>

#include "parseArgs/parseArgs.h"
#include "parseArgs/paConfig.h"

#include "logMsg/logMsg.h"

#include "au/string.h" // au::str()
#include "au/Cronometer.h"  // au::Cronometer
#include "au/CommandLine.h" // au::CommandLine



static const char* manShortDescription =  "Simple command line tool to generate fake data for simple_mobility demo\n";
static const char* manSynopsis = "simple_mobility_generator [-commands] [-rate X] [-users X] [-period X] [-progressive] [-fix_position]\n";

int users;
int rate;
int period;
bool progresive;
bool commands;
bool fix_position;

PaArgument paArgs[] =
{
	{ "-users"        , &users,          "",  PaInt,     PaOpt,       100000,    100,  100000000,         "Number of users" },    
	{ "-rate"         , &rate,           "",  PaInt,     PaOpt,        10000,    100,    1000000,         "CDRs per second" },    
	{ "-period"       , &period,         "",  PaInt,     PaOpt,          100,     10,      86400,         "Period in seconds" },    
	{ "-progressive"  , &progresive,     "",  PaBool,    PaOpt,        false,  false, true,               "Generate cdrs in sequential order for all the users"},
	{ "-commands"     , &commands,       "",  PaBool,    PaOpt,        false,  false, true,               "Generate commands to create user-areas (instead of cdrs)"},
	{ "-fix_position" , &fix_position,   "",  PaBool,    PaOpt,        false,  false, true,               "Use fix positions for all users"},
	PA_END_OF_ARGS
};

int logFd = -1;

int current_user;


class Position
{
    
public:
    
    double x;
    double y;
    
    Position()
    {
        x = 0;
        y = 0;
    }
    
    Position( double _x , double _y )
    {
        x = _x;
        y = _y;
    }

    void set( double _x , double _y )
    {
        x = _x;
        y = _y;
    }
    
    void set_in_limits( )
    {
        set_in_limits(&x);
        set_in_limits(&y);
    }    
    
private:
    
    void set_in_limits( double* var )
    {
        if( *var <  0)
            *var = 0;
        if( *var > 1000 )
            *var = 1000;
    }    

};

Position getHome( size_t user )
{
    if( fix_position )
        return Position ( 10 , 10 );
    
    return Position( 10 * ( user%100 )  , 1000 - 10 * ( user%100 ) );
}

Position getWork( size_t user )
{
    if( fix_position )
        return Position ( 900 , 900 );

    return Position( 1000 - 10 * ( user%100 ) , 10 * ( user%100 )  );
}

Position getPosition( size_t user )
{
    if( time(NULL)%period < (period/2) )
        return getHome(user);
    else
        return getWork(user);
    
    return Position( rand()%1000 , rand()%1000 );
}


size_t getUser()
{<commit_msg>SAMSON-140 Minor update over simple_mobility_generator<commit_after>

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <unistd.h>

#include "parseArgs/parseArgs.h"
#include "parseArgs/paConfig.h"

#include "logMsg/logMsg.h"

#include "au/string.h" // au::str()
#include "au/Cronometer.h"  // au::Cronometer
#include "au/CommandLine.h" // au::CommandLine



static const char* manShortDescription =  "Simple command line tool to generate fake data for simple_mobility demo\n";
static const char* manSynopsis = "simple_mobility_generator [-commands] [-rate X] [-users X] [-period X] [-progressive] [-fix_position]\n";

int users;
int rate;
int period;
bool progresive;
bool commands;
bool fix_position;

PaArgument paArgs[] =
{
	{ "-users"        , &users,          "",  PaInt,     PaOpt,       100000,    100,  100000000,         "Number of users" },    
	{ "-rate"         , &rate,           "",  PaInt,     PaOpt,        10000,    100,    1000000,         "CDRs per second" },    
	{ "-period"       , &period,         "",  PaInt,     PaOpt,          100,     10,      86400,         "Period in seconds" },    
	{ "-progressive"  , &progresive,     "",  PaBool,    PaOpt,        false,  false, true,               "Generate cdrs in sequential order for all the users"},
	{ "-commands"     , &commands,       "",  PaBool,    PaOpt,        false,  false, true,               "Generate commands to create user-areas (instead of cdrs)"},
	{ "-fix_position" , &fix_position,   "",  PaBool,    PaOpt,        false,  false, true,               "Use fix positions for all users"},
	PA_END_OF_ARGS
};

int logFd = -1;

int current_user;


class Position
{
    
public:
    
    double x;
    double y;
    
    Position()
    {
        x = 0;
        y = 0;
    }
    
    Position( double _x , double _y )
    {
        x = _x;
        y = _y;
    }

    void set( double _x , double _y )
    {
        x = _x;
        y = _y;
    }
    
    void set_in_limits( )
    {
        set_in_limits(&x);
        set_in_limits(&y);
    }    
    
private:
    
    void set_in_limits( double* var )
    {
        if( *var <  0)
            *var = 0;
        if( *var > 1000 )
            *var = 1000;
    }    

};

Position getHome( size_t user )
{
    if( fix_position )
        return Position ( 10 , 10 );
    
    return Position( 10 * ( user%100 )  , 1000 - 10 * ( user%100 ) );
}

Position getWork( size_t user )
{
    if( fix_position )
        return Position ( 900 , 900 );

    return Position( 1000 - 10 * ( user%100 ) , 10 * ( user%100 )  );
}

Position getPosition( size_t user )
{
    int p = time(NULL)%period;
    
    if(  p < (period/2) )
        return getHome(user);
    else
        return getWork(user);
    
    return Position( rand()%1000 , rand()%1000 );
}


size_t getUser()
{
{'fraction_non_alphanumeric': 0.13372717508055854, 'fraction_numerical': 0.03741496598639456, 'mean_word_length': 1.928197064989518, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4442321', 'n_tokens_mistral': 2092, 'n_tokens_neox': 1906, 'n_words': 509}