Hi I am using java with cplex

I am trying to maximize an equation and i want to consider the object even if it is a negative value.

I declared about my object variable like that

IloNumVar profit = cplex.numVar(0, Double.MAX_VALUE, "profit");

when i use this code the object value will be zero because it is negative

Do you have any suggestion to do that ?

asked 27 Oct '14, 06:50

ibrahem's gravatar image

accept rate: 0%

You should not put a lower bound of zero on your variable if you want it to take negative values as well. I don't know the java-API but I could imagine it should look something like

IloNumVar profit = cplex.numVar(-IloInfinity, IloInfinity, "profit");

answered 27 Oct '14, 08:51

Sune's gravatar image

accept rate: 20%

edited 27 Oct '14, 08:52

Thank you very much

(27 Oct '14, 09:00) ibrahem

In the Java API, the way to represent infinity (signed) is Double.NEGATIVE_INFINITY or Double.POSITIVE_INFINITY.

(28 Oct '14, 16:24) Paul Rubin ♦♦
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: 27 Oct '14, 06:50

Seen: 1,316 times

Last updated: 28 Oct '14, 16:24

OR-Exchange! Your site for questions, answers, and announcements about operations research.