001/******************************************************************************* 002 * Copyright (c) 2014 Opt4J 003 * 004 * Permission is hereby granted, free of charge, to any person obtaining a copy 005 * of this software and associated documentation files (the "Software"), to deal 006 * in the Software without restriction, including without limitation the rights 007 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 008 * copies of the Software, and to permit persons to whom the Software is 009 * furnished to do so, subject to the following conditions: 010 * 011 * The above copyright notice and this permission notice shall be included in 012 * all copies or substantial portions of the Software. 013 * 014 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 015 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 016 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 017 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 018 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 019 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 020 * SOFTWARE. 021 *******************************************************************************/ 022 023package org.opt4j.benchmarks.wfg; 024 025import java.util.ArrayList; 026import java.util.List; 027 028import org.opt4j.benchmarks.K; 029import org.opt4j.benchmarks.M; 030 031import com.google.inject.Inject; 032 033/** 034 * The {@link WFG3} benchmark function. 035 * 036 * @author lukasiewycz 037 * 038 */ 039public class WFG3 extends WFGEvaluator { 040 041 /** 042 * Constructs a {@link WFG3} benchmark function. 043 * 044 * @param k 045 * the position parameters 046 * @param M 047 * the number of objectives 048 */ 049 @Inject 050 public WFG3(@K int k, @M int M) { 051 super(k, M); 052 } 053 054 protected static List<Double> shape(final List<Double> t_p) { 055 056 assert (t_p.size() >= 2); 057 058 final int M = t_p.size(); 059 060 final List<Boolean> A = createA(M, true); 061 final List<Double> x = calculateX(t_p, A); 062 063 List<Double> h = new ArrayList<>(); 064 065 for (int m = 1; m <= M; m++) { 066 h.add(WFGShapeFunctions.linear(x, m)); 067 } 068 069 return calculateF(x, h); 070 } 071 072 /* 073 * (non-Javadoc) 074 * 075 * @see org.opt4j.benchmark.wfg.WFGEvaluator#f(java.util.List) 076 */ 077 @Override 078 public List<Double> f(List<Double> y) { 079 y = WFG1.t1(y, k); 080 y = WFG2.t2(y, k); 081 y = WFG2.t3(y, k, M); 082 083 return WFG3.shape(y); 084 } 085}