Hi!
I'd assume, that the language does not support something like this.
Others will tell if I'm wrong.
I don't know your special use-case, but I'd generally speak against such
a practice. It seems cleaner if one knows whether a variable is integer
or not.
However, if this would make the rest of the model cleaner, and it is
more important than efficiency, you can always do this:
set intset;
set contset;
set all := intset union contset;
var intvar {intset} integer;
var mixedvar {all} >=0;
s.t. foobar{i in intset}:
intvar[i] = mixedvar[i];
I thought that the presolver would maybe kick in and remove the
unnecessary variables, but it doesn't seem to do so. (v4.65)
I haven't tried commercial solvers, but I'd assume they do.
All the best!
Mate
On 2022. 03. 15. 7:26, Anku Pandey wrote:
Hi,
I have to formulate a problem in mathprog where a variable can be both
integer type and continuous type based on index.
Let me give an example to further illustrate this.
I have two sets of items:
set itemInteger;
set itemContinuous;
I need to define a variable, awardQuantity, on these sets so that for
items in the set itemInteger, it is of type Integer and for items in set
itemContinuous, it is of type continuous.
I know I can define two different variables:
var awardQuantityInt[i in itemInteger], integer;
var awardQuantityCont[i in itemContinuous];
But that is not what I am looking for.
I want a single variable handling both types.
I would really appreciate it if I can get some help on it. I have been
trying to find an answer to this for a few days now.
Thanks,
Anku