m_nlp.pwSin.deactivate() m_nlp.pwCos.deactivate() def _cos(m, t): return m.cth[t] == cos(m.th[t]) m_nlp.Cos = Constraint(m_nlp.t, rule=_cos) def _sin(m, t): return m.sth[t] == sin(m.th[t]) m_nlp.Sin = Constraint(m_nlp.t, rule=_sin) opt_nlp = SolverFactory('ipopt') #opt = constructGurobiSolver(mipgap=0.8, MIPFocus=1, TimeLimit=90., Threads=11) opt = constructGurobiSolver(mipgap=0.5, TimeLimit=40., Threads=11) hop.constructVisualizer() #results = opt_nlp.solve(m_nlp, tee=True) #m_nlp.solutions.load_from(results) #hop.loadResults(m_nlp) results = opt.solve(m, tee=True) m.solutions.store_to(results) m_nlp.solutions.load_from(results, ignore_invalid_labels=True) fixIntegerVariables(m_nlp) results_nlp = opt_nlp.solve(m_nlp, tee=True) hop.loadResults(m_nlp)