### Installing GeneticSharp Core Package (.NET 6) - Shell Source: https://github.com/giacomelli/geneticsharp/blob/master/README.md This command installs the core GeneticSharp NuGet package for .NET 6 projects. It provides the fundamental components of the genetic algorithm library without extensions, serving as the basic setup for integrating GeneticSharp into a .NET 6 application. ```shell install-package GeneticSharp ``` -------------------------------- ### Running a Genetic Algorithm Instance (C#) Source: https://github.com/giacomelli/geneticsharp/blob/master/README.md This C# code snippet demonstrates the setup and execution of a genetic algorithm using GeneticSharp. It initializes key components like selection, crossover, mutation, fitness, and chromosome, then creates a population and a GeneticAlgorithm instance. The Termination condition is set, and the Start method initiates the evolutionary process, finally printing the fitness of the best solution found. ```csharp var selection = new EliteSelection(); var crossover = new OrderedCrossover(); var mutation = new ReverseSequenceMutation(); var fitness = new MyProblemFitness(); var chromosome = new MyProblemChromosome(); var population = new Population (50, 70, chromosome); var ga = new GeneticAlgorithm(population, fitness, selection, crossover, mutation); ga.Termination = new GenerationNumberTermination(100); Console.WriteLine("GA running..."); ga.Start(); Console.WriteLine("Best solution found has {0} fitness.", ga.BestChromosome.Fitness); ``` -------------------------------- ### Installing GeneticSharp Extensions Package (.NET 6) - Shell Source: https://github.com/giacomelli/geneticsharp/blob/master/README.md This command installs the GeneticSharp.Extensions NuGet package for .NET 6 projects. This package includes various pre-built components and examples such as TSP, AutoConfig, Bitmap equality, and Equation Solver, providing a richer set of functionalities for common genetic algorithm problems. ```shell install-package GeneticSharp.Extensions ``` -------------------------------- ### Installing GeneticSharp Templates with dotnet new (Shell) Source: https://github.com/giacomelli/geneticsharp/blob/master/README.md This command installs the `GeneticSharp.Templates` NuGet package, making its project templates available for use with the `dotnet new` command-line interface. It is a necessary first step to create new projects based on GeneticSharp's pre-defined structures, enabling rapid setup for genetic algorithm applications. ```shell dotnet new -i GeneticSharp.Templates ``` -------------------------------- ### Installing GeneticSharp for .NET Framework 3.5 - Shell Source: https://github.com/giacomelli/geneticsharp/blob/master/README.md This command installs a very old version (1.2.0) of the GeneticSharp NuGet package. This specific version is required for compatibility with projects targeting the .NET Framework 3.5, catering to very old application environments. ```shell install-package GeneticSharp -Version 1.2.0 ``` -------------------------------- ### Installing GeneticSharp for .NET Standard 2.0 / .NET Framework 4.6.2 - Shell Source: https://github.com/giacomelli/geneticsharp/blob/master/README.md This command installs a specific older version (2.6.0) of the GeneticSharp NuGet package. This version is compatible with projects targeting .NET Standard 2.0 and .NET Framework 4.6.2, providing support for legacy or specific environment requirements. ```shell install-package GeneticSharp -Version 2.6.0 ``` -------------------------------- ### Creating TSP Unity3D Application with dotnet new (Shell) Source: https://github.com/giacomelli/geneticsharp/blob/master/README.md This command creates a new Unity3D project template, integrated with GeneticSharp and specifically set up to solve the Travelling Salesman Problem (TSP). The `-n` parameter defines the root namespace for the generated project, and the `-o` parameter specifies the output directory where the Unity project will be initialized. ```shell dotnet new GeneticSharpTspUnity3d -n MyNamespace -o MyOutoputFolder ``` -------------------------------- ### Creating Generic Console Application with dotnet new (Shell) Source: https://github.com/giacomelli/geneticsharp/blob/master/README.md This command creates a new console application project integrated with GeneticSharp, providing a basic structure for genetic algorithm implementations. Users are required to implement their specific chromosome and fitness functions to define the algorithm's behavior. The `-n` parameter sets the namespace, and `-o` specifies the output folder for the new project. ```shell dotnet new GeneticSharpConsoleApp -n MyNamespace -o MyOutoputFolder ``` -------------------------------- ### Creating TSP Blazor Application with dotnet new (Shell) Source: https://github.com/giacomelli/geneticsharp/blob/master/README.md This command generates a new Blazor client application project, pre-configured with GeneticSharp to solve the Travelling Salesman Problem (TSP). The `-n` parameter sets the root namespace for the generated project files, and the `-o` parameter specifies the output directory where the new project will be created. ```shell dotnet new GeneticSharpTspBlazorApp -n MyNamespace -o MyOutoputFolder ``` -------------------------------- ### Creating TSP Console Application with dotnet new (Shell) Source: https://github.com/giacomelli/geneticsharp/blob/master/README.md This command generates a new console application project, pre-configured with GeneticSharp to solve the Travelling Salesman Problem (TSP). Similar to other templates, the `-n` parameter defines the project's root namespace, and the `-o` parameter specifies the output directory for the newly created project files. ```shell dotnet new GeneticSharpTspConsoleApp -n MyNamespace -o MyOutoputFolder ``` -------------------------------- ### Implementing Custom Chromosome (C#) Source: https://github.com/giacomelli/geneticsharp/blob/master/README.md This C# code snippet illustrates how to define a custom chromosome by inheriting from ChromosomeBase. The constructor sets the chromosome length, GenerateGene defines how individual genes are created, and CreateNew provides a factory method for creating new instances. This class represents the solution encoding for the genetic algorithm. ```csharp public class MyProblemChromosome : ChromosomeBase { // Change the argument value passed to base constructor to change the length // of your chromosome. public MyProblemChromosome() : base(10) { CreateGenes(); } public override Gene GenerateGene (int geneIndex) { // Generate a gene base on my problem chromosome representation. } public override IChromosome CreateNew () { return new MyProblemChromosome(); } } ``` -------------------------------- ### Displaying Open Iconic Font Standalone Source: https://github.com/giacomelli/geneticsharp/blob/master/src/GeneticSharp.Runner.BlazorApp/wwwroot/css/open-iconic/README.md This HTML snippet demonstrates how to display an Open Iconic font icon when used standalone. The oi class initializes the icon font, and data-glyph specifies the particular icon to display, with title and aria-hidden for accessibility. ```HTML ``` -------------------------------- ### Initializing Google Analytics with gtag.js - JavaScript Source: https://github.com/giacomelli/geneticsharp/blob/master/src/GeneticSharp.Runner.BlazorApp/tools/jekyll-files/index.html This snippet initializes Google Analytics using the gtag.js library. It sets up the 'dataLayer' array, defines the 'gtag' function to push events, and configures the tracking ID 'UA-50922592-1'. It is typically used for website analytics and tracking. ```JavaScript window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'UA-50922592-1'); ``` -------------------------------- ### Rewriting URLs for GitHub Pages SPAs in JavaScript Source: https://github.com/giacomelli/geneticsharp/blob/master/src/GeneticSharp.Runner.BlazorApp/tools/jekyll-files/404.html This JavaScript snippet redirects the browser by converting the current URL's path and query string into a single query parameter (e.g., 'p' for path, 'q' for query) to support single-page applications on GitHub Pages. It handles custom domains and project pages by adjusting 'segmentCount' to preserve the base path, ensuring the client-side router receives the full intended route. ```JavaScript var segmentCount = 0; var l = window.location; l.replace( l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') + l.pathname.split('/').slice(0, 1 + segmentCount).join('/') + '/?p=/' + l.pathname.slice(1).split('/').slice(segmentCount).join('/').replace(/&/g, '~and~') + (l.search ? '&q=' + l.search.slice(1).replace(/&/g, '~and~') : '') + l.hash ); ``` -------------------------------- ### Linking Open Iconic Standalone Stylesheet Source: https://github.com/giacomelli/geneticsharp/blob/master/src/GeneticSharp.Runner.BlazorApp/wwwroot/css/open-iconic/README.md This HTML snippet shows how to link the default Open Iconic stylesheet for standalone usage, without Bootstrap or Foundation. This stylesheet provides the necessary CSS classes to use Open Iconic as an icon font in any web project. ```HTML ``` -------------------------------- ### Using Open Iconic SVG Sprite in HTML Source: https://github.com/giacomelli/geneticsharp/blob/master/src/GeneticSharp.Runner.BlazorApp/wwwroot/css/open-iconic/README.md This HTML snippet shows how to reference an icon from an Open Iconic SVG sprite using the and elements. A general class (icon) is added to the and a unique class (icon-account-login) to the for easy styling. ```HTML ``` -------------------------------- ### Linking Open Iconic Foundation Stylesheet Source: https://github.com/giacomelli/geneticsharp/blob/master/src/GeneticSharp.Runner.BlazorApp/wwwroot/css/open-iconic/README.md This HTML snippet shows how to link the Open Iconic stylesheet specifically designed for Foundation integration. This stylesheet provides the necessary CSS classes to use Open Iconic as an icon font within a Foundation project. ```HTML ``` -------------------------------- ### Linking Open Iconic Standalone Stylesheet in HTML Source: https://github.com/giacomelli/geneticsharp/blob/master/src/Templates/content/TspBlazorApp/wwwroot/css/open-iconic/README.md This HTML snippet shows how to link the default Open Iconic stylesheet for standalone use, without Bootstrap or Foundation. This enables the use of Open Iconic as an icon font in any web project. ```HTML ``` -------------------------------- ### Implementing Custom Fitness Evaluation (C#) Source: https://github.com/giacomelli/geneticsharp/blob/master/README.md This C# code snippet demonstrates how to create a custom fitness evaluation class by implementing the IFitness interface. The Evaluate method is where the fitness of a given chromosome is calculated, returning a double value that represents its quality. This is a core step in defining the objective function for a genetic algorithm. ```csharp public class MyProblemFitness : IFitness { public double Evaluate (IChromosome chromosome) { // Evaluate the fitness of chromosome. } } ``` -------------------------------- ### Handling GitHub Pages SPA Redirects - JavaScript Source: https://github.com/giacomelli/geneticsharp/blob/master/src/GeneticSharp.Runner.BlazorApp/tools/jekyll-files/index.html This self-executing function (IIFE) is designed for Single Page Applications hosted on GitHub Pages. It checks the URL's query string for a redirect parameter ('p') and reconstructs the original URL, then uses 'window.history.replaceState' to update the browser's history without causing a page reload. This allows SPAs to correctly route after a GitHub Pages redirect. ```JavaScript (function(l) { if (l.search) { var q = {}; l.search.slice(1).split('&').forEach(function(v) { var a = v.split('='); q[a[0]] = a.slice(1).join('=').replace(/~and~/g, '&'); }); if (q.p !== undefined) { window.history.replaceState(null, null, l.pathname.slice(0, -1) + (q.p || '') + (q.q ? ('?' + q.q) : '') + l.hash ); } } }(window.location)) ``` -------------------------------- ### Displaying Open Iconic Font with Bootstrap Source: https://github.com/giacomelli/geneticsharp/blob/master/src/GeneticSharp.Runner.BlazorApp/wwwroot/css/open-iconic/README.md This HTML snippet demonstrates how to display an Open Iconic font icon when integrated with Bootstrap. The oi class initializes the icon font, and oi-icon-name specifies the particular icon to display, with title and aria-hidden for accessibility. ```HTML ``` -------------------------------- ### Linking Open Iconic Foundation Stylesheet in HTML Source: https://github.com/giacomelli/geneticsharp/blob/master/src/Templates/content/TspBlazorApp/wwwroot/css/open-iconic/README.md This HTML snippet shows how to link the Open Iconic stylesheet specifically designed for Foundation integration. Including this stylesheet enables the use of Open Iconic as an icon font within a Foundation project. ```HTML ``` -------------------------------- ### Linking Open Iconic Bootstrap Stylesheet Source: https://github.com/giacomelli/geneticsharp/blob/master/src/GeneticSharp.Runner.BlazorApp/wwwroot/css/open-iconic/README.md This HTML snippet shows how to link the Open Iconic stylesheet specifically designed for Bootstrap integration. This stylesheet provides the necessary CSS classes to use Open Iconic as an icon font within a Bootstrap project. ```HTML ``` -------------------------------- ### Displaying Open Iconic Font with Foundation Source: https://github.com/giacomelli/geneticsharp/blob/master/src/GeneticSharp.Runner.BlazorApp/wwwroot/css/open-iconic/README.md This HTML snippet demonstrates how to display an Open Iconic font icon when integrated with Foundation. The fi-icon-name class specifies the particular icon to display, with title and aria-hidden for accessibility. ```HTML ``` -------------------------------- ### Displaying Open Iconic Foundation Icons in HTML Source: https://github.com/giacomelli/geneticsharp/blob/master/src/Templates/content/TspBlazorApp/wwwroot/css/open-iconic/README.md This HTML snippet demonstrates how to display an Open Iconic font icon when integrated with Foundation. The element uses a fi-icon-name class to render the specific icon, along with title and aria-hidden for accessibility. ```HTML ``` -------------------------------- ### Displaying Open Iconic Standalone Icons in HTML Source: https://github.com/giacomelli/geneticsharp/blob/master/src/Templates/content/TspBlazorApp/wwwroot/css/open-iconic/README.md This HTML snippet demonstrates how to display an Open Iconic font icon when used standalone. The element uses the oi base class and a data-glyph attribute to specify the icon, along with title and aria-hidden for accessibility. ```HTML ``` -------------------------------- ### Embedding Open Iconic SVGs in HTML Source: https://github.com/giacomelli/geneticsharp/blob/master/src/Templates/content/TspBlazorApp/wwwroot/css/open-iconic/README.md This snippet demonstrates how to embed an Open Iconic SVG directly into an HTML document using an tag. It's recommended to include the alt attribute for accessibility. This method treats the icon as a standard image. ```HTML icon name ``` -------------------------------- ### Embedding Open Iconic SVGs in HTML Source: https://github.com/giacomelli/geneticsharp/blob/master/src/GeneticSharp.Runner.BlazorApp/wwwroot/css/open-iconic/README.md This snippet demonstrates how to directly embed an Open Iconic SVG file into an HTML document using an tag. It's recommended to include the alt attribute for accessibility. ```HTML icon name ``` -------------------------------- ### Linking Open Iconic Bootstrap Stylesheet in HTML Source: https://github.com/giacomelli/geneticsharp/blob/master/src/Templates/content/TspBlazorApp/wwwroot/css/open-iconic/README.md This HTML snippet shows how to link the Open Iconic stylesheet specifically designed for Bootstrap integration. Including this stylesheet enables the use of Open Iconic as an icon font within a Bootstrap project. ```HTML ``` -------------------------------- ### Embedding Open Iconic SVG Sprite Icons in HTML Source: https://github.com/giacomelli/geneticsharp/blob/master/src/Templates/content/TspBlazorApp/wwwroot/css/open-iconic/README.md This HTML snippet shows how to display an icon from an Open Iconic SVG sprite. It uses an element with a general class and a element referencing the specific icon within the sprite via xlink:href. This approach allows for displaying multiple icons with a single request. ```HTML ``` -------------------------------- ### Displaying Open Iconic Bootstrap Icons in HTML Source: https://github.com/giacomelli/geneticsharp/blob/master/src/Templates/content/TspBlazorApp/wwwroot/css/open-iconic/README.md This HTML snippet demonstrates how to display an Open Iconic font icon when integrated with Bootstrap. The element uses the oi base class and an oi-icon-name class to render the specific icon, along with title and aria-hidden for accessibility. ```HTML ``` -------------------------------- ### Sizing Open Iconic SVG Sprite Icons with CSS Source: https://github.com/giacomelli/geneticsharp/blob/master/src/Templates/content/TspBlazorApp/wwwroot/css/open-iconic/README.md This CSS snippet illustrates how to set the dimensions for Open Iconic SVG sprite icons. Since all icons are square, applying equal width and height to the tag ensures proper scaling and display. ```CSS .icon { width: 16px; height: 16px; } ``` -------------------------------- ### Sizing Open Iconic SVG Sprite Icons with CSS Source: https://github.com/giacomelli/geneticsharp/blob/master/src/GeneticSharp.Runner.BlazorApp/wwwroot/css/open-iconic/README.md This CSS rule demonstrates how to set the dimensions for icons used with the Open Iconic SVG sprite. Since all icons are square, setting equal width and height on the tag ensures proper scaling. ```CSS .icon { width: 16px; height: 16px; } ``` -------------------------------- ### Coloring Open Iconic SVG Sprite Icons with CSS Source: https://github.com/giacomelli/geneticsharp/blob/master/src/GeneticSharp.Runner.BlazorApp/wwwroot/css/open-iconic/README.md This CSS snippet illustrates how to change the color of an Open Iconic SVG sprite icon. By applying the fill property to the specific class of the tag, the icon's color can be easily customized. ```CSS .icon-account-login { fill: #f00; } ``` -------------------------------- ### Coloring Open Iconic SVG Sprite Icons with CSS Source: https://github.com/giacomelli/geneticsharp/blob/master/src/Templates/content/TspBlazorApp/wwwroot/css/open-iconic/README.md This CSS snippet demonstrates how to change the color of an Open Iconic SVG sprite icon. By setting the fill property on the specific class applied to the tag, the icon's color can be easily customized. ```CSS .icon-account-login { fill: #f00; } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.