Skip to content

Problem with function gp in package cccp

2 messages · koiier m@iii@g oii scie@ce@iwi@@c@@t, Jeff Reichman

#
Thank you, Jeff and Bert!

1. As to the unconstrained problem I gave (which is not my main concern) 
I should have added that in geometric programming it is assumed that the 
target variables are positive, thus x,y > 0. This would also rule out my 
given solution, (0, 0), of the unconstrained problem. The positivity 
constraint in geometric programming is a consequence of the role the 
logarithmic transformation plays in the theory of geometric programming.

2. However, my concern is to find out how to define equality constraints 
and submit them as an argument to gp(), so I wanted to try out the most 
simple case. But it seems as gp() implicitely assumes there must be at 
least inequality constraints. If I add inequality constraints, then my 
equality constraints are not ignored by gp(). So, in the following 
example, I added a non-binding inequality constraint, and I receive the 
correct solution, this time for the correct reasons:

## Minimise P + Q subject to P*Q = 1 and 0.5*P^(-1)*Q^(-1) <= 1
F0 <- diag(2)                       #  [m0 * n] m0 = number of terms of 
the posynomial, n = number of variables
g0 <- log(matrix(1,2,1))            #  [m0 * 1]
bexp <- 1
A <-  matrix(c(1,1), 1, 2)          #  one constraint, one row
b <-  log(matrix(bexp, 1, 1))
F1 <- matrix(c(-1,-1), 1, 2)        #  additional (redundant) inequality 
constraint [m1 * n] m1 = number of terms of the posynomial
g1 <- log(matrix(0.5*bexp, 1, 1))   #  [m1 * 1]
RES <- gp(F0, g0, FList=list(F1), gList=list(g1), A=A, b=b)
sol <- RES$pdv$x
c(sol)  # [1] 1 1
RES <- gp(F0, g0, FList=list(F1), gList=list(g1))  # without the 
equality constraint
sol <- RES$pdv$x
c(sol)  # [1] 0.7071069 0.7071069

Best regards,

Wolfgang






Am 2025-08-01 04:18, schrieb Jeff Reichman:
#
So its that gp() wouldn't even activate equality constraints unless it also
saw inequality ones. Interesting


-----Original Message-----
From: R-help <r-help-bounces at r-project.org> On Behalf Of
koller at science.iwi.ac.at
Sent: Friday, August 1, 2025 10:40 AM
To: r-help at r-project.org
Subject: Re: [R] Problem with function gp in package cccp

Thank you, Jeff and Bert!

1. As to the unconstrained problem I gave (which is not my main concern) I
should have added that in geometric programming it is assumed that the
target variables are positive, thus x,y > 0. This would also rule out my
given solution, (0, 0), of the unconstrained problem. The positivity
constraint in geometric programming is a consequence of the role the
logarithmic transformation plays in the theory of geometric programming.

2. However, my concern is to find out how to define equality constraints and
submit them as an argument to gp(), so I wanted to try out the most simple
case. But it seems as gp() implicitely assumes there must be at least
inequality constraints. If I add inequality constraints, then my equality
constraints are not ignored by gp(). So, in the following example, I added a
non-binding inequality constraint, and I receive the correct solution, this
time for the correct reasons:

## Minimise P + Q subject to P*Q = 1 and 0.5*P^(-1)*Q^(-1) <= 1
F0 <- diag(2)                       #  [m0 * n] m0 = number of terms of 
the posynomial, n = number of variables
g0 <- log(matrix(1,2,1))            #  [m0 * 1]
bexp <- 1
A <-  matrix(c(1,1), 1, 2)          #  one constraint, one row
b <-  log(matrix(bexp, 1, 1))
F1 <- matrix(c(-1,-1), 1, 2)        #  additional (redundant) inequality 
constraint [m1 * n] m1 = number of terms of the posynomial
g1 <- log(matrix(0.5*bexp, 1, 1))   #  [m1 * 1]
RES <- gp(F0, g0, FList=list(F1), gList=list(g1), A=A, b=b) sol <- RES$pdv$x
c(sol)  # [1] 1 1
RES <- gp(F0, g0, FList=list(F1), gList=list(g1))  # without the equality
constraint sol <- RES$pdv$x
c(sol)  # [1] 0.7071069 0.7071069

Best regards,

Wolfgang






Am 2025-08-01 04:18, schrieb Jeff Reichman:
______________________________________________
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
https://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.