[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-glpk] Error : multiplication of linear forms not allowed

From: Andrew Makhorin
Subject: Re: [Help-glpk] Error : multiplication of linear forms not allowed
Date: Sun, 4 Apr 2010 15:12:10 +0400

>> You need to introduce auxiliary binary variables, say, z[i], where
>> z[i] = P[i] * P[i+1]. Assuming that all P[i] are binary, this equality
>> can be replaced by the following equivalent constraint:
>>    0 <= P[i] + P[i+1] - 2 * z[i] <= 1
>> that allows you avoiding multiplication.
> Thanks for the reply. I want to code this using a C++. Can you please
> let me know how to specify such constraint using GLPK C API.

You need to add auxilary binary variables z[i] with glp_add_cols and
glp_set_col_kind. Then to add every constraint like above you need to
call glp_add_rows, glp_set_row_bnds, and glp_set_mat_row. For more
details please see the glpk reference manual included in the package

reply via email to

[Prev in Thread] Current Thread [Next in Thread]