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

ibrahem
35
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");
link

answered 27 Oct '14, 08:51

Sune's gravatar image

Sune
958413
accept rate: 20%

edited 27 Oct '14, 08:52

Thank you very much

(27 Oct '14, 09:00) ibrahem
2

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

By RSS:

Answers

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

Tags:

×191
×7

Asked: 27 Oct '14, 06:50

Seen: 1,172 times

Last updated: 28 Oct '14, 16:24

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