001/* Maximum profit to cost ratio analysis.
002
003 Copyright (c) 2003-2014 The University of Maryland. All rights reserved.
004 Permission is hereby granted, without written agreement and without
005 license or royalty fees, to use, copy, modify, and distribute this
006 software and its documentation for any purpose, provided that the above
007 copyright notice and the following two paragraphs appear in all copies
008 of this software.
009
010 IN NO EVENT SHALL THE UNIVERSITY OF MARYLAND BE LIABLE TO ANY PARTY
011 FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
012 ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
013 THE UNIVERSITY OF MARYLAND HAS BEEN ADVISED OF THE POSSIBILITY OF
014 SUCH DAMAGE.
015
016 THE UNIVERSITY OF MARYLAND SPECIFICALLY DISCLAIMS ANY WARRANTIES,
017 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
018 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
019 PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
020 MARYLAND HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
021 ENHANCEMENTS, OR MODIFICATIONS.
022
023
024 */
025package ptolemy.graph.analysis;
026
027import java.util.List;
028
029import ptolemy.graph.Graph;
030import ptolemy.graph.analysis.analyzer.Analyzer;
031import ptolemy.graph.analysis.analyzer.MaximumProfitToCostRatioAnalyzer;
032import ptolemy.graph.analysis.strategy.ParhiMaximumProfitToCostRatioStrategy;
033import ptolemy.graph.mapping.ToDoubleMapping;
034import ptolemy.graph.mapping.ToIntMapping;
035
036///////////////////////////////////////////////////////////////////
037//// MaximumProfitToCostRatioAnalysis
038
039/**
040 Maximum profit to cost ratio analysis.
041 <p>
042 Please refer to:
043 <p>
044 Ali Dasdan , Sandy S. Irani , Rajesh K. Gupta, Efficient algorithms for optimum
045 cycle mean and optimum cost to time ratio problems,
046 Proceedings of the 36th ACM/IEEE conference on Design automation conference,
047 p.37-42, June 21-25, 1999, New Orleans, Louisiana, United States
048 <p>
049 for a detailed mathematical description of the problem.
050 <p>
051 @see ptolemy.graph.analysis.CycleMeanAnalysis
052 @since Ptolemy II 4.0
053 @Pt.ProposedRating Red (shahrooz)
054 @Pt.AcceptedRating Red (ssb)
055 @author Shahrooz Shahparnia
056 @version $Id$
057 */
058public class MaximumProfitToCostRatioAnalysis extends Analysis {
059    /** Construct an instance of this class using a default analyzer.
060     *  Please note the limitation on edge costs which is being imposed by the
061     *  default analyzer.
062     *
063     *  @param graph The given graph.
064     *  @param edgeProfits The profits associated with the edges of the graph.
065     *  @param edgeCosts The costs associated with the edges of the graph.
066     */
067    public MaximumProfitToCostRatioAnalysis(Graph graph,
068            ToDoubleMapping edgeProfits, ToIntMapping edgeCosts) {
069        super(new ParhiMaximumProfitToCostRatioStrategy(graph, edgeProfits,
070                edgeCosts));
071    }
072
073    /** Construct an instance of this class using a given analyzer.
074     *
075     *  @param analyzer The given analyzer.
076     */
077    public MaximumProfitToCostRatioAnalysis(
078            MaximumProfitToCostRatioAnalyzer analyzer) {
079        super(analyzer);
080    }
081
082    ///////////////////////////////////////////////////////////////////
083    ////                         public methods                    ////
084
085    /** Return the nodes on the cycle that corresponds to the maximum profit to
086     *  cost ratio.
087     *
088     *  @return The nodes on the cycle as an ordered list.
089     */
090    public List cycle() {
091        return ((MaximumProfitToCostRatioAnalyzer) analyzer()).cycle();
092    }
093
094    /** Return the maximum profit to cost ratio of the given graph.
095     *
096     *  @return Return the maximum profit to cost ratio of the associated graph.
097     */
098    public double maximumRatio() {
099        return ((MaximumProfitToCostRatioAnalyzer) analyzer()).maximumRatio();
100    }
101
102    /** Return a description of the analysis and the associated analyzer.
103     *
104     *  @return A description of the analysis and the associated analyzer.
105     */
106    @Override
107    public String toString() {
108        return "Maximum profit to cost ratio analysis using "
109                + "the following analyzer:\n" + analyzer().toString();
110    }
111
112    /** Check if a given analyzer is compatible with this analysis.
113     *  In other words if it is possible to use it to compute the computation
114     *  associated with this analysis.
115     *
116     *  @param analyzer The given analyzer.
117     *  @return True if the given analyzer is valid for this analysis.
118     */
119    @Override
120    public boolean validAnalyzerInterface(Analyzer analyzer) {
121        return analyzer instanceof MaximumProfitToCostRatioAnalyzer;
122    }
123}