ӭ
ղرվ
 
 
   ǰλ>>վҳ>>ϸϢ

η

ʱ䣺2013-01-05 4271


";

            For(var j=0;j<ģͱ+2;j++){

                  If((j==0&&i==0)||(j==(ģͱ+1)&&(i==Լ+1))){

                    str=str+"

";

                  }

                  Else If(i==0){

                          If(j==ģͱ+1){ str=str+"

";}

                       Else

                          str=str+"

";

}

                     Else If(j==0){

                        If(i==Լ+1){str=str+"

";}

                        Else

                           str=str+"

";

                  }

                  Else If(i==Լ+1&&j!=0){

                     str=str+"

";

                  }

                  Else

                     str=str+"

";

                }

               str=str+"

";

          }

2.ݴάĹؼ㷨

For(var i=0; i

    For(var j=0;j

        If(i==0&&j

           conArray[i][j]=$(".cells")[j].value;

        }

        Else If(j==varNum&&i>0){

              conArray[i][j]=$(".sign"+(i))[0].value;

        }

        Else if(i>0){

        If(j==varNum+1)

        conArray[i][j]=$(".cells"+i)[j-1].value;

        Else

        conArray[i][j]=$(".cells"+i)[j].value;

        }

       }

  }

˵ʹjquery﷨$(.cells)Ϊ˼򻯱ֻ̱̣ʹjqueryѡjavaScriptdocument.getElementById().cells͡.signǰ˵ÿеclassԡ

 

2.2ʾԹ滮ѧģģ

2.2.1ģ

ʾĿ꺯ݱVarNumʾԹ滮ģͣMax Z=Ŀ꺯Ĺ̶ʾʽĿ꺯ϵͱ±ǸÿеԪغͱVarNumġʾķʽݱIJֱͬ﷽һX(i)Ҫϡ+ţһҪϡ+,ͬʱҪԼϵǸҲҪϡ+šĿ꺯ʾˡ

ԼʾԼһǸԼԼConNumʾԼVarNum+1ʾ»ҪʾԼbԼϵԼԼϵConArray()СһԼǰҪʾS.T.ȻʾԼݱʾһϡ<=b߶Դһ+š

ʾǸԼǸԼûϵֻҪݱVarNumʾɡʾԼͬǣ֮䲻á+ӣáŷָһǡ>=0ʾԹ滮ѧģеıǷǸġ

2.2.2ؼ㷨

1ʾĿ꺯Ĺؼ㷨

     For   (i = 1; i<=; i++){

       If ( i == һ||һϵǸ)

          һޡ+

       Else

          һÿҪϡ+

      }

2ʾԼĹؼ㷨

     For  (j = 1; j<= Լ; j++){

       For ( i= 1; i<=+1; i++){

         If ( i == һ||һϵǸ)

            һޡ+

         Else

            Ifi == +1

               ÿԼϡ<=Լ

            Else

               һÿ߶Դһ+

          }

}

3ʾǸԼĹؼ㷨

     For  (i = 1; i<= ; i++){

       If  ( i == һ)

          ֮ϡ>=0

       Else

          һڱԴ

       }

עΪԼϵĶ뵽άConArrayУʾԹ滮ģʱǴóÿԼϵģ桰j<=ԼforеʵǸijдҪΪ⣬Ҳͬġ

2.3׼ģ

2.3.1ģ

Թ滮ı׼ʽĸص㣺Ŀ󻯡ԼΪʽ߱ǸҶǸڸַDZ׼ʽԹ滮⣬תΪ׼ʽõ㷨Ž⡣

Թ滮ģ͵Ĺ淶ʽ

    Թ滮ģ͵ı׼ʽ:

׼ģʾԹ滮ѧģģƣΨһڣÿԼһɳڱмԼмɳڱڷǸԼаɳڱ뼴ɡ

׼Ŀ꺯ʾģеĿ꺯һ£ޱ仯

Լı׼ԼConNumб׼ʾԼVarnum+1ڱ׼»ҪʾԼbԼϵԼԼϵConArray( )СһԼǰҪʾS.T.ȻʾԼݱʾÿһԼҪһɳڱɳڱϡ=bbΪԼɳڱԴһ+ţñĺһǸʱͲҪһ+š

׼ǸԼǸԼûϵֻҪݱVarNumԼConNumʾVarNum+ConNumɡʾԼͬǣмConNumɳڱҸ֮䲻á+ӣáŷָһϡ>=0ʾԹ滮ѧģеıǷǸġ

ͬʱڱ׼֮ҪConArrayеԼӺɳڱɳڱϵµ뵽һµConArray1УΪڱ׼ʱǴóЩϵģĻȽϷ㣬javaScriptһôڴάʱҪҪǼм飬ֻҪԶijȡ

2.3.2ؼ㷨

1׼ԼĹؼ㷨

     For (j = 1; j<=Լ; j++){

      For(i=1;i<=+1;i++){

       If(i==+1)

         һʾ+

       Else

{

          If( i == +1)

     ɳڱԼb

          Else if(һϵ)

             ÿԴһ+

}

}

     ʾԼ

}

˵ΪԼϵĶ뵽άConArray1Уڱ׼ʱǴóÿԼϵģ桰j<=ԼforеʵǸijдҪΪ⣬Ҳͬġ

2׼ǸԼĹؼ㷨

     For  (i = 1;i<=+Լ;i++){

       If  (i == һ)

          ϡ>=

       Else

          ϡ

      }

2.4ģ

2.4.1ģ

ģĹԹ滮ѧģ͵ļ㣬Ӧõ㷨ŽĿֵҳʼлﶼɳڱΪлģΪһλȻǰConArray1еٵ뵽mydataУmydataеֵøʼαеÿԪһһӦġΪ˸õɵαͬʱԺĵֻҪڸıеֵͿһĵαˡ

Ϳʼ㣬Ϊ¼裺

1ļCheck( )ֻҪǻļΪļ϶0Ϊ˼ͬʱǻǷǻǼļһģDzDzǷǻļͬʱ¼ļ뵽mydataһУڼļȫСڻ0ǰΪŽMaxValټ㣻ڼ0ѡȡӦıΪȻ¼ڶάmydataе±indexInμĺΪInBase( ) 

2ݽڶάmydataе±indexInϵmydataе±indexOutindexOutļǽmydataдbһгindexInһУindexInһС0ȵĶӦеĸоá-棬ʹṆ̀ҳmydataдСУоdzӦм¼ϵindexOutеȫǡ-Ļ˵ӦϵС0ͿжϳģûŽġindexInindexOutཻһmydata[indexOut-1][indexIn-1]ľDZεԪμĺΪOutBase( )

3ϵupdataMydata( )µķdzϵеĸϵԪԭϵdzϵгԸĽӦ뱾нϵԪϱеĸϵֵԭϵԼҲ㲢滻ڻBasVar( )У滻±ֵ

4ٸµϵCheck( )InBase( )OutBase r ( )͸ϵupdataMydata ( )ѭֱŽ⡣ĿֵMaxValڻĿ꺯ϵӦԼbۼӺ͡

ˣѭأ֪μMaxValֵأ

ǿͨһݹѭĴͬһflagIndexInǷڱεǷı䣬ıͼûиı˵ξŵ

2.4.2ؼ㷨

1ʱݹؼ㷨

      Function ݹ鷽( ){

       Check( );

       InBase( );

       OutBase( );

       If(εindexInֵı){

ñ

}

}

2ؼ㷨

     ļ㣺

      For(k = 1; k<=Լ; k++){

        ǻӦļΪ0

      }

     ǻļ㣺

      For(g =1; g<=Լ; g++){

        = Ŀ꺯ϵӦϵ

      }

3Ѱҽؼ㷨

      For( i = 1; i<=+Լ; i++){

        If (>0)

          ڴļֵӦıΪ

      }

4ؼ㷨

     For(i = 1; i<=Լ; i++){

       If (ϵ<=0 || <=0)

         á-ʾ

       Else{

       ǽӦϵ

 򣽻ӦԼ½Ӧϵ

       }

5ѰҳĹؼ㷨

     For (i = 1; i<=Լ; i++){

       If (бȽϳСij)

         СӦıΪ

       }

6ϵؼ㷨

     For(i = 1; i<=Լ; i++){

       If (dzӦϵ)

         dzϵ=ϵСӦ뱾нϵԪ+еĸϵ

       Else

         ϵ=ϵС1Ԫ

     }

7ʱŽĹؼ㷨

     For(i = 1; i<=Լ; i++){

        ʱŽ=Ŀ꺯ϵԼϵۼӺ

}

8ɵαĹؼ㷨

ͬdocument.createElement("table");һ

For(i=1; i<=Լ+3; i++){

      ڱвһ

For(j=1; j<=ºϵ; j++){

         ڸвԪ񣨵Ԫеݵmydataеֵ

 }

}

˵Ϊ˷ѧѧϰαĵ̣ϵͳе̷һʹѧӼ򵥡ˡ

2.5ʾϸģ

2.5.1ģ

ϸģּڰѼÿһ̼ÿбı仯ʾѧϰ߸ȷеĶüϸڡÿεеļ㷽ʽͬģֱŽ޽ֹͣ㡣ÿεġȷԼʱŽϸ̡

ϸ£

ѱϢȫ浽һάStrArrayУǾʹõģ˵StrArrayе±

1.1

1.1.1ηĻ˼·

Թ滮н⣨㣩ķϴģDzеġѡȡн⣬ӿһſı߽ƶһڵļ㣬Ҫ¼Ŀ꺯ֵԭĿ꺯ֵԹ滮Ŀҳһн⣬ǷΪŽ⣬Ž⣬ֹͣŽ⣬ôжԹ滮Ž⣬߸һóʹĿ꺯ֵӽֵһн⡣ڻнĸޣܿͨ޴εõԹ滮ŻнжԹ滮Ž⡣

1.1.2ηĻ

1ʼн⣬гʼα

ԷDZ׼͵Թ滮Ҫɱ׼ʽܿ跨ʹԼ̵ϵаһλ ԴΪһʼн⡣

ΪһнǷţҪĿ꺯ֵڻнĿ꺯ֵбȽϡΪд淶ͱڼ㣬Եηļһרű񣬳Ϊα(1-1)ÿҳһµĻнʱػһŵαʼнĵαƳʼαŽĵαյα

2Լ顣

1-1α

cj

c1

cm

cj

cn

CB

b

x1

xm

xj

xn

c1

c2

cm

x1

x2

xm

b1

b2

bm

1

0

0

0

0

1

 

a1j

a2j

amj

a1n

a2n

amn

cj-zj

0

0

мcj-zjQ0һв˹ʱеĻн⼴ΪŽ⣬дcj-zj >0ʱPjQ0Ϊ޽⣬תһ

3һнתڵĿ꺯ֵĻн⣬гµĵα

1.ȷıֻҪмj>0ӦıxjͿΪıһϼʱһҳһkӦıxkΪ

2.ȷı ȷxrdz,arkΪԪ

3.ýxk滻xrõһµĻ ӦҳһµĻн⣬ӦؿԻһµĵα(1-2)

(1) ѵrг ֮Ľ±ĵrУ Уѵrг ֮ԭеiУ еrλ в䣻 rԭֵԭͬ

(2) Ȼ ļֵϵ ȥ еĸԪ иӦԪصij˻Ѽ еһУõ 㲢 ֵȥ иԪbиԪصij˻[1]

4ظ̣ͿԵõŽжϳŽ⡣

1-2ʼα

cj

c1

cr

cm

cj

ck

CB

b

x1

xr

xm

xj

xk

c1

ck

cm

x1

xk

xm

1

0

0

0

0

1

 

0

1

0

 

cj- zj

0

0

0

1.1.3㷨Թ滮ķ

ʵУʵҪ󣬳ԽԹ滮ѧģ͡һõ㷨Թ滮ķ

ѹ˾ƻ,ּҵƷԭԴޣ֪һҵƷֱռõ豸AB̨ʱʱ䡢Թÿּҵ۳һĻ1-3ʾʸù˾ӦּҵټʹȡΪ

 

1-3 Ʒйݱ

Ŀ

ÿ

豸Ah

0

5

15

豸B(h)

6

2

24

Թ(h)

1

1

5

Ԫ

2

1

 

⣺⹹Թ滮ģͣ

Ŀ꺯     

        Լ

                   

                       

õηԹ滮⣬׼ã

   

 

 

   

ȡʼн λ󣩡ʼαĹ1-4ʾ

ŵαУǻ ļΪǵõŽ Ŀֵ Ԫ-17/2Ϊ-Zֵ

Ϊܹؿ嵥㷨Ľ˼·Լ㷨бڸĹϵе3ε£

һε

ȡʼл ô Ϊ ΪǻĿ꺯÷ǻʾ

 

 

 

ڶε

ǰĿл ô Ϊ ΪǻĿ꺯÷ǻʾ

              

ε

ǰĿл ô Ϊ ΪǻĿ꺯÷ǻʾ

               

Ŀ꺯 Уǻ ļǵõŽ ,Ŀֵ

 

1-4 α

cB

xB

b`

2

1

0

0

0

X1

X2

X3

X4

X5

0

X3

15

0

5

1

0

0

--

0

X4

24

[6]

2

0

1

0

4

0

X5

5

1

1

0

0

1

5

-Z

0

2

1

0

0

0

 

0

X3

15

0

5

1

0

0

3

2

X1

4

1

2/6

0

1/6

0

37/3

0

X5

1

0

[4/6]

0

-1/6

1

4/3

-Z

-8

0

1/3

0

-1/3

0

 

0

X3

15/2

0

0

1

5/4

-15/2

--

2

X1

7/2

1

0

0

1/4

-1/2

--

1

X2

3/2

0

1

0

-1/4

3/2

4/3

-Z

-17/2

0

0

0

-1/4

-1/2

 

ŵαУǻ ļΪǵõŽ Ŀֵ Ԫ-17/2Ϊ-Zֵ

 

 


ͼ1-1㷨ͼ

1.2M㷨

1.2.1M㷨Ļ˼

һԹ滮ϵвλʱûԵĻн⣬Ǹ˹ķóʼн⣬һôM㷨MҲΪͷҪȡM>0ΪһԭĿ꺯м-Mÿһ˹ȸݲʽĻ򸺵ɳڱҼɳڱǷ񹹳ɵλ󣬹ɵλ㷽͵㷨һδɵλӵ˹ɳڱһλм㡣ɳڱĿ꺯еϵΪ0˹ϵΪ-M˴-Mǿ˹һֳͷĿΪǿ˹ɱתΪǻʹָ֮ԭ˵ԭȼۡMڼʱɿһϸ˵ΪڼMʱжֵMϿ֤MֻҪȡijֵϾͿԡ

1.2.2M㷨Ļ

1.ɳڱɳڱϵǷ񹹳ɵλδɵλ˹ʹ˹ϵɳڱϵɵλҲ˹Ŀġ

2.ɳڱ˹˱׼Թ滮ģ͡

3.׼Թ滮ģ͵ķӦõ㷨ԴM㷨ĵ㷽͵㷨ļ㷽ͬ

4.M㷨к˹ϵ-M˹ĿǹɵλӦõ㷨㣬Dzܸıԭ⣬ÿ˹ԡ-Mܹ֤׼Թ滮ģԭȼۡ

5.-MΪַܲ㣬ȻMΪһһڽѧҪԹ滮ģ͹ģ̫ȡֵM=10000㡣еСM10000档

Ҫע֮⣬αļ뵥㷨ļͬ㷨ε㣬ֱõŽжϳŽΪֹ

㷨ʵ

2.1ģ

2.1.1ģ

ģҪʵֵĹǴӴԹ滮ѧģ͡ǵ¼棬ûԸԼʵҪѡõηǴMм㡣ǵηťʾηļ̡򿪵ηҳ󣬴Ӵģ͵ıVarNumԼConNumȻģ͵ıԼԶһΪÿȡһclassԣΪ˷ŵԶɵıDzݣҪݵĵԪаһıвҪݵĵԪ磺ͷʾϢȻñĿ꺯ϵԼϵԼbΪһConNum+1кVarNum+1еһԴʱҪһάConArrayš

ıVarNumֵԼConNumֵ֮ȷԹ滮ѧģ͵ıԼԼ

ģ͵ĹУԼϵԼĿ꺯ϵ֮ȷԹ滮ѧģ͡

2.1.2ؼ㷨

1.ԶɱĹؼ㷨

          For(var i=0;i<Լ+2;i++){

            str=str+"

---- b x("+j+") Ŀ꺯ϵ c("+i+")

value=''>

value=''>

--

--

--

C(1)

C(2)

C(3)

C(4)

C(5)

CB

XB

b

X(1)

X(2)

X(3)

X(4)

X(5)

C(3)

X(3)

b(1)

A(1,1)

A(1,2)

A(1,3)

A(1,4)

A(1,5)

--

C(4)

X(4)

b(2)

A(2,1)

A(2,2)

A(2,3)

A(2,4)

A(2,5)

--

C(5)

X(5)

B(2)

A(3,1)

A(3,2)

A(3,3)

A(3,4)

A(3,5)

--

-Z

(1)

(2)

(3)

(4)

(5)

--

ϸ̵ıʽ磺(1) = C(1)-C(3)*A(1,1)-C(4)*A(2,1)- C(5)*A(3,1) =1500-0*3-0*2-0*0=1500ʽַͨƴɵģڵʱͨݹɵģҪϸֻڵķж뼸ͿϸḶ́messageAbCheckɼϸ̺͸ôŽϸ̣calCoe()Լϵϸ̣ŽϸʽΪZ=C(3)*b(1)+C(4)*b(2)+C(5)*b(3)=0-0*65+0*40+0*75=0Լϵϸ̵ıΪ,ͬԪͬһеʱʽΪA(3,1)=A(3,1)/A(3,2)=0/3=0 (A(3,2)Ԫ) Ԫͬһеʱʽǣ

A(1,1)=A(3,1)*[-A(1,2)/A(3,2)]+A(1,1)=0* (-2/3)+3=3

Ƿʾϸ̣ݸ˵IJͬҪ˱ȽԻƣֻõͲʾϸ̣ѧϰ˳ѧ㷨ôĹоͿԵʾϸ̡ťͿԿϸ̣һĿȻȽⵥηԭ

2.5.2ؼ㷨

1ʾϸŽ̵ĺ룺

Function messageAbCheck(){

//mymessage

    mymessage=mymessage+"
ļ̣
";

//ƴӱʽһַC(1)-C(3)*A(1,1)-C(4)*A(2,1)-

C(5)*A(3,1)

    var str1="";

//ƴӱʽһַ1500-0*3-0*2-0*0

var str2="";

    //ΪstrArrayһмļǴӵпʼ

    For(var i=3;i<ɳڱԼϵĸ+3;i++){

       str1="";

          str2="";

          str1=strArray[conNum+2][i]+"="+strArray[0][i]+"-";

          str2=mydata[0][i]+"-";

       For(var j=2;j

//strArrayеһżĵԪʼƴ

//һǻ

          If(j==conNum+1){

               str1=str1+strArray[j][0]+"*"+strArray[j][i]+"=";

                       str2=str2+mydata[j][0]+"*"+mydata[j][i]+"="+mydata[conNum+2][i]+"

";

           }

//

             else {

                   str1=str1+strArray[j][0]+"*"+strArray[j][i]+"-";

                   str2=str2+mydata[j][0]+"*"+mydata[j][i]+"-";

             }

          }

//ַһ

         mymessage=mymessage+str1+str2;

   }

     //Ŀֵϸ

//str1str2

     str1="";

     str2="";

    mymessage=mymessage+"εĿֵϸ:
";

   For(var i=2;i

      If(i==conNum+1){

           str1=str1+strArray[i][0]+"*"+strArray[i][2]+"=";

              str2=str2+mydata[i][0]+"*"+mydata[i][2]+"="+(-mydata[conNum+2][2])+"

";

         }

      else{

        str1=str1+strArray[i][0]+"*"+strArray[i][2]+"+";

           str2=str2+mydata[i][0]+"*"+mydata[i][2]+"+";

         }

    }

        mymessage=mymessage+"Z="+str1+str2;

}

2ʾϵϸ̵ĺ

Function calCoe(){

      mymessage=mymessage+""+(count)+"ε

";

      mymessage=mymessage+"Լϵϸ̣

";

      mymessage=mymessage+"εԪΪ"+strArray[indexOut] [indexIn] +"
";

      var str1="";

      var str2="";

//resultŽʽļ

      var result;

      For(var i=2;i

       For(var j=3;j

           str1="";

        str2="";

//ԪͬһеĻ

          If(i==indexOut){

  str1=strArray[i][j]+"="+strArray[i][j]+"/"+strArray[indexOut][indexIn]+"=";

             str2=mydata[i][j]+"/"+mydata[indexOut][indexIn]+"=";

             result=parseFloat((mydata[i][j]/mydata[indexOut][indexIn]).toFixed(2));

             mymessage=mymessage+str1+str2+result+"

";

          }

         else {

             str1=strArray[i][j]+"="+strArray[indexOut][j]+"*[-"+strArray[i][indexIn]+"/"

             +strArray[indexOut][indexIn]+"]+"+strArray[i][j]+"=";

            str2=mydata[indexOut][j]+"*["+(-mydata[i][indexIn])+"/"

             +mydata[indexOut][indexIn]+"]+"+mydata[i][j]+"=";

//ʽĽ                            result=parseFloat((parseFloat(mydata[indexOut][j])*(parseFloat(-mydata[i][indexIn])/parseFloat(mydata[indexOut][indexIn]))+ parseFloat(mydata[i][j])).toFixed(2));

//ʽͽƴӵһ

mymessage=mymessage+str1+str2+result+"

";

         }

        }

    } 

}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

4

4.1


Թ滮ģͶвԣģͼʾ

ģͽݣ

3

Լ4

--

X(1)

X(2)

X(3)

b

C(1)

1

1

2

9

C(2)

1

0

2

15

C(3)

4

1

5

25

C(4)

2

2

3

17

Ŀ꺯ϵ

10

20

15

--

õĽǻļֵ:170ŽΪx(4)=0.5 ,x(5)=15 ,x(6)=16.5 , x(2)=8.5δ֪0

ģͽݣ

3

Լ2

--

X(1)

X(2)

X(3)

b

C(1)

2

7

1

30

C(2)

6

1

3

45

Ŀ꺯ϵ

15

30

28

--

õǻļֵ:467.44ŽΪx(2)=2.3 ,x(3)=14.23 ,δ֪0

ģͽݣ

2

Լ4

--

X(1)

X(2)

b

C(1)

2

3

65

C(2)

4

6

83

C(3)

2

4

30

C(4)

4

1

45

Ŀ꺯ϵ

2

1

--

õǻļֵ:3293.62ŽΪx(3)=37.14 x(4)=27.29  ,x(2)=2.14 x(1)=10.71 δ֪0

ģͽݣ

2

Լ2

--

X(1)

X(2)

b

C(1)

2

-3

3

C(2)

-1

1

5

Z

3

2

--

õӦϵСڵ0,Ž

ģͽݣ

3

Լ3

--

X(1)

X(2)

X(3)

b

C(1)

2

1

3

24

C(2)

0

2

3

43

C(3)

4

2

4

26

Ŀ꺯ϵ

34

62

15

--

õǻļֵ: 806ŽΪx(4)=11 ,x(5)=17 ,x(2)=13 ,δ֪0

ģͽݣ

4

Լ4

--

X(1)

X(2)

X(3)

X(4)

b

C(1)

3

2

1

4

45

C(2)

3

5

2

4

65

C(3)

2

3

5

2

34

 

2

4

2

5

35

Ŀ꺯ϵ

53

24

64

34

--

õǻļֵ:837.45,ŽΪx(1)=14.69 ,x(6)=19.08 ,x(3)=0.92 , ,x(8)=3.77,δ֪0

Թ滮ģͶβԿ֪˳ѧԹ滮ģ͵νѧʾȷн޽ܼܹﵽѧʾĿġ

 

 

 

 

 

 

 

 

ο

[1]  .˳ѧ2棩[M].еҵ

[2]  Ȩ.˳ѧ̳̣ڶ棩.廪ѧ

[3]  Ȩ.˳ѧۣ8棩.廪ѧ

[4]  ֣ƣκȻ.Jquery.ʵ

[5]  َ֣볡.HTML&CSS&JavaScript﷨ǵ.й

[6]  ʯ.˳ѧγ̽ѧĸļ˼.ѧԺѧ20102

[7]  ƿԪ.dz˳ѧĽ.ǣ200906


ͳ