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)  



Installing Rcplex



 sudo R CMD INSTALL --configure-args="PKG_CFLAGS='-m64 -fPIC' PKG_CPPFLAGS=-I/opt/ibm/ILOG/CPLEX_Studio124/cplex/include PKG_LIBS='-L/opt/ibm/ILOG/CPLEX_Studio124/cplex/lib/x86-64_sles10_4.1/static_pic -lcplex -m64 -lm -lpthread'" Rcplex_0.3-0.tar.gz  


Sunday, July 15, 2012

sending sbackup reporting

I don't know how to send emails only when errors occur, but it can send emails every time backup happens.

Add following to /etc/sbackup.conf

[report]  
 from = SBackup Daemon   
 to = ****@gmail.com  
 smtpserver = smtp.gmail.com  
 smtpuser = ****@gmail.com  
 smtppassword = ****  
 smtpport = 587  
 smtptls = 1  

send emails when mdadm errors occur

 # instruct the monitoring daemon where to send mail alerts  
 MAILADDR sangoh@gmail.com  
 MAILFROM icme-leconte-mdadm  

msmtp settings for sending mail through gmail

msmtp can send email through gmail.
If you do not run mail server on your linux desktop, you can still use msmtp, which has same interface as sendmail.

msmtp can be used to send system emails because of this sendmail interface.
This is working /etc/msmtprc on my system

 defaults  
 tls on  
 tls_starttls on  
 tls_trust_file /etc/ssl/certs/ca-certificates.crt  
   
 account default  
 host smtp.gmail.com  
 port 587  
 auth on  
 user ****@gmail.com  
 password ********  
 from ****@gmail.com  
 logfile /var/log/msmtp.log  


ref: http://www.absolutelytech.com/2010/07/17/howto-configure-msmtp-to-work-with-gmail-on-linux/