All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.cloudsimplus.heuristics.HeuristicSolution Maven / Gradle / Ivy

Go to download

CloudSim Plus: A modern, highly extensible and easier-to-use Java 8+ Framework for Modeling and Simulation of Cloud Computing Infrastructures and Services

There is a newer version: 8.0.0
Show newest version
/*
 * CloudSim Plus: A modern, highly-extensible and easier-to-use Framework for
 * Modeling and Simulation of Cloud Computing Infrastructures and Services.
 * http://cloudsimplus.org
 *
 *     Copyright (C) 2015-2021 Universidade da Beira Interior (UBI, Portugal) and
 *     the Instituto Federal de Educação Ciência e Tecnologia do Tocantins (IFTO, Brazil).
 *
 *     This file is part of CloudSim Plus.
 *
 *     CloudSim Plus is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 *
 *     CloudSim Plus is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 *
 *     You should have received a copy of the GNU General Public License
 *     along with CloudSim Plus. If not, see .
 */
package org.cloudsimplus.heuristics;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * A solution for a complex problem found using a {@link Heuristic} implementation.
 * A heuristic can generate multiple solutions until find an optimal or suboptimal
 * solution for the problem.
 *
 * @author Manoel Campos da Silva Filho
 * @param  the type used to store the result of the solution.
 * Check {@link #getResult()} for more details.
 * @since CloudSim Plus 1.0
 */
public interface HeuristicSolution extends Comparable> {
    Logger LOGGER = LoggerFactory.getLogger(HeuristicSolution.class.getSimpleName());

    /**
     * An attribute that implements the Null Object Design Pattern for {@link HeuristicSolution}
     * objects.
     */
    HeuristicSolution NULL = new HeuristicSolutionNull();

	/**
	 * @return the heuristic that generated this solution.
	 */
	Heuristic> getHeuristic();

    /**
     * Defines how good the solution is and it the inverse of the {@link #getCost()}.
     * As higher is the fitness,
     * better is a solution. How a solution fitness is computed is totally
     * dependent of the heuristic implementation being used
     * to find a solution.
     *
     * @return the solution fitness
     * @see #getCost()
     */
    default double getFitness() {
        return 1.0/getCost();
    }

    /**
     * Defines the cost of using this solution.
     * As higher is the cost, worse is a solution. How a solution cost is computed is totally
     * dependent of the heuristic implementation being used to find a solution.
     *
     * @return the solution cost
     * @see #getFitness()
     */
    double getCost();

    /**
     * Gets the result of the solution.
     * For instance, if a implementation of this interface aims to provide
     * a mapping between Cloudlets and Vm's, this type would be
     * a {@code  Map}, that will indicate which Vm will
     * run each Cloudlet.
     * This way, the type T of the solution is totally dependent of the problem
     * being solved by the heuristic implementation.
     *
     * 

* The result of solution is generated by a heuristic. * Getting an optimal or sub-optimal solution is the final goal of a heuristic. *

* * @return the object containing the result of the generated solution. */ T getResult(); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy