Originally posted by: Yeahoos
Okay, thanks, I see how it works for one constraint. But I still can't do
x1 <= 2*y1
x2 <= 2*y2
using ranges. It works with the GUI: $A$1:$A$2 <= 2*$B$1:$B$2. But I am using the macros. Here is the code I tried:
CPXaddVariable Variable:= ActiveSheet.Cells(1,1), Lb:=0, Ub:= 2
CPXaddVariable Variable:= ActiveSheet.Cells(1,2), Lb:=0, Ub:= 1
CPXaddVariable Variable:= ActiveSheet.Cells(2,1), Lb:=0, Ub:= 2
CPXaddVariable Variable:= ActiveSheet.Cells(2,2), Lb:=0, Ub:= 1
CPXaddConstraint Constraint:=Range(ActiveSheet.Cells(1,1),ActiveSheet.Cells(2,1)), Ub:=2*Range(ActiveSheet.Cells(1,2),ActiveSheet.Cells(2,2))
I get a "Run-Time Error '13': Type mismatch.
#CPLEXOptimizers#DecisionOptimization