Skip to content

Add bindings for update_vector_data and update_matrix_data.#4

Open
JonasBreuling wants to merge 4 commits intoqoco-org:mainfrom
JonasBreuling:update_data
Open

Add bindings for update_vector_data and update_matrix_data.#4
JonasBreuling wants to merge 4 commits intoqoco-org:mainfrom
JonasBreuling:update_data

Conversation

@JonasBreuling
Copy link

This PR adds python bindings for update_vector_data and update_matrix_data. It depends on qoco-org/qoco#44 since minor changes to the C-code are required.

@govindchari
Copy link
Member

Looks good, but can you add some unit tests to test out the new update functions?

@JonasBreuling
Copy link
Author

JonasBreuling commented Mar 7, 2026

I've added some tests and removed the returns.

res2 = prob.solve()
assert res2.status in ["QOCO_SOLVED", "QOCO_SOLVED_INACCURATE"]
# Objective should be different after update
assert abs(res2.obj - obj1) > 1e-6 or True # Allow for some tolerance
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this always be True since you are asserting (something or True)?

# Solve updated problem
res2 = prob.solve()
assert res2.status in ["QOCO_SOLVED", "QOCO_SOLVED_INACCURATE"]
# Objective should be different after update
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test should be checking whether the modified problem is returning the correct answer as well, not just the objective being different. I would suggest setting up a simple problem with a known optimal objective and checking against that objective.


# Solve initial problem
res1 = prob.solve()
assert res1.status in ["QOCO_SOLVED", "QOCO_SOLVED_INACCURATE"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should only check against QOCO_SOLVED

@JonasBreuling
Copy link
Author

I will work on the tests. Currently, my workload is huge, so this will take a few weaks. Do you have similar test cases in the C++ code that I can reuse?

@govindchari
Copy link
Member

I have a few here which are named some variation of "update data test": https://github.com/qoco-org/qoco/blob/main/tests/simple_tests/missing_constraints_test.cpp

2 similar comments
@govindchari
Copy link
Member

I have a few here which are named some variation of "update data test": https://github.com/qoco-org/qoco/blob/main/tests/simple_tests/missing_constraints_test.cpp

@govindchari
Copy link
Member

I have a few here which are named some variation of "update data test": https://github.com/qoco-org/qoco/blob/main/tests/simple_tests/missing_constraints_test.cpp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants