func solve(dict *lp.Dict, epsInt float64) Solution { if !dict.Feas() { log.Println("init. dict. not feasible: solve feas. problem") // Solve the feasibility problem. var infeas bool dict, infeas = lp.SolveFeas(dict) if infeas { // Continuous relaxation is infeasible, // therefore integer problem is infeasible. fmt.Println("infeasible") return Solution{Infeas: true} } } else { log.Println("init. dict. feasible") } log.Println("solve") var unbnd bool dict, unbnd = lp.PivotToFinal(dict) if unbnd { // Relaxation became unbounded. log.Println("primal is unbounded") return Solution{Unbnd: true} } for !dict.IsIntEps(epsInt) { fmt.Printf("primal objective coeffs: %.4g\n", dict.C) // Check if integer solution. log.Println("add cutting-plane constraints") dict = lp.CutPlane(dict) log.Println("feasible?", dict.Feas()) log.Println("switch to dual") dict = dict.Dual() log.Println("feasible?", dict.Feas()) log.Println("solve") var unbnd bool dict, unbnd = lp.PivotToFinal(dict) if unbnd { // Dual of relaxation became unbounded. log.Println("dual is unbounded (primal infeasible)") return Solution{Infeas: true} } log.Println("feasible?", dict.Feas()) log.Println("switch to primal") dict = dict.Dual() log.Println("objective:", dict.Obj()) // // Find a feasible solution. // var infeas bool // log.Println("solve feasibility problem") // dict, infeas = lp.SolveFeas(dict) // if infeas { // // Continuous relaxation is infeasible, // // therefore integer problem is infeasible. // log.Println("primal is infeasible") // return Solution{Infeas: true} // } // var unbnd bool // log.Println("solve problem") // dict, unbnd = lp.Solve(dict) // if unbnd { // // Relaxation became unbounded. // log.Println("primal is unbounded") // return Solution{Unbnd: true} // } } return Solution{Obj: dict.Obj()} }