Example #1
0
        static void Main( string[] args )
        {
            // 環境設定
            // 未指定用(デフォルト)
            Configuration.Seed = 0;
            Configuration.NoiseRate = 0;
            Configuration.ImbalanceLevel = 0;
            Configuration.NoiseWidth = 0;
            Configuration.ASName = "nnn";
            Configuration.L = 6;
            Configuration.ExploitEnv = new MultiplexerEnvironment( 6 );
            Environment Env = new MultiplexerEnvironment( 6 );
            Configuration.Theta_sub = 20;
            Configuration.ExpThreshold = 20;
            Configuration.DifferenceSigma = 75;
            Configuration.LookBackSigma = 15;
            Configuration.DifferenceEpsilon = 75;
            Configuration.LookBackEpsilon = 15;
            Configuration.P_sharp = 0.35;

            string EnvName = "hoge";
            string Comment = "hoge";

            for(int i = 0; i < args.Length; i++)
            {
                if(args[i] == "-s" | args[i] == "-S" | args[i] == "--Seed" | args[i] == "--seed")
                {
                    Configuration.Seed = int.Parse( args[++i] );
                }

                if(args[i] == "-c" | args[i] == "-C" | args[i] == "--Complexity" | args[i] == "--complexity")
                {
                    Configuration.NoiseRate = double.Parse( args[++i] );
                    Configuration.ImbalanceLevel = ( int )double.Parse( args[i] );	// int型に変換
                    Configuration.NoiseWidth = double.Parse( args[i] );
                }

                if(args[i] == "-a" | args[i] == "-A" | args[i] == "--as" | args[i] == "--As")
                {
                    Configuration.ASName = args[++i];
                }

                if( args[i] == "-e" | args[i] == "-E" | args[i] == "--env" | args[i] == "--Env" )
                {
                    EnvName = args[++i];
                    // 環境選択
                    //if( args[i] == "alternating" )
                    //{
                    //    // オルタネイティング(正解・不正解反転)ノイズ
                    //    env = new alternatingnoisemultiplexerenvironment( configuration.l, configuration.noiserate );
                    //}
                    //else if( args[i] == "alternating_noise_gauss" )
                    //{
                    //    env = new alternating_noisegaussianenvironment( configuration.l, configuration.noiserate );
                    //}
                    //else if( args[i] == "alternating_scattergauss" )
                    //{
                    //    env = new alternating_scattergaussianenvironment( configuration.l, configuration.noiserate );
                    //}
                    //else if( args[i] == "alternating_randomsigma_gauss" )
                    //{
                    //    env = new alternating_randomsigmaenvironment( configuration.l, configuration.noiserate );
                    //}
                    //else if( args[i] == "imbalance" )
                    //{
                    //    // class-imbalance
                    //    env = new classimbalanceenvironment( configuration.l, configuration.imbalancelevel );
                    //}
                    //else if( args[i] == "biasedreward" )
                    //{
                    //    // biasedreward(ノイズ無し)
                    //    env = new biasedrewardenvironment( configuration.l, 0 );
                    //}
                    //else if( args[i] == "biasedgauss" )
                    //{
                    //    // biasedreward(ノイズ無し)
                    //    env = new biasedgaussianrewardenvironment( configuration.l, configuration.noisewidth );
                    //}
                    //else if( args[i] == "biasedgauss_noise_gauss" )
                    //{
                    //    env = new biasedgaussian_noisegaussianenvironment( configuration.l, configuration.noisewidth );
                    //}
                    //else if( args[i] == "biasedgauss_scattergauss" )
                    //{
                    //    env = new biasedgaussian_scattergaussianenvironment( configuration.l, configuration.noisewidth );
                    //}
                    //else if( args[i] == "biasedgauss_randomsigma_gauss" )
                    //{
                    //    env = new biasedgaussian_randomsigmaenvironment( configuration.l, configuration.noisewidth );
                    //}
                     if( args[i] == "Uniformity" )
                    {
                        // 同じ大きさのノイズ
                        Env = new UniformityMultiplexerEnvironment( Configuration.L, Configuration.NoiseWidth );
                    }
                    //else if( args[i] == "CorrelateNoise" )
                    //{
                    //    /// Addressbitsと比例ノイズ
                    //    Env = new CorrelatedNoiseMultiplexerEnvironment( Configuration.L, Configuration.NoiseWidth );
                    //}
                    else if( args[i] == "Noise" )
                    {
                        // Addressbitsの大きさと関連ノイズ(偏り)
                        Env = new NoiseMultiplexerEnvironment( Configuration.L, Configuration.NoiseWidth );
                    }
                    //else if( args[i] == "ScatterSituation" )
                    //{
                    //    // situation毎にばらつきが違う(比例)
                    //    Env = new ScatterSituationBinaryEnvironment( Configuration.L, Configuration.NoiseWidth );
                    //}
                    //else if( args[i] == "PM" )
                    //{
                    //    // プラスまたはマイナスNoiseWidth固定のばらつき(検証目的)
                    //    Env = new PlusMinusNoiseEnvironment( Configuration.L, Configuration.NoiseWidth );
                    //}
                    else if( args[i] == "Gauss" )
                    {
                        Env = new GaussianNoiseEnvironment( Configuration.L, Configuration.NoiseWidth );
                    }
                    //else if( args[i] == "ScatterGauss" )
                    //{
                    //    Env = new ScatterGaussianNoiseEnvironment( Configuration.L, Configuration.NoiseWidth );
                    //}
                    //else if( args[i] == "Noise_Gauss" )
                    //{
                    //    Env = new Noise_GaussianNoiseEnvironment( Configuration.L, Configuration.NoiseWidth );
                    //}
                    //else if( args[i] == "RandomSigma_Gauss" )
                    //{
                    //    Env = new RandomSigmaGaussianNoiseEnvironment( Configuration.L, Configuration.NoiseWidth );
                    //}
                    //else if( args[i] == "Gauss_0" )
                    //{
                    //    Env = new GaussianNoiseEnvironment_0( Configuration.L, Configuration.NoiseWidth );
                    //}
                    //else if( args[i] == "ScatterGauss_0" )
                    //{
                    //    Env = new ScatterGaussianNoiseEnvironment_0( Configuration.L, Configuration.NoiseWidth );
                    //}
                    //else if( args[i] == "Noise_Gauss_0" )
                    //{
                    //    Env = new Noise_GaussianNoiseEnvironment_0( Configuration.L, Configuration.NoiseWidth );
                    //}
                    //else if( args[i] == "RandomSigma_Gauss_0" )
                    //{
                    //    Env = new RandomSigmaGaussianNoiseEnvironment_0( Configuration.L, Configuration.NoiseWidth );
                    //}
                    else
                    {
                        // 普通のMultiplexer問題
                        Env = new MultiplexerEnvironment( Configuration.L );
                    }
                }

                if(args[i] == "--ts" | args[i] == "--Ts" | args[i] == "--ThetaSub")
                {
                    Configuration.Theta_sub = int.Parse( args[++i] );
                    Configuration.ExpThreshold = int.Parse( args[i] );
                }

                if(args[i] == "--ds" | args[i] == "--Ds" | args[i] == "--DifferenceSigma" )
                {
                    // 分散差分許容範囲
                    Configuration.DifferenceSigma = double.Parse( args[++i] );
                }

                if( args[i] == "--ls" | args[i] == "--Ls" | args[i] == "--LookbackSigma" )
                {
                    // 分散が安定したか見返す数
                    Configuration.LookBackSigma = int.Parse( args[++i] );
                }

                if( args[i] == "--de" | args[i] == "--De" | args[i] == "--DifferenceEpsilon" )
                {
                    // 各分類子の差分許容範囲
                    Configuration.DifferenceEpsilon = double.Parse( args[++i] );
                }

                if( args[i] == "--le" | args[i] == "--Le" | args[i] == "--LookbackEpsilon" )
                {
                    // 各分類子のepsilon(分散)が安定したか見返す数
                    Configuration.LookBackEpsilon = int.Parse( args[++i] );
                }

                if(args[i] == "--cm" | args[i] == "--comment" | args[i] == "--Comment")
                {
                    Comment = args[++i];
                }

                if(args[i] == "-l" | args[i] == "--Length" | args[i] == "--length")
                {
                    // situation(Condition)の長さ
                    Configuration.L = int.Parse( args[++i] );
                    Configuration.ExploitEnv = new MultiplexerEnvironment( Configuration.L );
                }

                if( args[i] == "--ps" | args[i] == "--Ps" | args[i] == "--PSharp" )
                {
                    Configuration.P_sharp = double.Parse( args[++i] );
                }
            }

            // 変数設定
            Config( args );

            // フォルダ名用時間取得
            DateTime dt = DateTime.Now;

            // フォルダ指定
            Configuration.pppp = dt.Year + "" + dt.Month.ToString( "D2" ) + "" + dt.Day.ToString( "D2" );
            Configuration.pppp +=  "_" + Comment + "_" + Configuration.L + "_" + Configuration.P_sharp + "_" + Configuration.Theta_sub + "_" + Configuration.DifferenceSigma + "_" + Configuration.LookBackSigma;
            string Path = "./" + Configuration.pppp + "/" + Configuration.NoiseWidth + "/";

            Path += dt.Year + "" + dt.Month.ToString( "D2" ) + "" + dt.Day.ToString( "D2" ) + "" + dt.Hour.ToString( "D2" ) + "" + dt.Minute.ToString( "D2" ) + "" + dt.Second.ToString( "D2" );
            Path += "_s" + Configuration.Seed;
            Path += "_c" + Configuration.NoiseWidth;
            Path += "_l" + Configuration.L;
            Path += "_a" + Configuration.ASName;
            Path += "_e" + EnvName;
            Path += "_ts" + Configuration.Theta_sub;
            Path += "_ds" + Configuration.DifferenceSigma;
            Path += "_ls" + Configuration.LookBackSigma;
            Path += "_de" + Configuration.DifferenceEpsilon;
            Path += "_le" + Configuration.LookBackEpsilon;
            Path += "_ps" + Configuration.P_sharp;
            //foreach( string parameter in args )
            //{
            //	Path += ( "_" + parameter );
            //}

            System.IO.DirectoryInfo di = System.IO.Directory.CreateDirectory( Path );
            System.IO.Directory.SetCurrentDirectory( Path );

            //Configuration.ESW = new StreamWriter( "./epsilon_" + Configuration.Seed + "CnoiseWidth_" + Configuration.NoiseWidth
            //	+ "AS_" + Configuration.ASName + "ET_" + Configuration.ExpThreshold + "DS_" + Configuration.DifferenceSigma + "LS_" + Configuration.LookBackSigma
            //	+ "DE_" + Configuration.DifferenceEpsilon + "LE_" + Configuration.LookBackEpsilon + ".csv", true, System.Text.Encoding.GetEncoding( "shift_jis" ) );

            Configuration.Problem_1000 = new StreamWriter("./problem_1000" +/* Configuration.Seed + "CnoiseWidth_" + Configuration.NoiseWidth
                + "AS_" + Configuration.ASName + "ET_" + Configuration.ExpThreshold + "DS_" + Configuration.DifferenceSigma + "LS_" + Configuration.LookBackSigma
                + "DE_" + Configuration.DifferenceEpsilon + "LE_" + Configuration.LookBackEpsilon +*/ ".csv", true, System.Text.Encoding.GetEncoding("shift_jis"));
            Configuration.Problem_0100 = new StreamWriter("./problem_0100" + ".csv", true, System.Text.Encoding.GetEncoding("shift_jis"));

            Configuration.Problem_0010 = new StreamWriter("./problem_0010" + ".csv", true, System.Text.Encoding.GetEncoding("shift_jis"));
            Configuration.Problem_0001 = new StreamWriter("./problem_0001" + ".csv", true, System.Text.Encoding.GetEncoding("shift_jis"));

            Configuration.Problem_1_00 = new StreamWriter("./problem_1#00" + ".csv", true, System.Text.Encoding.GetEncoding("shift_jis"));

            Configuration.Problem_1100 = new StreamWriter("./problem_1100" + ".csv", true, System.Text.Encoding.GetEncoding("shift_jis"));

            Configuration.Problem__100 = new StreamWriter("./problem_#100" + ".csv", true, System.Text.Encoding.GetEncoding("shift_jis"));

            Configuration.Problem = new StreamWriter("./problem" + ".csv", true, System.Text.Encoding.GetEncoding("shift_jis"));

            Configuration.ESW = new StreamWriter( "./epsilon_" + Configuration.Seed + "CnoiseWidth_" + Configuration.NoiseWidth
                + "AS_" + "CS" + "ET_" + Configuration.ExpThreshold + "DS_" + Configuration.DifferenceSigma + "LS_" + Configuration.LookBackSigma
                + "DE_" + Configuration.DifferenceEpsilon + "LE_" + Configuration.LookBackEpsilon + ".csv", true, System.Text.Encoding.GetEncoding( "shift_jis" ) );

            //Configuration.Problem = new StreamWriter( "./problem_" + Configuration.Seed + "CnoiseWidth_" + Configuration.NoiseWidth
            //	+ "AS_" + "CS" + "ET_" + Configuration.ExpThreshold + "DS_" + Configuration.DifferenceSigma + "LS_" + Configuration.LookBackSigma
            //	+ "DE_" + Configuration.DifferenceEpsilon + "LE_" + Configuration.LookBackEpsilon + ".csv", true, System.Text.Encoding.GetEncoding( "shift_jis" ) );
            Configuration.Delete_1_00 = new StreamWriter("./Delete_1#00" + ".csv", true, System.Text.Encoding.GetEncoding("shift_jis"));

            Configuration.Delete_0100 = new StreamWriter("./Delete_0100" + ".csv", true, System.Text.Encoding.GetEncoding("shift_jis"));

            Configuration.Delete_0010 = new StreamWriter("./Delete_0010" + ".csv", true, System.Text.Encoding.GetEncoding("shift_jis"));

            Configuration.Delete_0001 = new StreamWriter("./Delete_0001" + ".csv", true, System.Text.Encoding.GetEncoding("shift_jis"));

            // 初期化
            // Population初期化
            Population P = new NormalPopulation( Configuration.N );

            //if(Configuration.ASName == "CS")
            //{
            //	P = new SigmaNormalPopulation( Configuration.N );
            //}

            // 試行

            Experiment( Env, P );
        }
