Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a feasible model turns out to be infeasible randomly #4199

Closed
disonvon opened this issue Apr 25, 2024 · 5 comments
Closed

a feasible model turns out to be infeasible randomly #4199

disonvon opened this issue Apr 25, 2024 · 5 comments
Assignees
Labels
Help Needed Modeling/Usage problem Solver: CP-SAT Solver Relates to the CP-SAT solver
Milestone

Comments

@disonvon
Copy link

disonvon commented Apr 25, 2024

What version of OR-Tools and what language are you using?
Version: 9.8
Language: python

Which solver are you using (e.g. CP-SAT, Routing Solver, GLOP, BOP, Gurobi)
CP-SAT
What operating system (Linux, Windows, ...) and version?
Mac Apple M2 Mac Os 13.0
What did you do?
Steps to reproduce the behavior:
a text model file return different solution status, sometimes it is feasible, sometimes not

What did you expect to see
the feasible status should be consistent, which is feasible in my case
What did you see instead?
as above mentioned
Make sure you include information that can help us debug (full error message, model Proto).

#coding=utf-8
from ortools.sat.python import cp_model
from google.protobuf import text_format
import pickle
import os

def solve(file):
    model = cp_model.CpModel()
    with open(file, "r") as file:
        text_format.Parse(file.read(), model.Proto())

    # Create a solver and solve
    solver = cp_model.CpSolver()
    solver.parameters.max_time_in_seconds = 120
    # solver.parameters.log_search_progress = True
    status = solver.Solve(model)

    # Check the solution
    if status == cp_model.OPTIMAL:
        print('Objective value =', solver.ObjectiveValue())
    elif status == cp_model.FEASIBLE:
        print('A potentially suboptimal solution was found.')
    elif status == cp_model.INFEASIBLE:
        print('The problem is infeasible.')
    else:
        print('ohter status')


if __name__ == '__main__':
    file = './../../output/test.pd.txt'
    for i in range(1, 10):
        print(f'----------iteration: {i}----------')
        solve(file)

    print('done')

----------iteration: 1----------
Objective value = 283621783174.0
----------iteration: 2----------
The problem is infeasible.
----------iteration: 3----------
The problem is infeasible.
----------iteration: 4----------
The problem is infeasible.
----------iteration: 5----------
The problem is infeasible.
----------iteration: 6----------
The problem is infeasible.
----------iteration: 7----------
The problem is infeasible.
----------iteration: 8----------
The problem is infeasible.
----------iteration: 9----------
The problem is infeasible.
done

Anything else we should know about your project / environment

@disonvon
Copy link
Author

disonvon commented Apr 25, 2024

test.pd.txt.zip

@disonvon
Copy link
Author

model file attached above

@lperron
Copy link
Collaborator

lperron commented Apr 25, 2024

Can you try with 9.9 ?

@disonvon
Copy link
Author

Can you try with 9.9 ?

9.9 is always feasible(optimal) for this model.
BTW, i also encountered the similar cases months ago with 9.4

@lperron lperron closed this as completed Apr 25, 2024
@lperron
Copy link
Collaborator

lperron commented Apr 25, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help Needed Modeling/Usage problem Solver: CP-SAT Solver Relates to the CP-SAT solver
Projects
None yet
Development

No branches or pull requests

3 participants