Question

I just learn GLPK tool to solve my math model.

Actually, my model will use power operator that make this problem into nonlinear problem.

The briefly code like:

set  I;

var x{I} binary;

var V{I};

maximize M: sum{i in I} V[i];

subject to C1: sum{i in I} x[i] <=1;

subject to C2{i in I}: V[i] = 2^x[i];  

//I want to use variable x to compute V, and my objective function dependent on V

data;

set I := i1 i2 i3;

I want to ask is this problem reasonable or not? Is it possible to solve by GLPK? I try to use some conditional expressions to achieve my object, but I'm not familiar with this language. Are there any other tool can solve problem like this? Thanks for help.

Was it helpful?

Solution

MILP solvers like GLPK require your constraints to be linear. Since the power operator is nonlinear you run into problems.

There is a simple solution for converting

  V[i] == 2^x[i] 

to a linear expression, when x[i] is a binary variable. When x[i] = 0, V[i] = 2^0 = 1. When x[i] = 1, V[i] = 2^1 = 2. So you can express V[i] as

  V[i] == 1 + x[i]

When x[i] = 0, 1 + x[i] = 1. When x[i] = 1, 1 + x[i] = 2.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top