Programming HeuristicLab A. Scheibenpflug Heuristic and Evolutionary Algorithms Laboratory (HEAL) School of Informatics/Communications/Media, Campus Hagenberg.

Slides:



Advertisements
Similar presentations
Population-based metaheuristics Nature-inspired Initialize a population A new population of solutions is generated Integrate the new population into the.
Advertisements

Multi-Objective Optimization NP-Hard Conflicting objectives – Flow shop with both minimum makespan and tardiness objective – TSP problem with minimum distance,
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 7: User-Defined Functions II.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 7: User-Defined Functions II.
Chapter 7: User-Defined Functions II
Chapter 7 User-Defined Methods. Chapter Objectives  Understand how methods are used in Java programming  Learn about standard (predefined) methods and.
Chapter 7: User-Defined Functions II Instructor: Mohammad Mojaddam.
Programming HeuristicLab A. Scheibenpflug Heuristic and Evolutionary Algorithms Laboratory (HEAL) School of Informatics/Communications/Media, Campus Hagenberg.
Content Based Image Clustering and Image Retrieval Using Multiple Instance Learning Using Multiple Instance Learning Xin Chen Advisor: Chengcui Zhang Department.
Road Map Introduction to object oriented programming. Classes
Iterators T.J. Niglio Computer & Systems Engineering Fall 2003 Software Design & Documentation Object Behavioral.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Imagine that I am in a good mood Imagine that I am going to give you some money ! In particular I am going to give you z dollars, after you tell me the.
Terms and Rules Professor Evan Korth New York University (All rights reserved)
Abstract Data Types and Encapsulation Concepts
Chapter 6: Transform and Conquer Genetic Algorithms The Design and Analysis of Algorithms.
Java Unit 9: Arrays Declaring and Processing Arrays.
Genetic Programming on Program Traces as an Inference Engine for Probabilistic Languages Vita Batishcheva, Alexey Potapov
Genetic Algorithm.
HeuristicLab 3.0 Modeling EAs.
Hongfeng Wang Pusan, Korea.  Introduction  General framwork of GA  An example of GA programming 2.
Genetic Algorithms by using MapReduce
Zorica Stanimirović Faculty of Mathematics, University of Belgrade
C++ Programming: From Problem Analysis to Program Design, Fifth Edition, Fifth Edition Chapter 7: User-Defined Functions II.
HeuristicLab Hive An Open Source Environment for Parallel and Distributed Execution of Heuristic Optimization Algorithms S. Wagner, C. Neumüller, A. Scheibenpflug.
Derivative Free Optimization G.Anuradha. Contents Genetic Algorithm Simulated Annealing Random search method Downhill simplex method.
Programming HeuristicLab Basics A. Scheibenpflug Heuristic and Evolutionary Algorithms Laboratory (HEAL) School of Informatics/Communications/Media, Campus.
Classes In C++ 1. What is a class Can make a new type in C++ by declaring a class. A class is an expanded concept of a data structure: instead of holding.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
Data Structures and Algorithms Dr. Tehseen Zia Assistant Professor Dept. Computer Science and IT University of Sargodha Lecture 1.
Genetic Algorithms What is a GA Terms and definitions Basic algorithm.
Probabilistic Algorithms Evolutionary Algorithms Simulated Annealing.
Speeding Up Warehouse Physical Design Using A Randomized Algorithm Minsoo Lee Joachim Hammer Dept. of Computer & Information Science & Engineering University.
Class Builder Tutorial Presented By- Amit Singh & Sylendra Prasad.
Programming HeuristicLab Basics A. Scheibenpflug Heuristic and Evolutionary Algorithms Laboratory (HEAL) School of Informatics/Communications/Media, Campus.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
Ferdowsi University of Mashhad 1 Automatic Semantic Web Service Composition based on owl-s Research Proposal presented by : Toktam ghafarian.
HeuristicLab 3.0 Overview. Motivation genericity – no focus on any particular heuristic optimization paradigm – suitable for any kind of algorithm – suitable.
Programming HeuristicLab Basics A. Scheibenpflug Heuristic and Evolutionary Algorithms Laboratory (HEAL) School of Informatics/Communications/Media, Campus.
An Introduction to Genetic Algorithms Lecture 2 November, 2010 Ivan Garibay
OOP Basics Classes & Methods (c) IDMS/SQL News
Mid-Year Review. Coding Problems In general, solve the coding problems by doing it piece by piece. Makes it easier to think about Break parts of code.
Artificial Intelligence By Mr. Ejaz CIIT Sahiwal Evolutionary Computation.
1 Comparative Study of two Genetic Algorithms Based Task Allocation Models in Distributed Computing System Oğuzhan TAŞ 2005.
Classes CS 162 (Summer 2009). Parts of a Class Instance Fields Methods.
Inheritance Modern object-oriented (OO) programming languages provide 3 capabilities: encapsulation inheritance polymorphism which can improve the design,
Genetic Algorithm in TDR System
Selected Topics in CI I Genetic Programming Dr. Widodo Budiharto 2014.
Chapter 7: User-Defined Functions II
Chapter 13: Pointers, Classes, Virtual Functions, and Abstract Classes
CS2006- Data Structures I Chapter 5 Linked Lists I.
Meta-heuristics Introduction - Fabien Tricoire
HeuristicLab 4.0 Roadmap – Features – Improvements.
classes and objects review
Chapter 3: Using Methods, Classes, and Objects
About the Presentations
Chapter 17 Object-Oriented Data Structures
Subject Name: Operation Research Subject Code: 10CS661 Prepared By:Mrs
Metaheuristic methods and their applications. Optimization Problems Strategies for Solving NP-hard Optimization Problems What is a Metaheuristic Method?
Multi-Objective Optimization
Defining Classes and Methods
Chapter 7: User-Defined Functions II
EE368 Soft Computing Genetic Algorithms.
Introduction to Data Structure
Object-Oriented Programming
CIS 199 Final Review.
CS2013 Lecture 7 John Hurley Cal State LA.
Coevolutionary Automated Software Correction
Presentation transcript:

