How to write divided by in objective function

33 views Asked by At

My problem is multi-objective optimization problem. The expression for the objective function is given below:

Maximize (w1F1 + w2(1/F2))

w1 and w2 are weighting of two objective function F1 and (1/F2)

I want to write the code in OPL CPLEX.

So if I am writing the objective function as - Maximize (w1F1 + w2(1/F2))

The error that I am getting in OPL Cplex is - CPLEX(default) cannot extract expression: 1 / F2

1

There are 1 answers

5
Alex Fleischer On

A simple way is to use CP within CPLEX as can be seen at https://github.com/AlexFleischerParis/zooopl/blob/master/zoononlinear.mod

using CP;

// CPOptimizer allows all kind of non linearities

int nbKids=300;
float costBus40=500;
float costBus30=400;
 
dvar int+ nbBus40;
dvar int+ nbBus30;
 
// Non linear objective (exponential) 
minimize
 costBus40*exp(nbBus40) +exp(nbBus30)*costBus30;
 
subject to
{
 40*nbBus40+nbBus30*30>=nbKids;
} 

If I change this to use 1/x , I can write

using CP;

// CPOptimizer allows all kind of non linearities

int nbKids=300;
float costBus40=500;
float costBus30=400;
dvar int+ nbBus40 in 1..10;
dvar int+ nbBus30 in 1..10;
 

minimize
 costBus40/nbBus40 +costBus30/nbBus30;
 
subject to
{
 40*nbBus40+nbBus30*30>=nbKids;
}