-------- Forwarded Message --------
From: Passorelli, Curtis <[email protected]>
To: [email protected] <[email protected]>
Subject: VBA dll call
Date: Wed, 4 Jan 2017 19:34:29 +0000



Hello,

 

I have been working with the GLPK API. I can get most of the functions
working except when it comes to matrices.

I am trying to fill up the constraint matrix, and it errors out and
shuts down Excel.

 

Are there any obvious mistakes?

 

Thanks for all of your hard work,

 

Curtis Passorelli


 

THE INFORMATION CONTAINED IN THIS E-MAIL MESSAGE AND ANY ATTACHMENTS
SENT FROM GENTEX CORPORATION IS GENTEX CONFIDENTIAL INFORMATION INTENDED
ONLY FOR THE PERSONAL USE OF THE INDIVIDUAL OR ENTITY NAMED ABOVE. If
you are not the intended recipient, you are hereby notified that any
review, distribution, or copying of this communication is strictly
prohibited. If you have received this communication in error, please
immediately notify the sender by return e-mail, and delete this e-mail
message and any attachments from your computer.

 



Private Declare Function glp_create_prob Lib 
"C:\Users\curtis.passorelli\Desktop\GLPK_VBA_API\glpk_4_27.dll" () As Long
Private Declare Sub glp_add_rows Lib 
"C:\Users\curtis.passorelli\Desktop\GLPK_VBA_API\glpk_4_27.dll" (ByVal lp As 
Long, ByVal nrs As Integer)
Private Declare Sub glp_add_cols Lib 
"C:\Users\curtis.passorelli\Desktop\GLPK_VBA_API\glpk_4_27.dll" (ByVal lp As 
Long, ByVal ncs As Integer)
Private Declare Sub glp_load_matrix Lib 
"C:\Users\curtis.passorelli\Desktop\GLPK_VBA_API\glpk_4_27.dll" (ByVal lp As 
Long, ByVal ne As Integer, ByRef ia() As Integer, ByRef ja() As Integer, ByRef 
ar() As Double)

Sub Test()

        Dim lp As Long
    Dim ia(1 To 9) As Integer
    Dim ja(1 To 9) As Integer
    Dim ar(1 To 9) As Double
        
        lp = glp_create_prob()
        
        Call glp_add_rows(lp, 3)
        Call glp_add_cols(lp, 3)
        
        ' populate arrays
    ia(1) = 1
    ia(2) = 1
    ia(3) = 1
    ia(4) = 2
    ia(5) = 2
    ia(6) = 2
    ia(7) = 3
    ia(8) = 3
    ia(9) = 3

    ja(1) = 1
    ja(2) = 2
    ja(3) = 3
    ja(4) = 1
    ja(5) = 2
    ja(6) = 3
    ja(7) = 1
    ja(8) = 2
    ja(9) = 3

    ar(1) = 1
    ar(2) = 1
    ar(3) = 1
    ar(4) = 10
    ar(5) = 4
    ar(6) = 5
    ar(7) = 2
    ar(8) = 2
    ar(9) = 6
        
        ' causes Excel to shut down
        Call glp_load_matrix(lp, 9, ia, ja, ar)

End sub
_______________________________________________
Help-glpk mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-glpk

Reply via email to