/*
 * Copyright 2011-2013 JOptimizer
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */
package com.joptimizer.functions;

import com.joptimizer.util.Utils;

import cern.colt.matrix.DoubleFactory1D;
import cern.colt.matrix.DoubleFactory2D;
import cern.colt.matrix.DoubleMatrix1D;
import cern.colt.matrix.DoubleMatrix2D;
import cern.colt.matrix.linalg.Algebra;
import cern.jet.math.Functions;
import cern.jet.math.Mult;

/**
 * Default barrier function for the barrier method algorithm.
 * 
If f_i(x) are the inequalities of the problem, theh we have: *
Φ = - Sum_i[log(-f_i(x))] * @see "S.Boyd and L.Vandenberghe, Convex Optimization, 11.2.1" * @author alberto trivellato (alberto.trivellato@gmail.com) */ public class LogarithmicBarrier implements BarrierFunction { final Algebra ALG = Algebra.DEFAULT; final DoubleFactory1D F1 = DoubleFactory1D.dense; final DoubleFactory2D F2 = DoubleFactory2D.dense; private ConvexMultivariateRealFunction[] fi = null; private int dim = -1; /** * Create the logarithmic barrier function. * @see "S.Boyd and L.Vandenberghe, Convex Optimization, 11.2.1" */ public LogarithmicBarrier(ConvexMultivariateRealFunction[] fi, int dim) { this.fi = fi; this.dim = dim; } public double value(double[] X) { double psi = 0; for(int j=0; j=0){ return Double.NaN; } psi -= Math.log(-ineqValuejX); } return psi; } public double[] gradient(double[] X) { DoubleMatrix1D gradFiSum = F1.make(getDim()); for(int j=0; jfi(X)-s, i=1,...,n */ public BarrierFunction createPhase1BarrierFunction(){ final int dimPh1 = dim +1; ConvexMultivariateRealFunction[] inequalitiesPh1 = new ConvexMultivariateRealFunction[this.fi.length]; for(int i=0; i

Ads help maintain this website.