Example #2
0
        static void Main(string[] args)
        {
            // 環境設定
            // 未指定用(デフォルト)
            Configuration.Seed           = 0;
            Configuration.NoiseRate      = 0;
            Configuration.ImbalanceLevel = 0;
            Configuration.NoiseWidth     = 0;
            Configuration.ASName         = "CS";
            Configuration.L = 8;
            //Configuration.ExploitEnv = new MultiplexerEnvironment( 6 );
            Environment Env = new ReadCsvEnvironment( );

            Configuration.Theta_sub         = 20;
            Configuration.ExpThreshold      = 20;
            Configuration.DifferenceSigma   = 0.1;          //for real data  0~1.0
            Configuration.LookBackSigma     = 15;
            Configuration.DifferenceEpsilon = 0.1;          //for real data 0.0~1.0
            Configuration.LookBackEpsilon   = 15;
            Configuration.P_sharp           = 0.35;
            Configuration.CoverPersentage   = 0.155;      //重なる部分の許す範囲 0~1.0


            string EnvName = "hoge";
            string Comment = "hoge";

            for (int i = 0; i < args.Length; i++)
            {
                if (args[i] == "-s"   | args[i] == "-S" | args[i] == "--Seed" | args[i] == "--seed")
                {
                    Configuration.Seed = int.Parse(args[++i]);
                }

                if (args[i] == "-c" | args[i] == "-C" | args[i] == "--Complexity" | args[i] == "--complexity")
                {
                    Configuration.NoiseRate      = double.Parse(args[++i]);
                    Configuration.ImbalanceLevel = ( int )double.Parse(args[i]);                        // int型に変換

                    Configuration.NoiseWidth = double.Parse(args[i]);
                }

                if (args[i] == "-a" | args[i] == "-A" | args[i] == "--as" | args[i] == "--As")
                {
                    Configuration.ASName = args[++i];
                }

                if (args[i] == "-e" | args[i] == "-E" | args[i] == "--env" | args[i] == "--Env")
                {
                    EnvName = args[++i];

                    if (args[i] == "csv")
                    {
                        Env = new ReadCsvEnvironment();
                    }

                    else
                    {
                        // 普通のMultiplexer問題
                        //Env = new MultiplexerEnvironment( Configuration.L );
                    }
                }

                if (args[i] == "--ts" | args[i] == "--Ts" | args[i] == "--ThetaSub")
                {
                    Configuration.Theta_sub    = int.Parse(args[++i]);
                    Configuration.ExpThreshold = int.Parse(args[i]);
                }

                if (args[i] == "--ds" | args[i] == "--Ds" | args[i] == "--DifferenceSigma")
                {
                    // 分散差分許容範囲
                    Configuration.DifferenceSigma = double.Parse(args[++i]);
                }

                if (args[i] == "--ls" | args[i] == "--Ls" | args[i] == "--LookbackSigma")
                {
                    // 分散が安定したか見返す数
                    Configuration.LookBackSigma = int.Parse(args[++i]);
                }

                if (args[i] == "--de" | args[i] == "--De" | args[i] == "--DifferenceEpsilon")
                {
                    // 各分類子の差分許容範囲
                    Configuration.DifferenceEpsilon = double.Parse(args[++i]);
                }

                if (args[i] == "--le" | args[i] == "--Le" | args[i] == "--LookbackEpsilon")
                {
                    // 各分類子のepsilon(分散)が安定したか見返す数
                    Configuration.LookBackEpsilon = int.Parse(args[++i]);
                }

                if (args[i] == "--cm" | args[i] == "--comment" | args[i] == "--Comment")
                {
                    Comment = args[++i];
                }

                if (args[i] == "-l" | args[i] == "--Length" | args[i] == "--length")
                {
                    // situation(Condition)の長さ
                    Configuration.L = int.Parse(args[++i]);
                    //Configuration.ExploitEnv = new MultiplexerEnvironment( Configuration.L );
                }

                if (args[i] == "--ps" | args[i] == "--Ps" | args[i] == "--PSharp")
                {
                    Configuration.P_sharp = double.Parse(args[++i]);
                }

                if (args[i] == "--per" | args[i] == "-percentage")
                {
                    Configuration.CoverPersentage = double.Parse(args[++i]);
                }
            }


            // 変数設定
            Config(args);

            // フォルダ名用時間取得
            DateTime dt = DateTime.Now;

            // フォルダ指定
            Configuration.pppp  = dt.Year + "" + dt.Month.ToString("D2") + "" + dt.Day.ToString("D2");
            Configuration.pppp += "_" + Comment + "_" + Configuration.L + "_" + Configuration.P_sharp + "_" + Configuration.Theta_sub + "_" + Configuration.DifferenceSigma + "_" + Configuration.LookBackSigma;
            string Path = "./" + Configuration.pppp + "/" + Configuration.NoiseWidth + "/";

            Path += dt.Year + "" + dt.Month.ToString("D2") + "" + dt.Day.ToString("D2") + "" + dt.Hour.ToString("D2") + "" + dt.Minute.ToString("D2") + "" + dt.Second.ToString("D2");
            Path += "_s" + Configuration.Seed;
            Path += "_c" + Configuration.NoiseWidth;
            Path += "_l" + Configuration.L;
            Path += "_a" + Configuration.ASName;
            Path += "_e" + EnvName;
            Path += "_ts" + Configuration.Theta_sub;
            Path += "_ds" + Configuration.DifferenceSigma;
            Path += "_ls" + Configuration.LookBackSigma;
            Path += "_de" + Configuration.DifferenceEpsilon;
            Path += "_le" + Configuration.LookBackEpsilon;
            Path += "_ps" + Configuration.P_sharp;
            Path += "_per" + Configuration.CoverPersentage;
            //foreach( string parameter in args )
            //{
            //	Path += ( "_" + parameter );
            //}

            System.IO.DirectoryInfo di = System.IO.Directory.CreateDirectory(Path);
            System.IO.Directory.SetCurrentDirectory(Path);



            Configuration.Problem = new StreamWriter("./problem" + ".csv", true, System.Text.Encoding.GetEncoding("shift_jis"));

            Configuration.ESW = new StreamWriter("./epsilon_" + Configuration.Seed + "CnoiseWidth_" + Configuration.NoiseWidth
                                                 + "AS_" + "CS" + "ET_" + Configuration.ExpThreshold + "DS_" + Configuration.DifferenceSigma + "LS_" + Configuration.LookBackSigma
                                                 + "DE_" + Configuration.DifferenceEpsilon + "LE_" + Configuration.LookBackEpsilon + ".csv", true, System.Text.Encoding.GetEncoding("shift_jis"));


            // 初期化
            // Population初期化
            Population P = new NormalPopulation(Configuration.N);

            Experiment(Env, P);
        }