Programming HeuristicLab A. Scheibenpflug Heuristic and Evolutionary Algorithms Laboratory (HEAL) School of Informatics/Communications/Media, Campus Hagenberg University of Applied Sciences Upper Austria Algorithms and Problems

Overview HL Algorithm Model Parameters, Operators and Scopes Algorithms Problems Programming HeuristicLabhttp://dev.heuristiclab.com2

Where are we? Programming HeuristicLabhttp://dev.heuristiclab.com3

HL Algorithm Model Typically, HL algorithms are constructed by chaining together operators An engine executes these operators – Enables pausing and debugging – Available engines: Sequential engine Parallel engine Debug engine (Hive engine) Programming HeuristicLabhttp://dev.heuristiclab.com4

HL Algorithm Model Programming HeuristicLabhttp://dev.heuristiclab.com5

Parameters Used to configure algorithms, problems and operators Used for accessing variables in the scope E.g. population size, analyzers, crossover operator Operators – Look up these parameters from the algorithm, problem or scope – Use them to store values (in the scope tree) Programming HeuristicLabhttp://dev.heuristiclab.com6

Parameters ValueParameter: – Stores a value (Item) that can be looked up. E.g. mutation rate, crossover operator,… LookupParameter: – Looks up parameters/items (variables) from the scope/parent scopes. ConstrainedValueParameter: – Contains a list of selectable values. ScopeTreeLookupParameter: – Goes down the scope tree and looks up variables. ScopeParameter: – Returns the current scope. ValueLookupParameter, OptionalConstrainedValueParameter, OperatorParameter, FixedValueParameter, OptionalValueParameter,… Programming HeuristicLabhttp://dev.heuristiclab.com7

Parameters Everything that is a ParameterizedNamedItem has a Parameters collection Normally used in the following way: – Add parameter to Parameters collection – Implement getter for convenience – Use parameter – Lookup parameter Programming HeuristicLabhttp://dev.heuristiclab.com8

Add parameter to Parameters collection The Crossover parameter enables the user to select different crossover operators: The PopulationSize is a freely configurable integer value: Programming HeuristicLabhttp://dev.heuristiclab.com9 Parameters.Add(new ConstrainedValueParameter ("Crossover", "The operator used to cross solutions.")); Parameters.Add(new ValueParameter ("PopulationSize", "The size of the population of solutions.", new IntValue(100)));

Implement getter for convenience Getter for crossover parameter: Getter for PopulationSize parameter: Programming HeuristicLabhttp://dev.heuristiclab.com10 public IConstrainedValueParameter CrossoverParameter { get { return (IConstrainedValueParameter )Parameters["Crossover"]; } } private ValueParameter PopulationSizeParameter { get { return (ValueParameter )Parameters["PopulationSize"]; } }

