1#include <iostream>2#include"Lingd11.h"3 #pragmaComment (lib, "Lingd11.lib")4 using namespacestd;5 6 7 intMain ()8 {9 Charcscript[ -];TenMemset (cScript,0, -*sizeof(Char)); one a Plsenvlingo plingo; -Plingo =lscreateenvlng (); - if(!Plingo) the { -cout<<"Can ' t create LINGO environment!"<<endl; - } - DoubleDstatus =1; + intNerror =1; - +Nerror = lsopenlogfilelng (plingo,"Result.log"); a if(nerror) at { -cout<<"Fail Open log!"<<endl; - } - Doubleres[6]; -Memset (res,0,6*sizeof(Double)); - Doublef_num[6] = { -, -, -, -, -, -}; in intnpointersnow; - //@POINTER (1) toNerror = lssetpointerlng (plingo,f_num,&npointersnow); + if(nerror) - { thecout<<"Fail Transfer memory1!"<<endl; * } $ //@POINTER (2)Panax NotoginsengNerror = lssetpointerlng (plingo,res,&npointersnow); - if(nerror) the { +cout<<"Fail Transfer memory!2"<<endl; a } the //@POINTER (2) +Nerror = lssetpointerlng (plingo,&dstatus,&npointersnow); - if(nerror) $ { $cout<<"Fail Transfer memory!3"<<endl; - } - //Lingo running Scripts thestrcpy (cScript,"SET Echoin 1 \ n Take SOLVE. LNG \ n GO \ QUIT \ n"); -Nerror =lsexecutescriptlng (plingo,cscript);Wuyi if(nerror) the { -cout<<"Fail Run lingo!"<<endl; wu } - lscloselogfilelng (plingo); about if(nerror | | dstatus! =Ls_status_global_lng) $ { -cout<<"Unable to solve!"<<endl; - } - lsdeleteenvlng (plingo); a Doubleresult =0; + for(inti =0; I <6; i++) the { -Result + =res[i]; $ } thecout<<"result:"<<result<<endl; the theSystem"Pause"); the return 0; -}
MODEL:SETS:ID/1..6/; NO (ID): x,num; Endsets!to Solve a goal; min.=num (3) * X (1) +x (2) +x (3) +x (4) +x (5) +x (6);!constraint conditions; x (6) +x (1) >=num (1); x (1) +x (2) >=num (2); x (2) +x (3) >=num (3); x (3) +x (4) >=num (4); x (4) +x (5) >=num (5); x (5) +x (6) >=num (6); x (1) >=num (1);D Ata:!the data in the VC m_num1,..., M_NUM6 passed to the lingo variable num1,..., num6;num[email protected] (1);!the results and states of lingo calculation are transferred to the variable Res,dstatus in VC respectively. @POINTER (2)=x; @POINTER (3)=@STATUS (); Enddataend
Lingo with high-level language connections (c + +) for example
http://blog.csdn.net/ds1231h/article/details/52383707
Lingo and VC mixed programming
Http://wenku.baidu.com/link?url= 4upzs0tb8qzzmbzxskuj7y-pqymxwlwtetxpilvcbbnaddhmmhrmdwr49ofa8jbgvn2lgumk7buvlyjrhii8g490dgtp1ljvz-7civwkmme
Lingo and advanced language mixed programming
Http://blog.chinaunix.net/uid-29764914-id-4459488.html
VC + + and lingo programming