GithubHelp home page GithubHelp logo

Duals from QP can be incorrect about highs.jl HOT 1 CLOSED

odow avatar odow commented on August 21, 2024
Duals from QP can be incorrect

from highs.jl.

Comments (1)

odow avatar odow commented on August 21, 2024

With

diff --git a/src/interfaces/highs_c_api.cpp b/src/interfaces/highs_c_api.cpp
index 821b39e18..5806b60f1 100644
--- a/src/interfaces/highs_c_api.cpp
+++ b/src/interfaces/highs_c_api.cpp
@@ -463,6 +463,9 @@ HighsInt Highs_getBasis(const void* highs, HighsInt* col_status,
   for (HighsInt i = 0; i < (HighsInt)basis.row_status.size(); i++) {
     row_status[i] = (HighsInt)basis.row_status[i];
   }
+  if (!basis.valid) {
+    return kHighsStatusError;
+  }
   return kHighsStatusOk;
 }

and

#include "interfaces/highs_c_api.h"

#include <stdlib.h>
#include <assert.h>

int main(int argc, char *argv[]) {
    void* highs = Highs_create();
    double inf = Highs_getInfinity(highs);
    int num_col = 2;
    int num_row = 1;
    int num_nz = 2;
    int q_num_nz = 3;
    int a_format = kHighsMatrixFormatColwise;
    int q_format = kHighsHessianFormatTriangular;
    int sense = kHighsObjSenseMinimize;
    double offset = 0.0;
    double col_cost[] = {1.0, 1.0};
    double col_lower[] = {-inf, -inf};
    double col_upper[] = {inf, inf};
    double row_lower[] = {-inf};
    double row_upper[] = {-1.0};
    int a_start[] = {0, 1};
    int a_index[] = {0, 0};
    double a_value[] = {1.0, 1.0};
    int q_start[] = {0, 2};
    int q_index[] = {0, 1, 1};
    double q_value[] = {4.0, 1.0, 2.0};
    int integrality[] = {kHighsVarTypeContinuous, kHighsVarTypeContinuous};
    int ret;
    ret = Highs_passModel(highs, num_col, num_row, num_nz, q_num_nz, a_format,
                          q_format, sense, offset, col_cost, col_lower,
                          col_upper, row_lower, row_upper, a_start, a_index,
                          a_value, q_start, q_index, q_value, NULL);
    assert(ret == 0);
    ret = Highs_run(highs);
    assert(ret == 0);
    int col_basis_status[] = {-123, -123};
    int row_basis_status[] = {-123};
    ret = Highs_getBasis(highs, col_basis_status, row_basis_status);
    assert(ret == 0);
    Highs_destroy(highs);
    return 0;
}

I get

(base) oscar@Oscars-MBP examples % export highs=/Users/Oscar/Documents/Code/HiGHS/build;
(base) oscar@Oscars-MBP examples % export DYLD_LIBRARY_PATH=$highs/lib; ./main
Running HiGHS 1.5.1 [date: 2023-04-12, git hash: 46574b917-dirty]
Copyright (c) 2023 HiGHS under MIT licence terms
0, 1.000000, 1, 0.000768, 0.000000, 0, 0.000000, 0.000000
3, -0.125000, 1, 0.000844, 0.000000, 0, 0.000000, 1.000000
Model   status      : Optimal
QP ASM    iterations: 3
Objective value     : -1.2500000000e-01
HiGHS run time      :          0.00
Assertion failed: (ret == 0), function main, file main.c, line 40.
zsh: abort      ./main

Let me know if you want me to make a PR. At the very least, we should signal that the basis isn't valid instead of always returning kHighsStatusOk.

from highs.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.