/*
* 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 java.util.ArrayList;
import java.util.List;
import org.apache.commons.math3.linear.Array2DRowRealMatrix;
import org.apache.commons.math3.linear.ArrayRealVector;
import org.apache.commons.math3.linear.MatrixUtils;
import org.apache.commons.math3.linear.RealMatrix;
import org.apache.commons.math3.linear.RealVector;
/**
* Generalized logarithm barrier function for SOCP with constraints:
*
||Ai.x+bi|| < ci.x+di, i=1,...,m
*
* @see "S.Boyd and L.Vandenberghe, Convex Optimization, p. 600"
* @author alberto trivellato (alberto.trivellato@gmail.com)
*/
public class SOCPLogarithmicBarrier implements BarrierFunction {
private List socpConstraintParametersList = null;
private int dim = -1;
public SOCPLogarithmicBarrier(List socpConstraintParametersList, int dim) {
this.socpConstraintParametersList = socpConstraintParametersList;
this.dim = dim;
}
public double value(double[] X) {
RealVector x = new ArrayRealVector(X);
double ret = 0;
for(int i=0; i||Ai.x+bi|| < ci.x+di+t, i=1,...,m
* @see "S.Boyd and L.Vandenberghe, Convex Optimization, 11.6.2"
*/
public BarrierFunction createPhase1BarrierFunction(){
final int dimPh1 = dim +1;
List socpConstraintParametersPh1List = new ArrayList();
SOCPLogarithmicBarrier bfPh1 = new SOCPLogarithmicBarrier(socpConstraintParametersPh1List, dimPh1);
for(int i=0; i ||A.x+b|| < c.x+d
*
*/
public class SOCPConstraintParameters{
private RealMatrix A = null;
private RealVector b;
private RealVector c;
private double d;
public SOCPConstraintParameters(double[][] AMatrix, double[] bVector, double[] cVector, double d){
this.A = new Array2DRowRealMatrix(AMatrix);
this.b = new ArrayRealVector(bVector);
this.c = new ArrayRealVector(cVector);
this.d = d;;
}
public RealMatrix getA() {
return A;
}
public RealVector getB() {
return b;
}
public RealVector getC() {
return c;
}
public double getD() {
return d;
}
}
public double getDualityGap(double t) {
return ((double)this.socpConstraintParametersList.size()) / t;
}
}
Ads help maintain this website.