1
0
mirror of https://gitlab.com/klmp200/LO41.git synced 2024-11-22 08:43:22 +00:00

experimental scenario generation script

This commit is contained in:
Aethor 2018-06-18 17:35:05 +02:00
parent 76f0c2e0ed
commit 4407c99b77
2 changed files with 260 additions and 12 deletions

231
Scripts/.gitignore vendored Normal file
View File

@ -0,0 +1,231 @@
# Created by .ignore support plugin (hsz.mobi)
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/dictionaries
.idea/**/shelf
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# CMake
cmake-build-debug/
cmake-build-release/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
### Vim template
# Swap
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-v][a-z]
[._]sw[a-p]
# Session
Session.vim
# Temporary
.netrwhist
*~
# Auto-generated tag files
tags
# Persistent undo
[._]*.un~
### C template
# Prerequisites
*.d
# Object files
*.o
*.ko
*.obj
*.elf
# Linker output
*.ilk
*.map
*.exp
# Precompiled Headers
*.gch
*.pch
# Libraries
*.lib
*.a
*.la
*.lo
# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib
# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex
# Debug files
*.dSYM/
*.su
*.idb
*.pdb
# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf
### macOS template
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### Emacs template
# -*- mode: gitignore; -*-
*~
\#*\#
/.emacs.desktop
/.emacs.desktop.lock
*.elc
auto-save-list
tramp
.\#*
# Org-mode
.org-id-locations
*_archive
# flymake-mode
*_flymake.*
# eshell files
/eshell/history
/eshell/lastdir
# elpa packages
/elpa/
# reftex files
*.rel
# AUCTeX auto folder
/auto/
# cask packages
.cask/
dist/
# Flycheck
flycheck_*.el
# server auth directory
/server/
# projectiles files
.projectile
# directory configuration
.dir-locals.el
### SublimeText template
# Cache files for Sublime Text
*.tmlanguage.cache
*.tmPreferences.cache
*.stTheme.cache
# Workspace files are user-specific
*.sublime-workspace
# Project files should be checked into the repository, unless a significant
# proportion of contributors will probably not be using Sublime Text
# *.sublime-project
# SFTP configuration file
sftp-config.json
# Package control specific files
Package Control.last-run
Package Control.ca-list
Package Control.ca-bundle
Package Control.system-ca-bundle
Package Control.cache/
Package Control.ca-certs/
Package Control.merged-ca-bundle
Package Control.user-ca-bundle
oscrypto-ca-bundle.crt
bh_unicode_properties.cache
# Sublime-github package stores a github token in this file
# https://packagecontrol.io/packages/sublime-github
GitHub.sublime-settings
# Scenario files
*.txt

41
Scripts/generate.pl Normal file → Executable file
View File

@ -1,27 +1,35 @@
#!/bin/perl
use strict;
use warnings;
use List::Util qw/shuffle/;
die "Usage : generate.pl agents_number [floor_number]\nagents number range from 2 to 500\n" if @ARGV == 0;
my $total_nb = $ARGV[0];
die "Error : stupid amount of agents ($total_nb)\n" if $total_nb < 2;
my $visitors_nb = int($total_nb / 2);
my $residents_nb = $total_nb - $visitors_nb;
my $floor_number = @ARGV > 2 ? $ARGV[1] : 25;
my $visitors_output_file_name = "visitors.txt";
my $residents_output_file_name = "residents.txt";
my $visitors_db_filename = "visitors.db";
my $residents_db_filename = "residents.db";
my @visitors = ();
my @residents = ();
my $total_nb = $ARGV[0];
my $visitors_nb = $ARGV[0]; #todo : calculer
my $residents_nb = $ARGV[1];
my $output_file_name = $ARGV[2] eq "" ? "out" : $ARGV[2];
open(my $visitors_db_file, $visitors_db_filename) or die "Error : no visitors database found \n";
open(my $residents_db_file, $residents_db_filename) or die "Error : no residents database found \n";
while(my $line = <$visitors_db_file>){
#chomp($line);
chomp($line);
push(@visitors, $line);
}
while(my $line = <$residents_db_file>){
#chomp($line);
push(@residents, $line);
chomp($line);
push(@residents, $line) if(@residents < $residents_nb);
}
die "Database is not big enough for $visitors_nb visitors\n" if @visitors < $visitors_nb;
@ -30,14 +38,23 @@ die "Database is not big enough for $residents_nb residents" if @residents < $re
@visitors = shuffle(@visitors);
@residents = shuffle(@residents);
open(my $output_file, '>'.$output_file_name) or die "Error : couldn't create output file.";
open(my $visitors_output_file, '>', $visitors_output_file_name) or die "Error : couldn't create visitors output file.";
open(my $residents_output_file, '>', $residents_output_file_name) or die "Error : couldn't create residents output file.";
for(my $i = 0; $i < )
foreach (@visitors){
print;
for(my $i = 0; $i < $visitors_nb; $i += 1){
print $visitors_output_file $visitors[$i] . ";" .
$residents[rand $residents_nb] . "\n";
}
for(my $i = 0; $i < $residents_nb; $i += 1){
print $residents_output_file $residents[$i] . ";" .
(int(rand(25)) + 1) . ";" .
(int(rand(25 + 1))) . "\n";
}
close $visitors_db_file;
close $residents_db_file;
close $visitors_output_file;
close $residents_output_file;