[R] Optimizing with constraints using alabama

Depratti, Roland A. (Student) ro|@nd@depr@tt| @end|ng |rom my@cc@u@edu
Mon Mar 20 19:46:23 CET 2023


Hi,

    I am testing code that is working successfully using constrOptim. I am replacing constrOptim with other solvers to compare benefits and performance.

    My belief was that, like constrOptim,  auglag in the alabama package would eliminate beta vectors that failed the constraints prior to calling the objective
    function. These betas are not only not in the solution space but also cause chaos for my objective function.

    I can see via debugging that hin is working correctly, but I am finding that these beta vectors are being passed to the objective function. I am not sure if this is
    due to my ineptness or if it is doing so as planned. The auglag documentation talks about applying penalties, so I assume it has examined the vector coming out
    of hin.  I would be pleased to have input from those more knowledgeable than me. If this is by design is there a flag variable available to be examined by my
    objective function. Currently, I am calling hin again within my objective function - certainly not an optimum solution.

Thanks,

Roland DePratti
Graduate Student
Central Connecticut State University Data Science Program

Here is my inequality constraint logic:


X (constraint matrix) =

    1  2  3  4 partyDem
1   -1  0  0  0        0
2   -1  0  0  0       -1
3    0  0  0 -1        0
4    0  0  0 -1       -1
5    0 -1  0  0        0
6    0 -1  0  0       -1
7    0  0 -1  0        0
8    0  0 -1  0       -1
9    0  0  0 -1        0
10   0  0  0 -1       -1
11  -1  0  0  0        0
12  -1  0  0  0       -1
13   0 -1  0  0        0
14   0 -1  0  0       -1
15   0  0 -1  0        0
16   0  0 -1  0       -1
17  -1  1  0  0        0
18  -1  1  0  0        0
19   0 -1  1  0        0
20   0 -1  1  0        0
21   0  0 -1  1        0
22   0  0 -1  1        0


hin <- function(par,X,Xa1,XaJ,Xaj1,Xaj2) {
  out <- X %*% par
  return(out)
}



	[[alternative HTML version deleted]]



More information about the R-help mailing list