{"id":23080612,"url":"https://github.com/chen0040/cs-optimization-binary-solutions","last_synced_at":"2025-04-03T13:47:31.935Z","repository":{"id":49409496,"uuid":"108701083","full_name":"chen0040/cs-optimization-binary-solutions","owner":"chen0040","description":"Local search optimization for binary-coded solutions implemented in C#","archived":false,"fork":false,"pushed_at":"2017-11-04T04:02:33.000Z","size":380,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-12T20:16:11.692Z","etag":null,"topics":["binary-coded-solutons","binary-optmization","numerical-optimization"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chen0040.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-29T03:09:02.000Z","updated_at":"2022-07-25T12:41:45.000Z","dependencies_parsed_at":"2022-09-14T22:01:05.057Z","dependency_job_id":null,"html_url":"https://github.com/chen0040/cs-optimization-binary-solutions","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chen0040%2Fcs-optimization-binary-solutions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chen0040%2Fcs-optimization-binary-solutions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chen0040%2Fcs-optimization-binary-solutions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chen0040%2Fcs-optimization-binary-solutions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chen0040","download_url":"https://codeload.github.com/chen0040/cs-optimization-binary-solutions/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247014505,"owners_count":20869376,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["binary-coded-solutons","binary-optmization","numerical-optimization"],"created_at":"2024-12-16T13:15:36.191Z","updated_at":"2025-04-03T13:47:31.917Z","avatar_url":"https://github.com/chen0040.png","language":"C#","readme":"# cs-optimization-binary-solutions\n\nLocal search optimization for binary-coded solutions implemented in C#\n\n# Install\n\n```bash\nInstall-Package cs-optimization-binary-solutions -Version 1.0.1\n```\n\n# Features\n\nThe following meta-heuristic algorithms are provided for binary optimization (Optimization in which the solutions are binary-coded):\n\n* Genetic Algorithm\n* Memetic Algorithm\n* GRASP\n* Multi-start Hill Climbing\n* Tabu Search\n* Variable Neighbhorhood Search \n* Iterated Local Search \n* Random Search \n\n# Usage\n\nThe code below shows how to use Genetic Algorithm to solve an optimization problem that looks for the binary-coded solution with minimum number of 1 bits:\n\n```cs \nint popSize = 100;\nint dimension = 1000; // solution has 1000 bits\nGeneticAlgorithm method = new GeneticAlgorithm(popSize, dimension);\nmethod.MaxIterations = 500;\n\nmethod.SolutionUpdated += (best_solution, step) =\u003e\n{\n\tConsole.WriteLine(\"Step {0}: Fitness = {1}\", step, best_solution.Cost);\n};\n\nBinarySolution finalSolution = method.Minimize((solution, constraints) =\u003e\n{\n\tint num1Bits = 0;\n\tfor(int i=0; i \u003c solution.Length; ++i)\n\t{\n\t\tnum1Bits += solution[i];\n\t}\n\treturn num1Bits; // try to minimize the number of 1 bits in the solution\n});\nConsole.WriteLine(\"final solution: {0}\", finalSolution);\n```\n\n\nThe code below shows how to use Memetic Algorithm to solve an optimization problem that looks for the binary-coded solution with minimum number of 1 bits:\n\n```cs \nint popSize = 100;\nint dimension = 1000; // solution has 1000 bits\nMemeticAlgorithm method = new MemeticAlgorithm(popSize, dimension);\nmethod.MaxIterations = 10;\nmethod.MaxLocalSearchIterations = 1000;\n\nmethod.SolutionUpdated += (best_solution, step) =\u003e\n{\n\tConsole.WriteLine(\"Step {0}: Fitness = {1}\", step, best_solution.Cost);\n};\n\nBinarySolution finalSolution = method.Minimize((solution, constraints) =\u003e\n{\n\tint num1Bits = 0;\n\tfor(int i=0; i \u003c solution.Length; ++i)\n\t{\n\t\tnum1Bits += solution[i];\n\t}\n\treturn num1Bits; // try to minimize the number of 1 bits in the solution\n});\nConsole.WriteLine(\"final solution: {0}\", finalSolution);\n```\n\nThe code below shows how to use Stochastic Hill Climber to solve an optimization problem that looks for the binary-coded solution with minimum number of 1 bits:\n\n```cs \nint dimension = 1000; // solution has 1000 bits\nStochasticHillClimber method = new StochasticHillClimber(dimension);\nmethod.MaxIterations = 100;\n\nmethod.SolutionUpdated += (best_solution, step) =\u003e\n{\n\tConsole.WriteLine(\"Step {0}: Fitness = {1}\", step, best_solution.Cost);\n};\n\nBinarySolution finalSolution = method.Minimize((solution, constraints) =\u003e\n{\n\tint num1Bits = 0;\n\tfor(int i=0; i \u003c solution.Length; ++i)\n\t{\n\t\tnum1Bits += solution[i];\n\t}\n\treturn num1Bits; // try to minimize the number of 1 bits in the solution\n});\nConsole.WriteLine(\"final solution: {0}\", finalSolution);\n```\n\nThe code below shows how to use Iterated Local Search to solve an optimization problem that looks for the binary-coded solution with minimum number of 1 bits:\n\n```cs \nint dimension = 1000; // solution has 1000 bits\nIteratedLocalSearch method = new IteratedLocalSearch(dimension);\nmethod.MaxIterations = 1000;\n\nmethod.SolutionUpdated += (best_solution, step) =\u003e\n{\n\tConsole.WriteLine(\"Step {0}: Fitness = {1}\", step, best_solution.Cost);\n};\n\nBinarySolution finalSolution = method.Minimize((solution, constraints) =\u003e\n{\n\tint num1Bits = 0;\n\tfor(int i=0; i \u003c solution.Length; ++i)\n\t{\n\t\tnum1Bits += solution[i];\n\t}\n\treturn num1Bits; // try to minimize the number of 1 bits in the solution\n});\nConsole.WriteLine(\"final solution: {0}\", finalSolution);\n```\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchen0040%2Fcs-optimization-binary-solutions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchen0040%2Fcs-optimization-binary-solutions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchen0040%2Fcs-optimization-binary-solutions/lists"}