function has 3 objectives, but the control object assumes 1

I am using the R programming language. I am using this library here to perform optimization on some function that I defined: CRAN - Package mlrMBO

I wrote the following code for the optimization:

library(mlrMBO)

obj.fn = makeMultiObjectiveFunction(
    name = "My test function",
    fn = function(x1, x2, x3, x4) {
        var_1 <- sin(x1 + x2)
        var_2 <- cos(x1 - x2)
        var_3 <- x1 + x4
        var_4 <- x3 + x4 -7
        goal_1 = sum(var_1 + var_2 + var_3 + var_4)
        goal_2 = var_1 + var_2 - var_3 + var_4
        goal_3 = var_1 + var_2 - var_3 + 2*var_4
        
        return(c(goal_1, goal_2, goal_3))
        
    },
    n.objectives = 3L,
    #define acceptable ranges
    par.set = makeParamSet(
        makeNumericParam("x1", lower = 20, upper = 40),
        makeNumericParam("x2", lower = 30, upper = 45),
        makeNumericParam("x3", lower = 10, upper = 20),
        makeNumericParam("x4", lower = 10, upper = 50)
        #define constraints
        , forbidden = expression(x2 >x1 | x3 > x4)
    ),
    
    minimize=rep(TRUE,3)
)

#create control gird
control=makeMBOControl(propose.points=1, final.method="best.predicted", final.evals=10)
control=setMBOControlTermination(control, iters=10)
control=setMBOControlInfill(control, crit=makeMBOInfillCritEI())

#perform optimization
lrn=makeMBOLearner(control, obj.fn)

res = mbo(obj.fn, design = NULL, learner = lrn, control = control, show.info = TRUE)

This produced the following error:

Warning in generateDesign(n.params * 4L, par.set, fun = lhs::maximinLHS) :
  generateDesign could only produce 15 points instead of 16!
Error in checkStuff(fun, design, learner, control) : 
  Objective function has 3 objectives, but the control object assumes 1.

I tried to correct the code by including 3 objectives:

#create control gird
control=makeMBOControl(propose.points=1, final.method="best.predicted",  n.objectives = 3L, final.evals=10)
control=setMBOControlTermination(control, iters=10)
control=setMBOControlInfill(control, crit=makeMBOInfillCritEI())

#perform optimization
lrn=makeMBOLearner(control, obj.fn)

res = mbo(obj.fn, design = NULL, learner = lrn, control = control, show.info = TRUE)

But this produces a new error :

Warning in generateDesign(n.params * 4L, par.set, fun = lhs::maximinLHS) :
  generateDesign could only produce 15 points instead of 16!
Error in checkStuff(fun, design, learner, control) : 
  Setting of final.method and final.evals for multi-objective optimization not supported at the moment.makes believe that there might be some package limitations that prevent me from 

This makes me believe that perhaps there are package limitations preventing me from doing this? Does anyone have any ideas?

Thanks

Given the message, I would experiment with not setting final.method and final.evals away from the defaults.

1 Like

thank you.. i will keep trying

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.