tests/testthat/test_isMultiobjective.R

context("isMultiobjective/isSingleObjective")

test_that("is{Multi,Single}objective works fine", {
	fn = makeSingleObjectiveFunction(
		name = "Single-objective function",
		fn = function(x) x^2,
		par.set = makeNumericParamSet(id = "x", len = 2L)
	)
	expect_false(isMultiobjective(fn))
	expect_true(isSingleobjective(fn))

	fn = makeMultiObjectiveFunction(
		name = "Multi-objective function",
		fn = function(x) c(x^2, exp(x)),
		n.objectives = 2L,
		par.set = makeNumericParamSet(id = "x", len = 1L),
    ref.point = c(11, 11)
	)

	expect_true(isMultiobjective(fn))
	expect_false(isSingleobjective(fn))
	expect_equal(getNumberOfObjectives(fn), 2L)
  expect_equal(getRefPoint(fn), c(11, 11))
})

Try the smoof package in your browser

Any scripts or data that you put into this service are public.

smoof documentation built on Aug. 14, 2017, 5:02 p.m.