René's URL Explorer Experiment


Title: Set of constraints raises Error · Issue #702 · python-control/python-control · GitHub

Open Graph Title: Set of constraints raises Error · Issue #702 · python-control/python-control

X Title: Set of constraints raises Error · Issue #702 · python-control/python-control

Description: I am using the python optimal control library to optimise the trajectory of a 2D rocket. Please find attached a minimum reproducible sample code of the optimisation process of the problem. Whenever I am trying to set constraints for only...

Open Graph Description: I am using the python optimal control library to optimise the trajectory of a 2D rocket. Please find attached a minimum reproducible sample code of the optimisation process of the problem. Whenever...

X Description: I am using the python optimal control library to optimise the trajectory of a 2D rocket. Please find attached a minimum reproducible sample code of the optimisation process of the problem. Whenever...

Opengraph URL: https://github.com/python-control/python-control/issues/702

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Set of constraints raises Error","articleBody":"I am using the python optimal control library to optimise the trajectory of a 2D rocket. Please find attached a minimum reproducible sample code of the optimisation process of the problem. Whenever I am trying to set constraints for only some of the states, I get the error described after the minimum reproducible example. Is there an appropriate way to define multiple separate constraints passed in the \"constraints= [..., ..., ...]\" argument of the solve.ocp() function? Also, instead of using range -np.inf to np.inf for state parameters that I do not want to bound, is there a value that makes the code ignore the specific state parameter constraints?\r\n\r\n```\r\nT_max_Single = 7607000/9\r\n\r\ng = 9.81 \r\nm = 114239.00\r\nk = 18.74\r\nI = 16071705.59\r\n\r\nimport numpy as np\r\nimport math\r\nimport control as ct\r\nimport control.optimal as opt\r\nimport matplotlib.pyplot as plt\r\nimport logging\r\nimport time\r\nimport os\r\nplt.style.use(\"default\")\r\nfrom IPython.display import display\r\nfrom colorama import *\r\nimport sympy as s\r\nfrom scipy.integrate import odeint\r\n\r\n\r\n#Definition of the states\r\ndef rocket_update(t, x, u, params):\r\n        \r\n    xpos = x[0] \r\n    U = x[1] \r\n    z = x[2] \r\n    W = x[3] \r\n    θ = x[4] \r\n    q = x[5] \r\n    \r\n    T = u[0]\r\n    a = u[1]\r\n\r\n    # Return the derivative of the state\r\n    dydt = np.array([U,\r\n            T*np.cos(θ-a)/m, \r\n            W,\r\n            T*np.sin(θ-a)/m-g,\r\n            q,\r\n            T*k*np.sin(a)/I])\r\n    \r\n    return(dydt)\r\n\r\ndef rocket_output(t, x, u, params):\r\n    return x                            # return (full state)\r\n\r\n\r\n\r\nTf = 8\r\n\r\n\r\n\r\n# Define the rocket movement dynamics as an input/output system\r\nrocket = ct.NonlinearIOSystem(\r\n    rocket_update, rocket_output, states=6, name='rocket',\r\n    inputs=(\"T\", \"α\"), outputs=(\"x\", \"U\", \"z\", \"W\", \"θ\", \"q\")) \r\n\r\n# Define the time horizon (and spacing) for the optimization\r\nhorizon = np.linspace(0, Tf, Tf, endpoint=True)                                        #############IMPORTANT\r\n\r\n# Provide an intial guess (will be extended to entire horizon)\r\nbend_left = [T_max_Single, 0.01]          # slight left veer                     #############IMPORTANT\r\n\r\n\r\n# Optimal Control Problem\r\nInitial_x = 0 #m\r\nFinal_x =  5 #m\r\n\r\nInitial_z =  0 #m\r\nFinal_z = 200 #m\r\n\r\nInitial_θ = np.pi/2 #m\r\nFinal_θ = np.pi/3 #m\r\n\r\nFinal_Thrust = T_max_Single\r\n\r\nx0 = [Initial_x, 0, Initial_z, 0, Initial_θ, 0]; u0 = [bend_left[0], bend_left[1]]\r\nxf = [Final_x, 0, Final_z, 0, Final_θ, 0]; uf = [Final_Thrust, 0]\r\n\r\n#T_max_Single\r\nMin_T = 1 * T_max_Single\r\nMax_T = 9 * T_max_Single\r\na_min = -20* np.pi/180\r\na_max = 20* np.pi/180\r\n\r\n# Approach 3: terminal constraints\r\n#\r\n# We can also remove the cost function on the state and replace it\r\n# with a terminal *constraint* on the state.  If a solution is found,\r\n# it guarantees we get to exactly the final state.\r\n#\r\nprint(\"Initialisation of optimisation\")    \r\n# print(\"Checkpoint_1\")\r\n\r\n# Input cost and terminal constraints\r\nR = np.diag([0, 0])                 # minimize applied inputs\r\ncost3 = opt.quadratic_cost(rocket, np.zeros((6,6)), R, u0=uf)\r\n\r\ncon1 = [ opt.input_range_constraint(rocket, [Min_T, a_min], [Max_T, a_max]) ]\r\n\r\nterminal = [ opt.state_range_constraint(rocket, [Final_x, -np.inf, Final_z, -np.inf, -np.inf, -np.inf],\r\n                                                [Final_x, np.inf, Final_z, np.inf, np.inf, np.inf]) ]\r\n\r\n\r\n# Reset logging to its default values\r\nlogging.basicConfig(\r\n    level=logging.DEBUG, filename=\"./steering-terminal_constraint.log\",\r\n    filemode='w', force=True)\r\n\r\n# Compute the optimal control\r\nstart_time = time.process_time()\r\nresult3 = opt.solve_ocp(\r\n    rocket, horizon, x0, cost3, con1,          \r\n    terminal_constraints=terminal, initial_guess=bend_left, log=False, method=\"trust-constr\",\r\n    options={'eps': 0.01})\r\n\r\nprint(\"* Total time = %5g seconds\\n\" % (time.process_time() - start_time))\r\n```\r\n\r\nError:\r\n\r\n```\r\n/opt/anaconda3/lib/python3.8/site-packages/scipy/optimize/_constraints.py:386: OptimizeWarning: At least one constraint is unbounded above and below. Such constraints are ignored.\r\n  warn(\"At least one constraint is unbounded above and below. Such \"\r\n/opt/anaconda3/lib/python3.8/site-packages/scipy/optimize/_constraints.py:432: OptimizeWarning: Equality and inequality constraints are specified in the same element of the constraint list. For efficient use with this method, equality and inequality constraints should be specified in separate elements of the constraint list. \r\n  warn(\"Equality and inequality constraints are specified in the same \"\r\n```","author":{"url":"https://github.com/ThomasGiavasopoulos","@type":"Person","name":"ThomasGiavasopoulos"},"datePublished":"2022-02-18T14:35:31.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":6},"url":"https://github.com/702/python-control/issues/702"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:4585584c-9392-8d6e-e515-40ee9819c621
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE4FA:90CEE:1276F3E:1A7E789:697A3792
html-safe-nonce30a36da4b18b62f00021e6238d37a01db11ab9e5172eba02229144f825fb5a8d
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNEZBOjkwQ0VFOjEyNzZGM0U6MUE3RTc4OTo2OTdBMzc5MiIsInZpc2l0b3JfaWQiOiI4MjE5NDM4OTkzODUwOTA2NTE0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac7e7be2ca4e28940875557340098734096b0cafe1825f95b3c3564f0ef0d77507
hovercard-subject-tagissue:1143173764
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python-control/python-control/702/issue_layout
twitter:imagehttps://opengraph.githubassets.com/7b9d654270f6bb914053b12aa60ecdd3d52e95000996cb2193348fce2fb51f56/python-control/python-control/issues/702
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/7b9d654270f6bb914053b12aa60ecdd3d52e95000996cb2193348fce2fb51f56/python-control/python-control/issues/702
og:image:altI am using the python optimal control library to optimise the trajectory of a 2D rocket. Please find attached a minimum reproducible sample code of the optimisation process of the problem. Whenever...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameThomasGiavasopoulos
hostnamegithub.com
expected-hostnamegithub.com
Noneaf6de804ceb83ad30bb9b348cdeaccaa30cdcb566762d5e74e21e2bad88885d0
turbo-cache-controlno-preview
go-importgithub.com/python-control/python-control git https://github.com/python-control/python-control.git
octolytics-dimension-user_id2285872
octolytics-dimension-user_loginpython-control
octolytics-dimension-repository_id22791752
octolytics-dimension-repository_nwopython-control/python-control
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id22791752
octolytics-dimension-repository_network_root_nwopython-control/python-control
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release2d980605f0959039ddebcbcf522b072508302977
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python-control/python-control/issues/702#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-control%2Fpython-control%2Fissues%2F702
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython-control%2Fpython-control%2Fissues%2F702
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python-control%2Fpython-control
Reloadhttps://github.com/python-control/python-control/issues/702
Reloadhttps://github.com/python-control/python-control/issues/702
Reloadhttps://github.com/python-control/python-control/issues/702
python-control https://github.com/python-control
python-controlhttps://github.com/python-control/python-control
Notifications https://github.com/login?return_to=%2Fpython-control%2Fpython-control
Fork 447 https://github.com/login?return_to=%2Fpython-control%2Fpython-control
Star 2k https://github.com/login?return_to=%2Fpython-control%2Fpython-control
Code https://github.com/python-control/python-control
Issues 87 https://github.com/python-control/python-control/issues
Pull requests 8 https://github.com/python-control/python-control/pulls
Discussions https://github.com/python-control/python-control/discussions
Actions https://github.com/python-control/python-control/actions
Projects 0 https://github.com/python-control/python-control/projects
Wiki https://github.com/python-control/python-control/wiki
Security 0 https://github.com/python-control/python-control/security
Insights https://github.com/python-control/python-control/pulse
Code https://github.com/python-control/python-control
Issues https://github.com/python-control/python-control/issues
Pull requests https://github.com/python-control/python-control/pulls
Discussions https://github.com/python-control/python-control/discussions
Actions https://github.com/python-control/python-control/actions
Projects https://github.com/python-control/python-control/projects
Wiki https://github.com/python-control/python-control/wiki
Security https://github.com/python-control/python-control/security
Insights https://github.com/python-control/python-control/pulse
New issuehttps://github.com/login?return_to=https://github.com/python-control/python-control/issues/702
New issuehttps://github.com/login?return_to=https://github.com/python-control/python-control/issues/702
Set of constraints raises Errorhttps://github.com/python-control/python-control/issues/702#top
https://github.com/murrayrm
0.9.2https://github.com/python-control/python-control/milestone/10
https://github.com/ThomasGiavasopoulos
https://github.com/ThomasGiavasopoulos
ThomasGiavasopouloshttps://github.com/ThomasGiavasopoulos
on Feb 18, 2022https://github.com/python-control/python-control/issues/702#issue-1143173764
murrayrmhttps://github.com/murrayrm
0.9.2https://github.com/python-control/python-control/milestone/10
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.