binary variable

38 views
Skip to first unread message

Zoro Roronoa

unread,
Feb 18, 2019, 9:50:03 AM2/18/19
to AMPL Modeling Language
Hi all ~~

I'm solving a nonlinear problem that contain binary variables . I solve my problem and get infeasible solution , then i try to display my variables and try to understand which part goes wrong. I found that the variable that I set to binary doesn't actually have the value 0 or 1 , it shows real number. I'm not sure it's the infeasible solution cause it or I set the variable to binary the wrong way. 

I followed the AMPL book (ch.20 Integer Linear program) and set the binary variable this way.

var sw {bus,cbus} binary; 

Thanks,

zoro

AMPL Google Group

unread,
Feb 18, 2019, 1:05:23 PM2/18/19
to Ampl Modeling Language
The first thing that the solver does is to compute a bound on the solution, by relaxing all of the "x is binary" restrictions to "0 <= x <= 1". The solver optimizes this relaxed problem and produces a solution in which some of the variables are fractional. Then the solver looks for a solution to the original problem, in which all the binary variables have to be 0 or 1. If it can't find any 0-1 solution, it reports "infeasible" and it may return the fractional solution instead.

So the short answer is, that your variable is defined correctly. You are seeing a fractional solution because there does not exist any solution that has all of the binary variables being 0 or 1, and that also satisfies all of the constraints.

To fix this problem, you will need to look for errors in your model and/or your data. As a start it can be helpful to try dropping some constraints (using the AMPL "drop" and "restore" commands); if you drop some constraints and the problem is still infeasible, then you know that the dropped constraints are not involved in causing the infeasibility. (Some linear/quadratic solvers can automate this process, but you mention that you have a nonlinear problem.)

--
Robert Fourer
am...@googlegroups.com
{#HS:781853794-36606#}

Zoro Roronoa

unread,
Feb 18, 2019, 8:24:30 PM2/18/19
to AMPL Modeling Language
Hi Robert ,

Thanks,your answer really helps me a lot.

Zoro

AMPL Google Group於 2019年2月19日星期二 UTC+8上午2時05分23秒寫道:
Reply all
Reply to author
Forward
0 new messages