Use parameter Use crossover parameter: Use PopulationSize parameter: Programming HeuristicLabhttp://dev.heuristiclab.com11 PopulationSizeParameter.Value.Value = 42; ICrossover defaultCrossover = Problem.Operators.OfType ().FirstOrDefault(); foreach (ICrossover crossover in Problem.Operators.OfType ().OrderBy(x => x.Name)) CrossoverParameter.ValidValues.Add(crossover); CrossoverParameter.Value = defaultCrossover;

Lookup Parameter Defining lookup parameter for crossover: Defining lookup parameter for population size: Programming HeuristicLabhttp://dev.heuristiclab.com12 Parameters.Add(new ValueLookupParameter ("Crossover", "The operator used to cross solutions.")); Parameters.Add(new ValueLookupParameter ("PopulationSize", "The size of the population.")); public ValueLookupParameter PopulationSizeParameter { get { return (ValueLookupParameter )Parameters["PopulationSize"]; } } public ValueLookupParameter CrossoverParameter { get { return (ValueLookupParameter )Parameters["Crossover"]; } }

Use Lookup Parameter Set crossover parameter: Set PopulationSize parameter: Programming HeuristicLabhttp://dev.heuristiclab.com13 CrossoverParameter.Value = ga.CrossoverParameter.ValidValues.Single(x => x.GetType() == typeof(OrderCrossover)); PopulationSizeParameter.Value.Value = 42;

Use Lookup Parameter In the genetic algorithm, a placeholder looks up the crossover that it executes: – Create placeholder – Set the name of operator to lookup – In the placeholder operator Programming HeuristicLabhttp://dev.heuristiclab.com14 crossover.OperatorParameter.ActualName = "Crossover"; Placeholder crossover = new Placeholder(); OperationCollection next = new OperationCollection(base.Apply()); IOperator op = OperatorParameter.ActualValue; if (op != null) next.Insert(0, ExecutionContext.CreateOperation(op)); return next;

Scopes A scope is a node in the scope tree Contains link to parent and sub-scopes Contains variables (e.g. solutions or their quality) Operators usually work on scopes (either directly or through parameters) Example - Selection: Programming HeuristicLabhttp://dev.heuristiclab.com15

Operators Inherit from SingleSuccessorOperator Override the Apply() method Must return base.Apply() – Returns successor operation Use ExecutionContext to access scopes Or better: Use parameters to retrieve scopes, values from scopes or manipulate them Programming HeuristicLabhttp://dev.heuristiclab.com16

Instrumented Operators Inherit from InstrumentedOperator Override InstrumentedApply() Must return base.InstrumentedApply() Allows to configure before and after actions Useful for analyzers, additional functionality,… without changing the algorithm Think of aspect-oriented programming Programming HeuristicLabhttp://dev.heuristiclab.com17

Operators Programming HeuristicLabhttp://dev.heuristiclab.com18 A parameter for retrieving „Value“ (default name, can be configure with ActualValue) from scope or parent scopes If the value is not found it can also be created in the scope A operator that increments a value from the scope by „Increment“ For easier access to parameter values

Algorithms and Problems Different ways how to implement algorithms and problems Algorithms – Flexible: Inherit from HeuristicOptimizationEngineAlgorithm – Easy: Inherit from BasicAlgorithm Problems – Flexible: Inherit from SingleObjectiveHeuristicOptimizationProblem – Easy: Inherit from [Single|Multi]ObjectiveBasicProblem Programming HeuristicLabhttp://dev.heuristiclab.com19

Base classes/interfaces for algorithms Programming HeuristicLabhttp://dev.heuristiclab.com20

Base classes/interfaces for algorithms IExecutable (Executable): – Defines methods for starting, stopping, etc. of algorithms IOptimizer: – Contains a run collection IAlgorithm: – Contains a problem on which the algorithm is applied as well as a result Algorithm: – Base class, implements IAlgorithm EngineAlgorithm: – Extensions for execution with an engine (operator graph, scope, engine) HeuristicOptimizationEngineAlgorithm: – Specifies problem: IHeuristicOptimizationProblem Programming HeuristicLabhttp://dev.heuristiclab.com21

What does an HL algorithm do? Create operator graph of algorithm by chaining together operators (the actual algorithm) Offer user configuration options through parameters Discover operators from the Operators collection of the problem/encoding Parameterize/wire (react to changes in operators) operators where necessary Programming HeuristicLabhttp://dev.heuristiclab.com22

