Thursday, July 19, 2012

Quadratic Constrained Quadratic Program with cplex and Rcplex

Once cplex and Rcplex, an interface package for R, have been installed, following private function can be used to perform QCQP (Quadratic Constrained Quadratic Program).


 #######################################  
 ## Q1: QCQP with inactive constraint ##  
 ## xopt=c(0.00,0.4) ##  
 #######################################  
   
 ## Quadratic Objective  
 Qmat <- 2 * diag(2)  
   
 ## Linear Constraint  
 Amat <- matrix(0,2,2) ## no linear constraint  
 bvec <- c(0,0) ## no linear constraint  
   
 ## Quadratic Constraint  
 QC <- list(  
 QC=list(  
 Q=list(diag(2)),  
 L=list()),  
 dir="L",  
 b=1^2)  
 cvec <- 2 * c(0,-0.4)  
   
 ## Solve  
 Rcplex:::Rcplex_solve_QCP(cvec=cvec,Amat=Amat,bvec=bvec,sense="E",Qmat=Qmat,QC=QC,lb=-Inf)  
   
 #######################################  
 ## Q2: QCQP with active constraint ##  
 ## xopt=c(0.00, 0.13) ##  
 #######################################  
   
 ## Quadratic Objective  
 Qmat <- 2 * diag(2)  
   
 ## Linear Constraint  
 Amat <- matrix(0,2,2) ## no linear constraint  
 bvec <- c(0,0) ## no linear constraint  
   
 ## Quadratic Constraint  
 QC <- list(  
 QC=list(  
 Q=list(diag(2)),  
 L=list()),  
 dir="L",  
 b=0.13^2)  
 cvec <- 2 * c(0,-0.4)  
   
 Rcplex:::Rcplex_solve_QCP(cvec=cvec,Amat=Amat,bvec=bvec,sense="E",Qmat=Qmat,QC=QC,lb=-Inf)  



1 comment:

  1. Hello,

    Does this function solve a mixed integer SOCP problem as well? Thanks in advance.

    Regards,
    Shima.

    ReplyDelete