0

I'm trying to take the ceiling of one of my decision variables times 2.5, in my Solver goal function, but the Math.Ceiling() function can't be applied because the foobar variable isn't a double, it's a "term" variable. Is there another way I can express this same code, that will work in Solver?

Decision foo = new Decision(Domain.IntegerNonnegative, "bar");
model.AddDecision(foo);

model.AddGoal("foobar", GoalKind.Maximize, Math.Ceiling(2.5 * foobar));
economistdolly
  • 395
  • 4
  • 20

1 Answers1

0

The Model class contains a large number of static methods that performs arithmetic operations on Term objects rather than double:s. You'll find most, if not all, of the operations that are available in the Math class.

In particular, you should be able to change your goal function to use Model.Ceiling.

Anders Gustafsson
  • 15,837
  • 8
  • 56
  • 114
  • Using the function Model.Ceiling I get the error: `No solver could be found that can accept the model given the model type and directive(s)` Any thoughts on that? – economistdolly Sep 24 '12 at 14:57
  • Can't say for sure, but you have set `foo` to an integer domain decision. What happens if you set `foo` to be a floating-point decision instead? – Anders Gustafsson Sep 24 '12 at 15:40