BasicAlgorithm Creating an operator graph can be quite tricky Wiring operators is error-prone BasicAlgorithms are – Easy to implement – No boilerplate code – Hard-coded (no operator graph) – Don’t support pause Programming HeuristicLabhttp://dev.heuristiclab.com23

Base classes/interfaces for BasicAlgorithm Programming HeuristicLabhttp://dev.heuristiclab.com24

BasicAlgorithm - Interface Implement the Run method Optional: Fix problem type Programming HeuristicLabhttp://dev.heuristiclab.com25 protected override void Run(CancellationToken cancellationToken) public override Type ProblemType { get { return typeof(BinaryProblem); } } public new BinaryProblem Problem { get { return (BinaryProblem)base.Problem; } set { base.Problem = value; } }

Example – Random Search Programming HeuristicLabhttp://dev.heuristiclab.com26 protected override void Run(CancellationToken cancellationToken) { DoubleValue bestQuality = new DoubleValue(0.0); Results.Add(new Result("BestQuality", bestQuality)); for(int i = 0; i bestQuality.Value) { bestQuality.Value = curQuality; } else if(!Problem.Maximization && curQuality < bestQuality.Value) { bestQuality.Value = curQuality; } } }

Problems Use encodings for representing solutions Encodings consist of solution candidate definitions and corresponding operators Problems contain – the evaluator – the solution creator Define maximization or minimization Contain the „problem data“ (e.g. a distance matrix, a simulation, a function definition), usually supplied by a ProblemInstanceProvider Can be single- or multi-objective Configured with parameters Programming HeuristicLabhttp://dev.heuristiclab.com27

Problem Architecture Programming HeuristicLabhttp://dev.heuristiclab.com28

Base classes/interfaces for problems Programming HeuristicLabhttp://dev.heuristiclab.com29

Base classes/interfaces for problems IProblem: – Contains the operators collection; all operators that can be used by the problem, algorithm and user IHeuristicOptimizationProblem: – Defines solution creator and evaluator Problem, HeuristicOptimizationProblem and Single/MultiObjectiveHeuristicOptimizationPr oblem provide abstract base classes Programming HeuristicLabhttp://dev.heuristiclab.com30

Recap: What does a HL problem do? Defines used encoding Defines single/multi objective Defines min/maximization Discovers correct operators – Are used by the algorithm Wires/parameterizes operators Loads problem data using a corresponding problem instance provider Programming HeuristicLabhttp://dev.heuristiclab.com31

BasicProblem Similar concept as BasicAlgorithm Makes implementing new problems easier No wireing/operators necessary Use automatic encoding configuration Don’t work with all algorithm types, e.g. algorithms that use very specific operators Simulated Annealing Scatter Search Particle Swarm Optimization Programming HeuristicLabhttp://dev.heuristiclab.com32

Base classes/interfaces for BasicProblem Programming HeuristicLabhttp://dev.heuristiclab.com33

BasicProblem - Interface Define Encoding Define maximization or minimization Evaluate a solution and return quality Programming HeuristicLabhttp://dev.heuristiclab.com34 bool Maximization { get; } double Evaluate(Individual individual, IRandom random); MyNewProblem : SingleObjectiveBasicProblem

BasicProblem - Interface Until now only GA variants can use the problem Implement neighbourhood function to also use trajectory-based metaheuristics Optional: Add analysis code for tracking results Programming HeuristicLabhttp://dev.heuristiclab.com35 IEnumerable GetNeighbors(Individual individual, IRandom random); void Analyze(Individual[] individuals, double[] qualities, ResultCollection results, IRandom random);

BasicProblem – Example: OneMax Programming HeuristicLabhttp://dev.heuristiclab.com36 class OneMaxProblem : SingleObjectiveBasicProblem { public OneMaxProblem() { } [StorableConstructor] protected OneMaxProblem(bool deserializing) : base(deserializing) { } public OneMaxProblem(OneMaxProblem alg, Cloner cloner) : base(alg, cloner) { } public override IDeepCloneable Clone(Cloner cloner) { return new OneMaxProblem(this, cloner); } public override bool Maximization { get{ return true; } } public override double Evaluate(Individual individual, IRandom random) { return individual.BinaryVector().Count(b => b); } }

Useful Links Programming HeuristicLabhttp://dev.heuristiclab.com