<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CocoWrapper;
using Common;
using Algorithm;
using System.Xml;
using System.Xml.Serialization;
using System.IO;
using Node;

namespace CocoClusterApp
{
    class Program
    {

        public const int BudgetMultiplier = 100000;
        public const int IndependentRestarts = 10000;
        public const int RandomSeed = 12;
        public static Problem Problem;

        static void Main(string[] args)
        {
            if (args.Length < 3)
            {
                Console.WriteLine("CocoSingleCpuApp <Dim1[,Dim2,Dim3...]> <FunctionsFrom> <FunctionsTo>");
                return;
            }
            
            var nodeParamsSerializer = new XmlSerializer(typeof(NodeParameters));
            var psoParamsSerializer = new XmlSerializer(typeof(PsoParameters));
            NodeParameters nodeParams;
            PsoParameters psoParams;
            using (var nodeFileReader = new StreamReader("nodeParams.xml"))
            {
                nodeParams = (NodeParameters)nodeParamsSerializer.Deserialize(nodeFileReader);
            }
            using (var psoFileReader = new StreamReader("psoParams.xml"))
            {
                psoParams = (PsoParameters)psoParamsSerializer.Deserialize(psoFileReader);
            }
            MachineManager machineManager = new MachineManager(nodeParams.Ip, nodeParams.Ports.ToArray(), nodeParams.NrOfVCpu);
            if (nodeParams.PeerAddress != null)
            {
                machineManager.Register(nodeParams.PeerAddress);
            }


            string dims = args[0];
            var functionsFrom = int.Parse(args[1]);
            var functionsTo = int.Parse(args[2]);
            RandomGenerator randomGenerator = RandomGenerator.GetInstance(RandomSeed);
            CocoLibraryWrapper.cocoSetLogLevel("info");

            var functionsToOptimize = new List<string>();
            for (var i = functionsFrom; i <= functionsTo; i++)
            {
                functionsToOptimize.Add(String.Format("f{0:D3}", i));
            }
            Console.WriteLine("Running the example experiment... (might take time, be patient)");
            try
            {

                /* Set some options for the observer. See documentation for other options. */
                var observerOptions =
                    "result_folder: PSO_on_bbob_" +
                    DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString()
                    + " algorithm_name: PSO"
                    + " algorithm_info: \"A simple Random search algorithm\"";<commit_msg>waiting for registration<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CocoWrapper;
using Common;
using Algorithm;
using System.Xml;
using System.Xml.Serialization;
using System.IO;
using Node;

namespace CocoClusterApp
{
    class Program
    {

        public const int BudgetMultiplier = 100000;
        public const int IndependentRestarts = 10000;
        public const int RandomSeed = 12;
        public static Problem Problem;

        static void Main(string[] args)
        {
            if (args.Length < 3)
            {
                Console.WriteLine("CocoSingleCpuApp <Dim1[,Dim2,Dim3...]> <FunctionsFrom> <FunctionsTo>");
                return;
            }
            
            var nodeParamsSerializer = new XmlSerializer(typeof(NodeParameters));
            var psoParamsSerializer = new XmlSerializer(typeof(PsoParameters));
            NodeParameters nodeParams;
            PsoParameters psoParams;
            using (var nodeFileReader = new StreamReader("nodeParams.xml"))
            {
                nodeParams = (NodeParameters)nodeParamsSerializer.Deserialize(nodeFileReader);
            }
            using (var psoFileReader = new StreamReader("psoParams.xml"))
            {
                psoParams = (PsoParameters)psoParamsSerializer.Deserialize(psoFileReader);
            }
            MachineManager machineManager = new MachineManager(nodeParams.Ip, nodeParams.Ports.ToArray(), nodeParams.NrOfVCpu);
            if (nodeParams.PeerAddress != null)
            {
                machineManager.Register(nodeParams.PeerAddress);
            }


            string dims = args[0];
            var functionsFrom = int.Parse(args[1]);
            var functionsTo = int.Parse(args[2]);
            RandomGenerator randomGenerator = RandomGenerator.GetInstance(RandomSeed);
            CocoLibraryWrapper.cocoSetLogLevel("info");

            var functionsToOptimize = new List<string>();
            for (var i = functionsFrom; i <= functionsTo; i++)
            {
                functionsToOptimize.Add(String.Format("f{0:D3}", i));
            }
            Console.WriteLine("Press any key on the keyboard when ready...");
            Console.ReadKey();
            Console.WriteLine("Running the example experiment... (might take time, be patient)");
            try
            {

                /* Set some options for the observer. See documentation for other options. */
                var observerOptions =
                    "result_folder: PSO_on_bbob_" +
                    DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString()
                    + " algorithm_name: PSO"
                    + " algorithm_info: \"A simple Random search algorithm\"";
{'fraction_non_alphanumeric': 0.09152110625909753, 'fraction_numerical': 0.008005822416302766, 'mean_word_length': 2.0623955431754877, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, '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': '129928', 'n_tokens_mistral': 1411, 'n_tokens_neox': 1336, 'n_words': 322}