Forum Discussion
FICO
9 years agoCommunity Manager
Bynary variables giving non-binary solutions...
So I have been working on a model that uses different linear constrains based on which binarie is activated. For my initial problem all the linear constrains are exactly the same one.
The problem works well and gives logical results, until I add a constrain that link all the binaries together and suddenly the solution has a lot of non-binaries values, between 0 and 1. I have never seen this problem before and haven't found yet a solution, so I come to see if someone has an answer here.
The code (more or less):
... (Declaring and defining values for most things)
forall(i in n) B(i) is_binary
forall(i in n) P(i)<= B(i)*Pmax !Only the P with the correct Binary will have a non-zero value
sum(P(1) + .. +P(n) + Pg - Pneg = Load) !the main contrain
sum(B(i)) <= 1 !So only 1 Binary (and thus linear constrain) is activated at the same time
forall(t in T) S(t) = S(t-1) + sum(P(1) + .. +P(n) - Pneg
forall(t in T) sum(B(i,s)*alfa_min(i,s)) <= S(t) <= sum(B(i,s)*alfa_max(i,s)) !This is the constraint that causes problems,which dictates the binary is active in each period.
When I add the last constrain, suddenly I get B(i) = 0.3 and other non-sense. I also see negative results for non-free varables
Any suggestion on how to deal with this problem or what I am doing wrong?
1 Reply
- FICOCommunity Manager
Have you checked the status of your problem before retrieving the solution values?
If you are working with Mosel, you could for example use code like the following:
!...solve...
if getprobstat<>XPRS_OPT then
writeln("No solution")
exit(0)
end-if
!...retrieve results...
Related Content
Related Content
Has anyone seen an issue with binary variables becoming non-binary?
I'm new to the community and fairly new to xpress. I've attached my code for the project (both as text and PDF). Whenever I am running this code, I am getting a solution but my solutions are not bina...6 years agoPlace FICO® Xpress Optimization ForumFICO® Xpress Optimization Forum1 unread comment1 unread0Views0likes1CommentMIP solution status
Hello, I've been using code like this to get the solution status of a MIP: case getprobstat of XPRS_OPT: status:="Optimum found" XPRS_UNF: status:="Unfinished" XPRS_INF: status:="Infeasib...5 months agoPlace FICO® Xpress Optimization ForumFICO® Xpress Optimization Forum3 unread comments3 unread7Views0likes3CommentsVariable names in callback (Java API)
I construct a cut in a preintsol callback using variables from the model containing the callback. When constructing the model, I give the variables names (using withName(...)) and store them in a vec...9 months agoPlace FICO® Xpress Optimization ForumFICO® Xpress Optimization Forum4 unread comments4 unread1View0likes4Comments